Java源码示例:io.fabric8.openshift.client.OpenShiftConfig
示例1
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));
});
}
示例2
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();
}
}
}
}
示例3
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);
}
示例4
public UnclosableOpenShiftClient(OkHttpClient httpClient, Config config) {
super(
httpClient,
config instanceof OpenShiftConfig
? (OpenShiftConfig) config
: new OpenShiftConfig(config));
}
示例5
@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();
}
}
示例6
@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();
}
}
示例7
@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();
}
}
示例8
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));
}
示例9
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));
}
示例10
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);
}
示例11
public OpenShiftConfig getOpenShiftClientConfiguration() {
return openShiftClientConfig;
}
示例12
public OAuthAccessTokenOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
示例13
public BuildConfigOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this(new BuildConfigOperationContext().withOkhttpClient(client).withConfig(config));
}
示例14
public UserOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
示例15
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);
}
示例16
public ProjectOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
示例17
public SecurityContextConstraintsOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
示例18
public TemplateOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this(new TemplateOperationContext().withOkhttpClient(client).withConfig(config));
}
示例19
@Override
public OpenShiftConfig getConfig() {
return OpenShiftConfig.wrap(super.getConfig());
}
示例20
protected Class<? extends Config> getConfigType() {
return OpenShiftConfig.class;
}
示例21
public RoleOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this((new OperationContext()).withOkhttpClient(client).withConfig(config));
}
示例22
public BuildOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this(new BuildOperationContext().withOkhttpClient(client).withConfig(config));
}
示例23
public OAuthAuthorizeTokenOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
示例24
public ProjectRequestsOperationImpl(OkHttpClient client, OpenShiftConfig config) {
this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
示例25
public OAuthClientOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
示例26
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);
}
示例27
public RoleBindingOperationsImpl(OkHttpClient client, OpenShiftConfig config) {
this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
示例28
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);
}
示例29
public SubjectAccessReviewOperationImpl(OkHttpClient client, OpenShiftConfig config) {
this(new OperationContext().withOkhttpClient(client).withConfig(config));
}
示例30
@Override
public CreateableLocalSubjectAccessReview inNamespace(String namespace) {
return new SubjectAccessReviewOperationImpl(client, OpenShiftConfig.wrap(getConfig())).local();
}