builder.withOauthToken(args[1]);
builder.withOauthToken((String) properties.get(KUBERNETES_OAUTH_TOKEN_SYSTEM_PROPERTY));
public KubeScannerBuilder withKubeConfigUser(String user) { kubeConfig.path("users").forEach(it -> { if (it.path("name").asText().equals(user)) { String authToken = it.path("user").path("auth-provider").path("config").path("access-token").asText(); withConfig(c -> { logger.info("setting token"); c.withOauthToken(authToken); }); } }); return this; }
String podMountedSAToken = APIFileUtils.readFileContentAsText( implParameters.get(POD_MOUNTED_SA_TOKEN_FILE_PATH)); return configBuilder.withOauthToken(podMountedSAToken).build(); } else { log.info("Using externally stored service account token"); return configBuilder.withOauthToken(resolveToken("encrypted" + externalSATokenFileName)).build();
String podMountedSAToken = APIFileUtils.readFileContentAsText( implParameters.get(POD_MOUNTED_SA_TOKEN_FILE_PATH)); return configBuilder.withOauthToken(podMountedSAToken).build(); } else { log.info("Using externally stored service account token"); return configBuilder.withOauthToken(resolveToken("encrypted" + externalSATokenFileName)).build();
/** * Build configurations for Openshift client * * @throws ContainerBasedGatewayException if failed to configure Openshift client */ private Config buildConfig() throws ContainerBasedGatewayException { System.setProperty(TRY_KUBE_CONFIG, "false"); System.setProperty(TRY_SERVICE_ACCOUNT, "true"); ConfigBuilder configBuilder; if (masterURL != null) { configBuilder = new ConfigBuilder().withMasterUrl(masterURL); } else { throw new ContainerBasedGatewayException("Kubernetes Master URL is not provided!", ExceptionCodes .ERROR_INITIALIZING_DEDICATED_CONTAINER_BASED_GATEWAY); } if (!StringUtils.isEmpty(saTokenFileName)) { configBuilder.withOauthToken(resolveToken("encrypted" + saTokenFileName)); } return configBuilder.build(); }
/** * Build configurations for Openshift client * * @throws ContainerBasedGatewayException if failed to configure Openshift client */ private Config buildConfig() throws ContainerBasedGatewayException { System.setProperty(TRY_KUBE_CONFIG, "false"); System.setProperty(TRY_SERVICE_ACCOUNT, "true"); ConfigBuilder configBuilder; if (masterURL != null) { configBuilder = new ConfigBuilder().withMasterUrl(masterURL); } else { throw new ContainerBasedGatewayException("Kubernetes Master URL is not provided!", ExceptionCodes .ERROR_INITIALIZING_DEDICATED_CONTAINER_BASED_GATEWAY); } if (!StringUtils.isEmpty(saTokenFileName)) { configBuilder.withOauthToken(resolveToken("encrypted" + saTokenFileName)); } return configBuilder.build(); }
private KubernetesClient createKubernetesClient(Environment environment) { try { Config config = new ConfigBuilder() .withMasterUrl(environment.getKubernetesMaster()) .withOauthToken(environment.getKubernetesToken()) .build(); return new DefaultKubernetesClient(config); } catch (Exception e) { logger.error("Could not create kubernetes client for environment {}", environment.getId(), e); throw new RuntimeException(); } }
builder.withOauthToken((String) properties.get(KUBERNETES_OAUTH_TOKEN_SYSTEM_PROPERTY));
.withApiVersion("v1") .withNamespace("testns") .withOauthToken("token") .withUsername("user") .withPassword("pass")
public OpenShift(Environment environment, String globalNamespace) { super(environment, new DefaultOpenShiftClient(new ConfigBuilder().withMasterUrl(environment.getApiUrl()) .withOauthToken(environment.getApiToken()) .build()), globalNamespace); }
builder.withOauthToken(token); } else if (credentials instanceof TokenProducer) { final String token = ((TokenProducer) credentials).getToken(serviceAddress, caCertData, skipTlsVerify); builder.withOauthToken(token); } else if (credentials instanceof UsernamePasswordCredentials) { UsernamePasswordCredentials usernamePassword = (UsernamePasswordCredentials) credentials;
if (auth.getToken() == null) { if (auth.getAuthProvider() != null) { configBuilder.withOauthToken(auth.getAuthProvider().getConfig().get("id-token")); configBuilder.withOauthToken(auth.getToken()); if (Strings.isNonBlank(token)) configBuilder.withOauthToken(token);
@Override public KubernetesClient createKubernetesClient(KubernetesCloudParams kubeCloudParams) { ConfigBuilder builder = new ConfigBuilder().withMasterUrl(kubeCloudParams.getEndpointUrl() ); Authentication authData = kubeCloudParams.getAuthData(); if (authData != null) { if (authData instanceof TokenAuthentication) { builder.withOauthToken( ((TokenAuthentication)authData).getAuthToken() ); } else if (authData instanceof UserAndPasswordAuthentication) { builder.withUsername( ((UserAndPasswordAuthentication) authData).getUser() ); builder.withPassword( ((UserAndPasswordAuthentication) authData).getPassword() ); } } if (kubeCloudParams.isDisableCertCheck() ) { builder.withTrustCerts(true); } else if (StringUtils.isNotEmpty(kubeCloudParams.getServerCert() )) { builder.withCaCertData(kubeCloudParams.getServerCert() ); } if (LOGGER.isLoggable(Level.CONFIG) ) { LOGGER.config("Creating Kubernetes client: " + kubeCloudParams.getEndpointUrl() ); } return new DefaultKubernetesClient(builder.build() ); }
builder.withOauthToken(configuration.getOauthToken());
builder.withPassword(configuration.getPassword()); } else { builder.withOauthToken(configuration.getOauthToken());
.withOauthToken(token) .withMasterUrl(master) .withTrustCerts(true)