io.fabric8.openshift.client.OpenShiftConfig Java Examples

The following examples show how to use io.fabric8.openshift.client.OpenShiftConfig. 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: OpenShift.java    From enmasse with Apache License 2.0 6 votes vote down vote up
public OpenShift(Environment environment) {
    super(environment, () -> {
        Config config = new ConfigBuilder().withMasterUrl(environment.getApiUrl())
                .withOauthToken(environment.getApiToken())
                .build();
        OkHttpClient httpClient = HttpClientUtils.createHttpClient(config);
        // Workaround https://github.com/square/okhttp/issues/3146
        httpClient = httpClient.newBuilder()
                .protocols(Collections.singletonList(Protocol.HTTP_1_1))
                .connectTimeout(environment.getKubernetesApiConnectTimeout())
                .writeTimeout(environment.getKubernetesApiWriteTimeout())
                .readTimeout(environment.getKubernetesApiReadTimeout())
                .build();
        return new DefaultOpenShiftClient(httpClient, new OpenShiftConfig(config));
    });
}
 
Example #2
Source File: BuildConfigOperationsImpl.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
private void deleteBuilds() {
  if (getName() == null) {
      return;
  }
  String buildConfigLabelValue = getName().substring(0, Math.min(getName().length(), 63));
  BuildList matchingBuilds = new BuildOperationsImpl(client, (OpenShiftConfig) config).inNamespace(namespace).withLabel(BUILD_CONFIG_LABEL, buildConfigLabelValue).list();

  if (matchingBuilds.getItems() != null) {

    for (Build matchingBuild : matchingBuilds.getItems()) {

      if (matchingBuild.getMetadata() != null &&
        matchingBuild.getMetadata().getAnnotations() != null &&
        getName().equals(matchingBuild.getMetadata().getAnnotations().get(BUILD_CONFIG_ANNOTATION))) {

        new BuildOperationsImpl(client, (OpenShiftConfig) config).inNamespace(matchingBuild.getMetadata().getNamespace()).withName(matchingBuild.getMetadata().getName()).delete();

      }

    }

  }
}
 
Example #3
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 #4
Source File: OpenShiftMockServer.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
public NamespacedOpenShiftClient createOpenShiftClient() {
  Config config = new ConfigBuilder()
    .withMasterUrl(url("/"))
    .withNamespace("test")
    .withTrustCerts(true)
    .withTlsVersions(TLS_1_0)
    .build();
  return new DefaultOpenShiftClient(createHttpClientForMockServer(config), new OpenShiftConfig(config));
}
 
Example #5
Source File: OpenShiftMockServer.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
public NamespacedOpenShiftClient createOpenShiftClient() {
  Config config = new ConfigBuilder()
    .withMasterUrl(url("/"))
    .withNamespace("test")
    .withTrustCerts(true)
    .withTlsVersions(TLS_1_0)
    .build();
  return new DefaultOpenShiftClient(createHttpClientForMockServer(config), new OpenShiftConfig(config));
}
 
Example #6
Source File: SubjectAccessReviewOperationImpl.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Override
public URL getRootUrl() {
  // This is an OpenShift resource. If no API Group Name is specified, use /oapi endpoint
  if (Utils.isNullOrEmpty(context.getApiGroupName())) {
    try {
      return new URL(OpenShiftConfig.wrap(getConfig()).getOpenShiftUrl());
    } catch (MalformedURLException e) {
      throw KubernetesClientException.launderThrowable(e);
    }
  } else {
    return super.getRootUrl();
  }
}
 
Example #7
Source File: ProjectRequestsOperationImpl.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Override
public URL getRootUrl() {
  // This is an OpenShift resource. If no API Group Name is specified, use /oapi endpoint
  if (Utils.isNullOrEmpty(context.getApiGroupName())) {
    try {
      return new URL(OpenShiftConfig.wrap(getConfig()).getOpenShiftUrl());
    } catch (MalformedURLException e) {
      throw KubernetesClientException.launderThrowable(e);
    }
  } else {
    return super.getRootUrl();
  }
}
 
Example #8
Source File: OpenShiftOperation.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Override
public URL getRootUrl() {
  // This is an OpenShift resource. If no API Group Name is specified, use /oapi endpoint
  if (Utils.isNullOrEmpty(context.getApiGroupName())) {
    try {
      return new URL(OpenShiftConfig.wrap(getConfig()).getOpenShiftUrl());
    } catch (MalformedURLException e) {
      throw KubernetesClientException.launderThrowable(e);
    }
  } else {
    return super.getRootUrl();
  }
}
 
Example #9
Source File: OpenShiftClientFactory.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
private OpenShiftClient createOC(Config config) {
  OkHttpClient clientHttpClient =
      getHttpClient().newBuilder().authenticator(Authenticator.NONE).build();
  OkHttpClient.Builder builder = clientHttpClient.newBuilder();
  builder.interceptors().clear();
  clientHttpClient =
      builder
          .addInterceptor(
              new OpenShiftOAuthInterceptor(clientHttpClient, OpenShiftConfig.wrap(config)))
          .addInterceptor(new ImpersonatorInterceptor(config))
          .build();

  return new UnclosableOpenShiftClient(clientHttpClient, config);
}
 
