io.fabric8.openshift.client.OpenShiftConfigBuilder Java Examples

The following examples show how to use io.fabric8.openshift.client.OpenShiftConfigBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenShiftConfigurationProperties.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public void setOpenShiftHost(String openShiftHost) {
    this.masterUrlHost = openShiftHost;

    final String current = openShiftClientConfig.getMasterUrl();
    if (!Objects.equals(current, openShiftHost)) {
        openShiftClientConfig = new OpenShiftConfigBuilder().withMasterUrl(masterUrlHost).build();
    }
}
 
Example #2
Source File: OpenShiftClientFactory.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Config buildDefaultConfig(String masterUrl, Boolean doTrustCerts) {
  OpenShiftConfigBuilder configBuilder = new OpenShiftConfigBuilder();
  if (!isNullOrEmpty(masterUrl)) {
    configBuilder.withMasterUrl(masterUrl);
  }

  if (doTrustCerts != null) {
    configBuilder.withTrustCerts(doTrustCerts);
  }

  return configBuilder.build();
}
 
Example #3
Source File: TemplateTest.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldLoadTemplateWithNumberParameters() throws Exception {
  OpenShiftClient client = new DefaultOpenShiftClient(new OpenShiftConfigBuilder().build());
  Map<String, String> map = new HashMap<>();
  map.put("PORT", "8080");
  KubernetesList list = client.templates().withParameters(map).load(getClass().getResourceAsStream("/template-with-number-params.yml")).processLocally(map);
  assertListIsServiceWithPort8080(list);
}
 
Example #4
Source File: OpenShiftMockServer.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
public NamespacedOpenShiftClient createOpenShiftClient() {
  OpenShiftConfig config = new OpenShiftConfigBuilder()
    .withMasterUrl(url("/"))
    .withNamespace("test")
    .withTrustCerts(true)
    .withTlsVersions(TLS_1_0)
    .withDisableApiGroupCheck(disableApiGroupCheck)
    .build();
  return new DefaultOpenShiftClient(createHttpClientForMockServer(config), config);
}
 
Example #5
Source File: LoadAsTemplateTest.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
private static DefaultOpenShiftClient createOpenShiftClientWithNoServer() {
  return new DefaultOpenShiftClient(new OpenShiftConfigBuilder().build());
}
 
