Refine search
private String getGitUserName() { String username; String userEnvVar = getConfig(Config.gitUserEnvVar); username = Systems.getEnvVarOrSystemProperty(userEnvVar); if (Strings.isNullOrBlank(username)) { username = "gogsadmin"; } return username; }
/** * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */ @Override public void init(FilterConfig config) throws ServletException { String kubernetesHostAndPort = Systems.getServiceHostAndPort( "KUBERNETES", "172.28.128.4", "8443"); kubernetesTrustCert = Boolean.parseBoolean(Systems.getEnvVarOrSystemProperty("KUBERNETES_TRUST_CERT", "true")); try { kubernetesOsapiUrl = new URL("https://" + kubernetesHostAndPort + KUBERNETES_OSAPI_URL + "/users/"); } catch (MalformedURLException e) { throw new ServletException(e); } }
/** * Returns the service host and port for the given environment variable name. * * @param serviceName the name of the service which is used as a prefix to access the <code>${serviceName}_SERVICE_HOST</code> and <code>${serviceName}_SERVICE_PORT</code> environment variables to find the hos and port * @param defaultHost the default host to use if not injected via an environment variable (e.g. localhost) * @parma defaultPort the default port to use to connect to the service if there is not an environment variable defined */ public static String getServiceHostAndPort(String serviceName, String defaultHost, String defaultPort) { String serviceEnvVarPrefix = getServiceEnvVarPrefix(serviceName); String hostEnvVar = serviceEnvVarPrefix + "_HOST"; String portEnvVar = serviceEnvVarPrefix + "_PORT"; String host = Systems.getEnvVarOrSystemProperty(hostEnvVar, hostEnvVar, defaultHost); String port = Systems.getEnvVarOrSystemProperty(portEnvVar, portEnvVar, defaultPort); String answer = host + ":" + port; LOG.info("Connecting to service " + serviceName + " on " + answer + " from $" + hostEnvVar + " and $" + portEnvVar); return answer; }
public JolokiaClients(KubernetesClient kubernetes) { this.kubernetes = kubernetes; if (Systems.hasEnvVarOrSystemProperty("JOLOKIA_AUTHENTICATION_MODE")) { authenticationMode = AuthenticationMode.valueOf(Systems.getEnvVarOrSystemProperty("JOLOKIA_AUTHENTICATION_MODE")); } }
String envVar = entry.getKey(); String annotation = entry.getValue(); if (Strings.isNotBlank(envVar) && Strings.isNotBlank(annotation)) { String value = Systems.getEnvVarOrSystemProperty(envVar); if (Strings.isNullOrBlank(value)) { value = tryDefaultAnnotationEnvVar(envVar);
/** * Returns true if the build simulator is enabled via the {@link FABRIC8_SIMULATOR_ENABLED} * environment variable or system property being "true" */ public static boolean isEnabled() { String value = Systems.getEnvVarOrSystemProperty(FABRIC8_SIMULATOR_ENABLED, FABRIC8_SIMULATOR_ENABLED, "false"); if (Strings.isNotBlank(value)) { return value.toLowerCase().equals("true"); } else { return false; } }
@Override protected boolean getDefaultOnline() { // If no online mode specified, we are supposed to be online // when running in an Jenkins CD. // TODO: Isn't there a better datum to detect a CD build ? because BUILD_CD is set // also when you do a 'regular' CI job .... return Systems.getEnvVarOrSystemProperty("BUILD_ID") != null; }
/** * If no environments have been configured lets default them from the `FABRIC8_DEFAULT_ENVIRONMENTS` environment variable */ public static void defaultEnvironments(ProjectConfig config, String namespace) { if (config != null) { String buildName = config.getBuildName(); if (Strings.isNotBlank(buildName) && Maps.isNullOrEmpty(config.getEnvironments())) { // lets default the environments from env var String defaultEnvironmentsText = Systems.getEnvVarOrSystemProperty("FABRIC8_DEFAULT_ENVIRONMENTS", "Testing=${namespace}-testing,Staging=${namespace}-staging,Production=${namespace}-prod"); String text = Strings.replaceAllWithoutRegex(defaultEnvironmentsText, "${buildName}", buildName); text = Strings.replaceAllWithoutRegex(text, "${namespace}", namespace); LinkedHashMap<String,String> environments = Maps.parseMap(text); config.setEnvironments(environments); } } }
String envVar = entry.getKey(); String annotation = entry.getValue(); if (Strings.isNotBlank(envVar) && Strings.isNotBlank(annotation)) { String value = Systems.getEnvVarOrSystemProperty(envVar); if (Strings.isNullOrBlank(value)) { value = tryDefaultAnnotationEnvVar(envVar);
protected static void waitUntilWeCanDestroyNamespace(Session session) { final Logger log = session.getLogger(); String confirmDestroy = Systems.getEnvVarOrSystemProperty(Constants.NAMESPACE_CLEANUP_CONFIRM_ENABLED, "false"); if (Objects.equal(confirmDestroy, "true")) { showErrorsBeforePause(session); String timeoutText = Systems.getEnvVarOrSystemProperty(Constants.NAMESPACE_CLEANUP_TIMEOUT, "0"); Long timeout = null; if (Strings.isNotBlank(timeoutText)) { try { timeout = Long.parseLong(timeoutText);
public Session(String id, Logger logger) { this.id = id; this.logger = logger; namespacePrefix = Systems.getEnvVarOrSystemProperty("FABRIC8_NAMESPACE_PREFIX", "itest-"); }
/** * Returns the brokerURL to connect to the Apache ActiveMQ broker using the given Kubernetes service name and an optional parametes string */ public static String getBrokerURL(String serviceName, String parameters) { if (parameters == null) { parameters = ""; } if (Strings.isNullOrBlank(serviceName)) { serviceName = Systems.getEnvVarOrSystemProperty(MQs.SERVICE_NAME_ENV_VAR, MQs.SERVICE_NAME_ENV_VAR, MQs.DEFAULT_SERVICE_NAME); } String serviceEnvVarPrefix = getServiceEnvVarPrefix(serviceName); String hostEnvVar = serviceEnvVarPrefix + "_HOST"; String portEnvVar = serviceEnvVarPrefix + "_PORT"; String host = Systems.getEnvVarOrSystemProperty(hostEnvVar, hostEnvVar, DEFAULT_HOST); String port = Systems.getEnvVarOrSystemProperty(portEnvVar, portEnvVar, DEFAULT_PORT); LOG.info("Connecting to ActiveMQ broker on " + host + ":" + port + " from $" + hostEnvVar + " and $" + portEnvVar + ". To use a different broker service please specify $" + SERVICE_NAME_ENV_VAR + "=someBrokerServiceName where 'someBrokerServiceName' is a defined ActiveMQ broker service in Kubernetes"); String answer = "failover:(tcp://" + host + ":" + port + ")" + parameters; LOG.info("BrokerURL is: {}", answer); return answer; }
protected static void waitUntilWeCanDestroyNamespace(Session session) { final Logger log = session.getLogger(); String confirmDestroy = Systems.getEnvVarOrSystemProperty(Constants.FABRIC8_NAMESPACE_CONFIRM_DESTROY, "false"); if (Objects.equal(confirmDestroy, "true")) { showErrorsBeforePause(session); String timeoutText = Systems.getEnvVarOrSystemProperty(Constants.FABRIC8_NAMESPACE_DESTROY_TIMEOUT, "0"); Long timeout = null; if (Strings.isNotBlank(timeoutText)) { try { timeout = Long.parseLong(timeoutText);
public static String getEnvVarOrSystemProperty(String envVarName, String defaultValue) { return getEnvVarOrSystemProperty(envVarName,envVarName,defaultValue); }
/** * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */ @Override public void init(FilterConfig config) throws ServletException { String kubernetesHostAndPort = Systems.getServiceHostAndPort( "KUBERNETES", "172.28.128.4", "8443"); kubernetesTrustCert = Boolean.parseBoolean(Systems.getEnvVarOrSystemProperty("KUBERNETES_TRUST_CERT", "true")); try { kubernetesOsapiUrl = new URL("https://" + kubernetesHostAndPort + KUBERNETES_OSAPI_URL + "/users/"); } catch (MalformedURLException e) { throw new ServletException(e); } }
/** * Returns the service host and port for the given environment variable name. * * @param serviceNameEnvVar the name of the environment variable used to configure the name of the service to connect to * @param defaultServiceName the default name of the service to use if the environment variable is not set * @param defaultHost the default host to use if not injected via an environment variable (e.g. localhost) * @parma defaultPort the default port to use to connect to the service if there is not an environment variable defined */ public static String getServiceHostAndPort(String serviceNameEnvVar, String defaultServiceName, String defaultHost, String defaultPort) { String serviceName = Systems.getEnvVarOrSystemProperty(serviceNameEnvVar, serviceNameEnvVar, defaultServiceName); String serviceEnvVarPrefix = getServiceEnvVarPrefix(serviceName); String hostEnvVar = serviceEnvVarPrefix + "_HOST"; String portEnvVar = serviceEnvVarPrefix + "_PORT"; String host = Systems.getEnvVarOrSystemProperty(hostEnvVar, hostEnvVar, defaultHost); String port = Systems.getEnvVarOrSystemProperty(portEnvVar, portEnvVar, defaultPort); String answer = host + ":" + port; LOG.info("Connecting to service " + serviceName + " on " + answer + " from $" + hostEnvVar + " and $" + portEnvVar + ". To use a different service address please specify $" + serviceNameEnvVar + "=someServiceName where 'someServiceName' is the id of a service in Kubernetes"); return answer; }
/** * Returns the brokerURL to connect to the Apache ActiveMQ broker using the given Kubernetes service name and an optional parametes string */ public static String getBrokerURL(String serviceName, String parameters) { if (parameters == null) { parameters = ""; } if (Strings.isNullOrBlank(serviceName)) { serviceName = Systems.getEnvVarOrSystemProperty(MQs.SERVICE_NAME_ENV_VAR, MQs.SERVICE_NAME_ENV_VAR, MQs.DEFAULT_SERVICE_NAME); } String serviceEnvVarPrefix = getServiceEnvVarPrefix(serviceName); String hostEnvVar = serviceEnvVarPrefix + "_HOST"; String portEnvVar = serviceEnvVarPrefix + "_PORT"; String host = Systems.getEnvVarOrSystemProperty(hostEnvVar, hostEnvVar, DEFAULT_HOST); String port = Systems.getEnvVarOrSystemProperty(portEnvVar, portEnvVar, DEFAULT_PORT); LOG.info("Connecting to ActiveMQ broker on " + host + ":" + port + " from $" + hostEnvVar + " and $" + portEnvVar + ". To use a different broker service please specify $" + SERVICE_NAME_ENV_VAR + "=someBrokerServiceName where 'someBrokerServiceName' is a defined ActiveMQ broker service in Kubernetes"); String answer = "failover:(tcp://" + host + ":" + port + ")" + parameters; LOG.info("BrokerURL is: {}", answer); return answer; }
public static Server startServer(String appName, Function<ServletContextHandler, Void> contextCallback, String defaultPort) throws Exception { String port = Systems.getEnvVarOrSystemProperty("HTTP_PORT", "HTTP_PORT", defaultPort); Integer num = Integer.parseInt(port); String service = Systems.getEnvVarOrSystemProperty("WEB_CONTEXT_PATH", "WEB_CONTEXT_PATH", ""); context.addEventListener(new BeanManagerResourceBindingListener()); String servletPath = "/*"; if (Strings.isNotBlank(service)) { servletPath = servletContextPath + "/*";
private static String getStringProperty(String name, Map<String, String> map, String defaultValue) { if (map.containsKey(name)) { return map.get(name); } else { return Systems.getEnvVarOrSystemProperty(name, defaultValue); } }
/** * Constructor. * @param vertx * @param httpGateway */ public EngineFactory(final Vertx vertx, final HttpGateway httpGateway) { this.vertx = vertx; this.httpGateway = httpGateway; String host = null; try { InetAddress initAddress = InetAddress.getByName("ELASTICSEARCH"); host = initAddress.getCanonicalHostName(); } catch (UnknownHostException e) { System.out.println("INFO: Could not resolve DNS for ELASTICSEARCH, trying ENV settings next."); } String hostAndPort = Systems.getServiceHostAndPort("ELASTICSEARCH", "localhost", "9200"); String[] hp = hostAndPort.split(":"); if (host == null) { System.out.println("ELASTICSEARCH host:port is set to " + hostAndPort + " using ENV settings."); host = hp[0]; } String protocol = Systems.getEnvVarOrSystemProperty("ELASTICSEARCH_PROTOCOL", "http"); System.out.println("*** Connecting to Elastic at service " + protocol + "://" + host + ":" + hp[1]); esConfig.put("client.type", "jest"); esConfig.put("client.host", host); esConfig.put("client.port", hp[1]); esConfig.put("client.protocol", protocol); esConfig.put("client.cluster-name", "elasticsearch"); }