Example #10
Source File: OpenShiftClientFactory.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
public UnclosableOpenShiftClient(OkHttpClient httpClient, Config config) {
  super(
      httpClient,
      config instanceof OpenShiftConfig
          ? (OpenShiftConfig) config
          : new OpenShiftConfig(config));
}
 
Example #11
Source File: RoleBindingOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public RoleBindingOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
  this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
 
Example #12
Source File: OpenShiftConfigurationProperties.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public OpenShiftConfig getOpenShiftClientConfiguration() {
    return openShiftClientConfig;
}
 
Example #13
Source File: ProjectRequestHandler.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public ProjectRequest create(OkHttpClient client, Config config, String namespace, ProjectRequest item) {
    return new ProjectRequestsOperationImpl(client, OpenShiftConfig.wrap(config)).create(item);
}
 
Example #14
Source File: OpenShiftOAuthInterceptor.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public OpenShiftOAuthInterceptor(OkHttpClient client, OpenShiftConfig config) {
  this.client = client;
  this.config = config;
}
 
Example #15
Source File: TemplateInstanceOperationContext.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public TemplateInstanceOperationContext withConfig(Config config) {
  return new TemplateInstanceOperationContext(client, OpenShiftConfig.wrap(config), plural, namespace, name, apiGroupName, apiGroupVersion, cascading,item, labels, labelsNot, labelsIn, labelsNotIn, fields, fieldsNot,resourceVersion, reloadingFromServer, gracePeriodSeconds, propagationPolicy, watchRetryInitialBackoffMillis, watchRetryBackoffMultiplier, parameters);
}
 
Example #16
Source File: GroupOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public GroupOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
  this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
 
Example #17
Source File: ClusterRoleBindingOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public ClusterRoleBindingOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
  this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
 
Example #18
Source File: SubjectAccessReviewOperationImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public Createable inAnyNamespace() {
  return new SubjectAccessReviewOperationImpl(client, OpenShiftConfig.wrap(getConfig())).self();
}
 
Example #19
Source File: OAuthAccessTokenOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public OAuthAccessTokenOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
  this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
 
Example #20
Source File: SubjectAccessReviewOperationImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public CreateableLocalSubjectAccessReview inNamespace(String namespace) {
  return new SubjectAccessReviewOperationImpl(client, OpenShiftConfig.wrap(getConfig())).local();
}
 
Example #21
Source File: SubjectAccessReviewOperationImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public SubjectAccessReviewOperationImpl(OkHttpClient client, OpenShiftConfig config) {
  this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
 
Example #22
Source File: BuildOperationContext.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public BuildOperationContext withConfig(Config config) {
  return new BuildOperationContext(client, OpenShiftConfig.wrap(config), plural, namespace, name, apiGroupName, apiGroupVersion, cascading,item, labels, labelsNot, labelsIn, labelsNotIn, fields, fieldsNot,resourceVersion, reloadingFromServer, gracePeriodSeconds, propagationPolicy, watchRetryInitialBackoffMillis, watchRetryBackoffMultiplier, in, out, err, inPipe, outPipe, errPipe, tty, terminatedStatus, timestamps, sinceTimestamp, sinceSeconds, tailingLines, prettyOutput, limitBytes, version);
}
 
Example #23
Source File: BuildConfigOperationContext.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public BuildConfigOperationContext withConfig(Config config) {
  return new BuildConfigOperationContext(client, OpenShiftConfig.wrap(config), plural, namespace, name, apiGroupName, apiGroupVersion, cascading,item, labels, labelsNot, labelsIn, labelsNotIn, fields, fieldsNot,resourceVersion, reloadingFromServer, gracePeriodSeconds, propagationPolicy, watchRetryInitialBackoffMillis, watchRetryBackoffMultiplier, secret, triggerType, authorName, authorEmail, committerName, committerEmail, commit, message, asFile, timeout, timeoutUnit);
}
 
Example #24
Source File: TemplateOperationContext.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public TemplateOperationContext withConfig(Config config) {
  return new TemplateOperationContext(client, OpenShiftConfig.wrap(config), plural, namespace, name, apiGroupName, apiGroupVersion, cascading,item, labels, labelsNot, labelsIn, labelsNotIn, fields, fieldsNot,resourceVersion, reloadingFromServer, gracePeriodSeconds, propagationPolicy, watchRetryInitialBackoffMillis, watchRetryBackoffMultiplier, parameters);
}
 
Example #25
Source File: OAuthClientOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public OAuthClientOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
  this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
 
Example #26
Source File: BuildConfigOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public BuildConfigOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
  this(new BuildConfigOperationContext().withOkhttpClient(client).withConfig(config));
}
 
Example #27
Source File: ProjectRequestsOperationImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public ProjectRequestsOperationImpl(OkHttpClient client, OpenShiftConfig config) {
  this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
 
Example #28
Source File: OAuthAuthorizeTokenOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public OAuthAuthorizeTokenOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
  this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
 
Example #29
Source File: BuildOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public BuildOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
  this(new BuildOperationContext().withOkhttpClient(client).withConfig(config));
}
 
Example #30
Source File: RoleOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public RoleOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
  this((new OperationContext()).withOkhttpClient(client).withConfig(config));
}