Example #6
Source File: ManagedOpenShiftClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Activate
public void activate(Map<String, Object> properties) {
  final OpenShiftConfigBuilder builder = new OpenShiftConfigBuilder();

  if (properties.containsKey(KUBERNETES_MASTER_SYSTEM_PROPERTY)) {
    builder.withMasterUrl((String) properties.get(KUBERNETES_MASTER_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_API_VERSION_SYSTEM_PROPERTY)) {
    builder.withApiVersion((String) properties.get(KUBERNETES_API_VERSION_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_NAMESPACE_SYSTEM_PROPERTY)) {
    builder.withNamespace((String) properties.get(KUBERNETES_NAMESPACE_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CA_CERTIFICATE_FILE_SYSTEM_PROPERTY)) {
    builder.withCaCertFile((String) properties.get(KUBERNETES_CA_CERTIFICATE_FILE_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CA_CERTIFICATE_DATA_SYSTEM_PROPERTY)) {
    builder.withCaCertData((String) properties.get(KUBERNETES_CA_CERTIFICATE_DATA_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_CERTIFICATE_FILE_SYSTEM_PROPERTY)) {
    builder.withClientCertFile((String) properties.get(KUBERNETES_CLIENT_CERTIFICATE_FILE_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_CERTIFICATE_DATA_SYSTEM_PROPERTY)) {
    builder.withClientCertData((String) properties.get(KUBERNETES_CLIENT_CERTIFICATE_DATA_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_KEY_FILE_SYSTEM_PROPERTY)) {
    builder.withClientKeyFile((String) properties.get(KUBERNETES_CLIENT_KEY_FILE_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_KEY_DATA_SYSTEM_PROPERTY)) {
    builder.withClientKeyData((String) properties.get(KUBERNETES_CLIENT_KEY_DATA_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_KEY_ALGO_SYSTEM_PROPERTY)) {
    builder.withClientKeyAlgo((String) properties.get(KUBERNETES_CLIENT_KEY_ALGO_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_CLIENT_KEY_PASSPHRASE_SYSTEM_PROPERTY)) {
    builder.withClientKeyPassphrase((String) properties.get(KUBERNETES_CLIENT_KEY_PASSPHRASE_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_AUTH_BASIC_USERNAME_SYSTEM_PROPERTY)) {
    builder.withUsername((String) properties.get(KUBERNETES_AUTH_BASIC_USERNAME_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_AUTH_BASIC_PASSWORD_SYSTEM_PROPERTY)) {
    builder.withPassword((String) properties.get(KUBERNETES_AUTH_BASIC_PASSWORD_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_OAUTH_TOKEN_SYSTEM_PROPERTY)) {
    builder.withOauthToken((String) properties.get(KUBERNETES_OAUTH_TOKEN_SYSTEM_PROPERTY));
  }
  if (properties.containsKey(KUBERNETES_WATCH_RECONNECT_INTERVAL_SYSTEM_PROPERTY)) {
    builder.withWatchReconnectInterval(Integer.parseInt((String) properties.get(KUBERNETES_WATCH_RECONNECT_INTERVAL_SYSTEM_PROPERTY)));
  }
  if (properties.containsKey(KUBERNETES_WATCH_RECONNECT_LIMIT_SYSTEM_PROPERTY)) {
    builder.withWatchReconnectLimit(Integer.parseInt((String) properties.get(KUBERNETES_WATCH_RECONNECT_LIMIT_SYSTEM_PROPERTY)));
  }
  if (properties.containsKey(KUBERNETES_REQUEST_TIMEOUT_SYSTEM_PROPERTY)) {
    builder.withRequestTimeout(Integer.parseInt((String) properties.get(KUBERNETES_REQUEST_TIMEOUT_SYSTEM_PROPERTY)));
  }
  if (properties.containsKey(KUBERNETES_HTTP_PROXY)) {
    builder.withHttpProxy((String) properties.get(KUBERNETES_HTTP_PROXY));
  }
  if (properties.containsKey(KUBERNETES_HTTPS_PROXY)) {
    builder.withHttpsProxy((String) properties.get(KUBERNETES_HTTPS_PROXY));
  }
  if (properties.containsKey(KUBERNETES_NO_PROXY)) {
    String noProxyProperty = (String) properties.get(KUBERNETES_NO_PROXY);
    builder.withNoProxy(noProxyProperty.split(","));
  }
  if (properties.containsKey(OPENSHIFT_URL_SYSTEM_PROPERTY)) {
    builder.withOpenShiftUrl((String) properties.get(OPENSHIFT_URL_SYSTEM_PROPERTY));
  } else {
    builder.withOpenShiftUrl(URLUtils.join(builder.getMasterUrl(), "oapi", builder.getOapiVersion()));
  }
  if (properties.containsKey(OPENSHIFT_BUILD_TIMEOUT_SYSTEM_PROPERTY)) {
    builder.withBuildTimeout(Integer.parseInt((String) properties.get(OPENSHIFT_BUILD_TIMEOUT_SYSTEM_PROPERTY)));
  } else {
    builder.withBuildTimeout(DEFAULT_BUILD_TIMEOUT);
  }
  if (properties.containsKey(KUBERNETES_WEBSOCKET_TIMEOUT_SYSTEM_PROPERTY)) {
    builder.withWebsocketTimeout(Long.parseLong((String) properties.get(KUBERNETES_WEBSOCKET_TIMEOUT_SYSTEM_PROPERTY)));
  }
  if (properties.containsKey(KUBERNETES_WEBSOCKET_PING_INTERVAL_SYSTEM_PROPERTY)) {
    builder.withWebsocketPingInterval(Long.parseLong((String) properties.get(KUBERNETES_WEBSOCKET_PING_INTERVAL_SYSTEM_PROPERTY)));
  }

  delegate = new DefaultOpenShiftClient(builder.build());
}