protected String addPortToIP(String podIP, Integer containerPort, String portNumberOrName) { if (containerPort != null) { if (containerPort > 0 && containerPort != 80) { return podIP + ":" + containerPort; } } if (Strings.isNotBlank(portNumberOrName)) { return podIP + ":" + portNumberOrName; } else { return podIP; } }
private void addPortIfValid(List<String> list, String port) { if (Strings.isNotBlank(port)) { list.add(port); } }
private void addPortIfValid(List<String> list, String port) { if (Strings.isNotBlank(port)) { list.add(port); } }
public static String joinPaths(String parentPath, String name) { String path = name; if (Strings.isNotBlank(parentPath)) { String separator = path.endsWith("/") || name.startsWith("/") ? "" : "/"; path = parentPath + separator + name; } return path; }
private String getLocalDockerRegistry() { if (Strings.isNotBlank(System.getenv(Constants.FABRIC8_DOCKER_REGISTRY_SERVICE_HOST))){ return System.getenv(Constants.FABRIC8_DOCKER_REGISTRY_SERVICE_HOST) + ":" + System.getenv(Constants.FABRIC8_DOCKER_REGISTRY_SERVICE_PORT); } return null; }
private Class getClientCreator() { Class creatorClass = null; String creatorClassName = System.getProperty(Constants.CLIENT_CREATOR_CLASS_NAME); try { if (Strings.isNotBlank(creatorClassName)) creatorClass = KubernetesExtension.class.getClassLoader().loadClass(creatorClassName); } catch (Throwable t) { //fallback to default } return creatorClass != null ? creatorClass : ClientCreator.class; } }
/** * Returns the version to use for the fabric8 archetypes */ public static String fabric8ArchetypesVersion() { String version = System.getenv(ENV_FABRIC8_ARCHETYPES_VERSION); if (Strings.isNotBlank(version)) { return version; } return MavenHelpers.getVersion("io.fabric8.archetypes", "archetypes-catalog"); }
/** * If a slug is not supplied then lets generate it from the project name */ protected String validateSlug(String slug, String name) { if (Strings.isNotBlank(slug)) { return slug; } else { return getUsername() + "-" + name; } }
private String getAuthenticationHeader() { String token = getAuthToken(); if (Strings.isNotBlank(token)) { return "Bearer " + token; } else { return null; } } }
public void addService(Service service) { String id = getId(service); if (Strings.isNotBlank(id)) { services.put(id, service); } }
protected String decodeSecretData(String text) { if (Strings.isNotBlank(text)) { return Base64Encoder.decode(text); } else { return text; } }
public void filter(ClientRequestContext requestContext) throws IOException { MultivaluedMap<String, Object> headers = requestContext.getHeaders(); String authenticationHeader = getAuthenticationHeader(); if (Strings.isNotBlank(authenticationHeader)) { headers.add("Authorization", authenticationHeader); } }
private void addDeploymentVersion(Map<String, String> deploymentVersions, HasMetadata resource) { String name = KubernetesHelper.getName(resource); String version = KubernetesHelper.getLabels(resource).get("version"); // TODO if there is no version label could we find it from somewhere else? if (Strings.isNotBlank(version)) { deploymentVersions.put(name, version); } else { listener.getLogger().println("No version label for " + KubernetesHelper.getKind(resource) + " " + KubernetesHelper.getName(resource) + " in namespace " + KubernetesHelper.getNamespace(resource)); } }
public void addController(ReplicationController controller) { String id = getId(controller); if (Strings.isNotBlank(id)) { controllers.put(id, controller); // now lets find all the pods that are active for this List<Pod> pods = snapshot.podsForReplicationController(controller); for (Pod pod : pods) { addPod(pod); } } }
private void addDeploymentVersion(Map<String, String> deploymentVersions, HasMetadata resource) { String name = KubernetesHelper.getName(resource); String version = KubernetesHelper.getLabels(resource).get("version"); // TODO if there is no version label could we find it from somewhere else? if (Strings.isNotBlank(version)) { deploymentVersions.put(name, version); } else { listener.getLogger().println("No version label for " + KubernetesHelper.getKind(resource) + " " + KubernetesHelper.getName(resource) + " in namespace " + KubernetesHelper.getNamespace(resource)); } }
public static void configureUserAndPassword(WebClient webClient, String username, String password) { if (Strings.isNotBlank(username) && Strings.isNotBlank(password)) { HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit(); conduit.getAuthorization().setUserName(username); conduit.getAuthorization().setPassword(password); } }
private void addGitServiceUrl(Map<String, String> annotations, String repoName, String gitCommitId) { String username = getGitUserName(); // this requires online access to kubernetes so we should silently fail if no connection String gogsUrl = getExternalServiceURL(getConfig(Config.gitService), "http"); String rootGitUrl = URLUtils.pathJoin(gogsUrl, username, repoName); rootGitUrl = URLUtils.pathJoin(rootGitUrl, "commit", gitCommitId); if (Strings.isNotBlank(rootGitUrl)) { annotations.put(Annotations.Builds.GIT_URL, rootGitUrl); } }
public KubernetesClient getKubernetes() { if (kubernetes == null) { String kubernetesAddress = kubernetesUrl.getValue(); if (Strings.isNotBlank(kubernetesAddress)) { kubernetes = new KubernetesClient(new KubernetesFactory(kubernetesAddress)); } else { kubernetes = new KubernetesClient(); } } Objects.notNull(kubernetes, "kubernetes"); return kubernetes; }
public static BuildConfig createIntegrationTestBuildConfig(String buildConfigName, Map<String, String> labels, String gitUrlText, String image, List<EnvVar> envVars) { BuildConfigBuilder buildConfigBuilder = buildConfigBuilder(buildConfigName, labels); BuildConfigSpecBuilder specBuilder = new BuildConfigSpecBuilder(); addBuildParameterGitSource(specBuilder, gitUrlText); if (Strings.isNotBlank(image)) { addBuildParameterCustomStrategy(specBuilder, image, envVars); } return buildConfigBuilder.withSpec(specBuilder.build()).build(); } }
public static BuildConfig createIntegrationTestBuildConfig(String buildConfigName, Map<String, String> labels, String gitUrlText, String image, List<EnvVar> envVars) { BuildConfigBuilder buildConfigBuilder = buildConfigBuilder(buildConfigName, labels); BuildConfigSpecBuilder specBuilder = new BuildConfigSpecBuilder(); addBuildParameterGitSource(specBuilder, gitUrlText); if (Strings.isNotBlank(image)) { addBuildParameterCustomStrategy(specBuilder, image, envVars); } return buildConfigBuilder.withSpec(specBuilder.build()).build(); } }