protected void loadDependency(Logger log, List<KubernetesList> kubeConfigs, File file, Controller controller, Configuration configuration, Logger logger, String namespace) throws IOException { if (file.isFile()) { log.info("Loading file " + file); Object content; if (file.getName().endsWith(".yaml") || file.getName().endsWith(".yml")) { content = loadYaml(file); } else { content = loadJson(file); } addConfig(kubeConfigs, content, controller, configuration, log, namespace, file.getPath()); } else { File[] children = file.listFiles(); if (children != null) { for (File child : children) { String name = child.getName().toLowerCase(); if (name.endsWith(".json") || name.endsWith(".yaml") || name.endsWith(".yml")) { loadDependency(log, kubeConfigs, child, controller, configuration, log, namespace); } } } } }
public void loadDependency(Logger log, List<KubernetesList> kubeConfigs, String dependency, Controller controller, Configuration configuration, String namespace) throws Exception { // lets test if the dependency is a local string String baseDir = System.getProperty("basedir", "."); String path = baseDir + "/" + dependency; File file = new File(path); if (file.exists()) { loadDependency(log, kubeConfigs, file, controller, configuration, log, namespace); } else { String text = readAsString(createURL(dependency)); Object resources; if (text.trim().startsWith("---") || dependency.endsWith(".yml") || dependency.endsWith(".yaml")) { resources = loadYaml(text); } else { resources = loadJson(text); } addConfig(kubeConfigs, resources, controller, configuration, log, namespace, dependency); } }
private String loadKubernetesExposeControllerCommandLine(KubernetesClient kubernetes, String commands) throws Exception { String namespace = System.getenv("KUBERNETES_NAMESPACE"); if (Strings.isNullOrBlank(namespace)) { namespace = KubernetesHelper.getNamespace(kubernetes); } ConfigMap configMap = kubernetes.configMaps().inNamespace(namespace).withName("exposecontroller").get(); if (configMap == null) { listener.getLogger().println("WARNING: no ConfigMap in namespace " + namespace + " called: exposecontroller so cannot run exposecontroller to expose Service URLs"); return null; } String configYaml = null; Map<String, String> data = configMap.getData(); if (data != null) { configYaml = data.get("config.yml"); } if (Strings.isNullOrBlank(configYaml)) { throw new Exception("ConfigMap " + namespace + "/exposecontroller does not have a `config.yml` data entry"); } Map map; try { map = KubernetesHelper.loadYaml(configYaml, Map.class); } catch (IOException e) { throw new Exception("Could not parse YAML in ConfigMap " + namespace + "/exposecontroller entry `config.yml`: " + e, e); } StringBuilder builder = new StringBuilder(commands); appendCliArgument(builder, "--http", map.get("http")); appendCliArgument(builder, "--exposer", map.get("exposer")); appendCliArgument(builder, "--domain", map.get("domain")); return builder.toString(); }
private String loadKubernetesExposeControllerCommandLine(KubernetesClient kubernetes, String commands) throws Exception { String namespace = System.getenv("KUBERNETES_NAMESPACE"); if (Strings.isNullOrBlank(namespace)) { namespace = KubernetesHelper.getNamespace(kubernetes); } ConfigMap configMap = kubernetes.configMaps().inNamespace(namespace).withName("exposecontroller").get(); if (configMap == null) { listener.getLogger().println("WARNING: no ConfigMap in namespace " + namespace + " called: exposecontroller so cannot run exposecontroller to expose Service URLs"); return null; } String configYaml = null; Map<String, String> data = configMap.getData(); if (data != null) { configYaml = data.get("config.yml"); } if (Strings.isNullOrBlank(configYaml)) { throw new Exception("ConfigMap " + namespace + "/exposecontroller does not have a `config.yml` data entry"); } Map map; try { map = KubernetesHelper.loadYaml(configYaml, Map.class); } catch (IOException e) { throw new Exception("Could not parse YAML in ConfigMap " + namespace + "/exposecontroller entry `config.yml`: " + e, e); } StringBuilder builder = new StringBuilder(commands); appendCliArgument(builder, "--http", map.get("http")); appendCliArgument(builder, "--exposer", map.get("exposer")); appendCliArgument(builder, "--domain", map.get("domain")); return builder.toString(); }
PipelineMetadata metadata = null; try { metadata = loadYaml(yamlFile, PipelineMetadata.class); } catch (IOException e) { LOG.warn("Failed to parse yaml file " + yamlFile + ". " + e, e);
private List<HasMetadata> loadImageStreams() throws IOException, InterruptedException { if (kubernetes.isAdaptable(OpenShiftClient.class)) { FilePath child = workspace.child("target"); if (child.exists() && child.isDirectory()) { List<FilePath> paths = child.list(); if (paths != null) { for (FilePath path : paths) { String name = path.getName(); if (path.exists() && !path.isDirectory() && name.endsWith("-is.yml")) { try (InputStream is = path.read()) { listener.getLogger().println("Loading OpenShift ImageStreams file: " + name); KubernetesResource dto = KubernetesHelper.loadYaml(is, KubernetesResource.class); return KubernetesHelper.toItemList(dto); } } } } } } return Collections.emptyList(); }
private List<HasMetadata> loadImageStreams() throws IOException, InterruptedException { if (kubernetes.isAdaptable(OpenShiftClient.class)) { FilePath child = workspace.child("target"); if (child.exists() && child.isDirectory()) { List<FilePath> paths = child.list(); if (paths != null) { for (FilePath path : paths) { String name = path.getName(); if (path.exists() && !path.isDirectory() && name.endsWith("-is.yml")) { try (InputStream is = path.read()) { listener.getLogger().println("Loading OpenShift ImageStreams file: " + name); KubernetesResource dto = KubernetesHelper.loadYaml(is, KubernetesResource.class); return KubernetesHelper.toItemList(dto); } } } } } } return Collections.emptyList(); }
String configPath = configUrl.getPath(); if (configPath.endsWith(".yml") || configPath.endsWith(".yaml")) { dto = loadYaml(configText, KubernetesResource.class); } else { dto = loadJson(configText);
dto = KubernetesHelper.loadJson(resources); } else { dto = KubernetesHelper.loadYaml(resources.getBytes(), KubernetesResource.class);
dto = KubernetesHelper.loadJson(resources); } else { dto = KubernetesHelper.loadYaml(resources.getBytes(), KubernetesResource.class);