public String getCurrentNamespace() { String answer = kubernetesClient.getNamespace(); if (Strings.isNullOrBlank(answer)) { answer = KubernetesHelper.defaultNamespace(); } if (Strings.isNullOrBlank(answer)) { answer = System.getenv("KUBERNETES_NAMESPACE"); } if (Strings.isNullOrBlank(answer)) { answer = "default"; } return answer; }
private String getNamespace() { String namespace = getContext().getNamespace(); if (Strings.isNullOrBlank(namespace)) { namespace = KubernetesHelper.defaultNamespace(); } return Strings.isNullOrBlank(namespace) ? DEFAULT_NAMESPACE : namespace; }
protected String getGogsURL(boolean external) { StopWatch watch = new StopWatch(); String namespace = kubernetesClient.getNamespace(); if (Strings.isNullOrEmpty(namespace)) { namespace = KubernetesHelper.defaultNamespace(); } String serviceName = GOGS; String answer = KubernetesHelper.getServiceURL(kubernetesClient, serviceName, namespace, "http", external); if (Strings.isNullOrEmpty(answer)) { String kind = external ? "external" : "internal"; throw new IllegalStateException("Could not find external URL for " + kind + " service: gogs!"); } if (!external) { // lets stick with the service name instead as its easier to grok return "http://" + serviceName + "/"; } LOG.info("getGogsURL took " + watch.taken()); return answer; } }
public static GitlabClient createGitRepoClient(KubernetesClient kubernetes, String userName, String password) { if (Strings.isNullOrBlank(userName)) { userName = Systems.getEnvVarOrSystemProperty(JENKINS_GOGS_USER, "gogsadmin"); } if (Strings.isNullOrBlank(password)) { password = Systems.getEnvVarOrSystemProperty(JENKINS_GOGS_PASSWORD, "RedHat$1"); } String namespace = KubernetesHelper.defaultNamespace(); String address; try { address = KubernetesHelper.getServiceURL(kubernetes, ServiceNames.GITLAB, namespace, "http", true); if (Strings.isNullOrBlank(address)) { LOG.warn("No Gitlab service could be found in kubernetes " + namespace + " on address: " + kubernetes.getMasterUrl()); return null; } } catch (IllegalArgumentException e) { LOG.warn("No Gitlab service could be found in kubernetes " + namespace + " on address: " + kubernetes.getMasterUrl()); return null; } LOG.info("Logging into Gitlab at " + address + " as user " + userName); return new GitlabClient(address, userName, password); } }
public static GitRepoClient createGitRepoClient(KubernetesClient kubernetes, String userName, String password) { if (Strings.isNullOrBlank(userName)) { userName = Systems.getEnvVarOrSystemProperty(JENKINS_GOGS_USER, "gogsadmin"); } if (Strings.isNullOrBlank(password)) { password = Systems.getEnvVarOrSystemProperty(JENKINS_GOGS_PASSWORD, "RedHat$1"); } String namespace = KubernetesHelper.defaultNamespace(); String address; try { address = KubernetesHelper.getServiceURL(kubernetes, ServiceNames.GOGS, namespace, "http", true); if (Strings.isNullOrBlank(address)) { LOG.warn("No Gogs service could be found in kubernetes " + namespace + " on address: " + kubernetes.getMasterUrl()); return null; } } catch (IllegalArgumentException e) { LOG.warn("No Gogs service could be found in kubernetes " + namespace + " on address: " + kubernetes.getMasterUrl()); return null; } LOG.info("Logging into Gogs at " + address + " as user " + userName); return new GitRepoClient(address, userName, password); } }
namespace = kubernetesClient.getNamespace(); if (Strings.isNullOrBlank(namespace)) { namespace = KubernetesHelper.defaultNamespace();