io.alauda.devops.client.osgi.ManagedAlaudaDevOpsClient Maven / Gradle / Ivy
/**
* Copyright (C) 2018 Alauda
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.alauda.devops.client.osgi;
import io.alauda.kubernetes.api.model.*;
import io.alauda.kubernetes.api.model.extensions.DoneablePodSecurityPolicy;
import io.alauda.kubernetes.api.model.extensions.PodSecurityPolicy;
import io.alauda.kubernetes.api.model.extensions.PodSecurityPolicyList;
import io.alauda.devops.client.AlaudaDevOpsClient;
import io.alauda.devops.client.AlaudaDevOpsConfig;
import io.alauda.devops.client.DefaultAlaudaDevOpsClient;
import io.alauda.devops.client.NamespacedAlaudaDevOpsClient;
import io.alauda.devops.client.dsl.*;
import io.fabric8.openshift.api.model.DoneableSecurityContextConstraints;
import io.fabric8.openshift.api.model.SecurityContextConstraints;
import io.fabric8.openshift.api.model.SecurityContextConstraintsList;
import io.alauda.kubernetes.api.model.apiextensions.CustomResourceDefinition;
import io.alauda.kubernetes.api.model.apiextensions.CustomResourceDefinitionList;
import io.alauda.kubernetes.api.model.apiextensions.DoneableCustomResourceDefinition;
import io.alauda.kubernetes.client.BaseClient;
import io.alauda.kubernetes.client.Config;
import io.alauda.kubernetes.client.RequestConfig;
import io.alauda.kubernetes.client.dsl.AppsAPIGroupDSL;
import io.alauda.kubernetes.client.dsl.AutoscalingAPIGroupDSL;
import io.alauda.kubernetes.client.dsl.KubernetesListMixedOperation;
import io.alauda.kubernetes.client.dsl.MixedOperation;
import io.alauda.kubernetes.client.dsl.NonNamespaceOperation;
import io.alauda.kubernetes.client.dsl.ParameterMixedOperation;
import io.alauda.kubernetes.client.dsl.ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable;
import io.alauda.kubernetes.client.dsl.PodResource;
import io.alauda.kubernetes.client.dsl.Resource;
import io.alauda.kubernetes.client.dsl.RollableScalableResource;
import io.alauda.kubernetes.client.dsl.ExtensionsAPIGroupDSL;
import io.alauda.kubernetes.client.dsl.FunctionCallable;
import io.alauda.kubernetes.client.dsl.LogWatch;
import io.alauda.kubernetes.client.dsl.NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable;
import io.alauda.kubernetes.client.dsl.NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable;
import io.fabric8.openshift.api.model.Build;
import io.fabric8.openshift.api.model.BuildConfig;
import io.fabric8.openshift.api.model.BuildConfigList;
import io.fabric8.openshift.api.model.BuildList;
import io.fabric8.openshift.api.model.ClusterRoleBinding;
import io.fabric8.openshift.api.model.ClusterRoleBindingList;
import io.fabric8.openshift.api.model.DeploymentConfig;
import io.fabric8.openshift.api.model.DeploymentConfigList;
import io.fabric8.openshift.api.model.DoneableBuild;
import io.fabric8.openshift.api.model.DoneableBuildConfig;
import io.fabric8.openshift.api.model.DoneableClusterRoleBinding;
import io.fabric8.openshift.api.model.DoneableDeploymentConfig;
import io.fabric8.openshift.api.model.DoneableGroup;
import io.fabric8.openshift.api.model.DoneableImageStream;
import io.fabric8.openshift.api.model.DoneableImageStreamTag;
import io.fabric8.openshift.api.model.DoneableOAuthAccessToken;
import io.fabric8.openshift.api.model.DoneableOAuthAuthorizeToken;
import io.fabric8.openshift.api.model.DoneableOAuthClient;
import io.fabric8.openshift.api.model.DoneablePolicy;
import io.fabric8.openshift.api.model.DoneablePolicyBinding;
import io.fabric8.openshift.api.model.DoneableProject;
import io.fabric8.openshift.api.model.DoneableRole;
import io.fabric8.openshift.api.model.DoneableRoleBinding;
import io.fabric8.openshift.api.model.DoneableRoute;
import io.fabric8.openshift.api.model.DoneableTemplate;
import io.fabric8.openshift.api.model.DoneableUser;
import io.fabric8.openshift.api.model.Group;
import io.fabric8.openshift.api.model.GroupList;
import io.fabric8.openshift.api.model.ImageStream;
import io.fabric8.openshift.api.model.ImageStreamList;
import io.fabric8.openshift.api.model.ImageStreamTag;
import io.fabric8.openshift.api.model.ImageStreamTagList;
import io.fabric8.openshift.api.model.OAuthAccessToken;
import io.fabric8.openshift.api.model.OAuthAccessTokenList;
import io.fabric8.openshift.api.model.OAuthAuthorizeToken;
import io.fabric8.openshift.api.model.OAuthAuthorizeTokenList;
import io.fabric8.openshift.api.model.OAuthClient;
import io.fabric8.openshift.api.model.OAuthClientList;
import io.fabric8.openshift.api.model.Policy;
import io.fabric8.openshift.api.model.PolicyBinding;
import io.fabric8.openshift.api.model.PolicyBindingList;
import io.fabric8.openshift.api.model.PolicyList;
import io.fabric8.openshift.api.model.Project;
import io.fabric8.openshift.api.model.ProjectList;
import io.fabric8.openshift.api.model.Role;
import io.fabric8.openshift.api.model.RoleBinding;
import io.fabric8.openshift.api.model.RoleBindingList;
import io.fabric8.openshift.api.model.RoleList;
import io.fabric8.openshift.api.model.Route;
import io.fabric8.openshift.api.model.RouteList;
import io.fabric8.openshift.api.model.Template;
import io.fabric8.openshift.api.model.TemplateList;
import io.fabric8.openshift.api.model.User;
import io.fabric8.openshift.api.model.UserList;
import io.alauda.devops.client.AlaudaDevOpsConfigBuilder;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.ConfigurationPolicy;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import java.io.InputStream;
import java.net.URL;
import java.util.Collection;
import java.util.Map;
import static io.alauda.kubernetes.client.Config.KUBERNETES_API_VERSION_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_AUTH_BASIC_PASSWORD_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_AUTH_BASIC_USERNAME_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_CA_CERTIFICATE_DATA_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_CA_CERTIFICATE_FILE_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_CLIENT_CERTIFICATE_DATA_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_CLIENT_CERTIFICATE_FILE_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_CLIENT_KEY_ALGO_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_CLIENT_KEY_DATA_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_CLIENT_KEY_FILE_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_CLIENT_KEY_PASSPHRASE_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_HTTPS_PROXY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_HTTP_PROXY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_MASTER_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_NO_PROXY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_OAUTH_TOKEN_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_REQUEST_TIMEOUT_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_WATCH_RECONNECT_INTERVAL_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_WATCH_RECONNECT_LIMIT_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_WEBSOCKET_PING_INTERVAL_SYSTEM_PROPERTY;
import static io.alauda.kubernetes.client.Config.KUBERNETES_WEBSOCKET_TIMEOUT_SYSTEM_PROPERTY;
@Component(immediate = true, configurationPid = "io.alauda.devops.client", policy = ConfigurationPolicy.OPTIONAL)
@Service({AlaudaDevOpsClient.class, NamespacedAlaudaDevOpsClient.class})
public class ManagedAlaudaDevOpsClient extends BaseClient implements NamespacedAlaudaDevOpsClient {
private DefaultAlaudaDevOpsClient delegate;
@Activate
public void activate(Map properties) {
final AlaudaDevOpsConfigBuilder builder = new AlaudaDevOpsConfigBuilder();
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(KUBERNETES_ALAUDA_URL_SYTEM_PROPERTY)) {
// builder.withOpenShiftUrl((String) properties.get(KUBERNETES_ALAUDA_URL_SYTEM_PROPERTY));
// } else {
// builder.withOpenShiftUrl(URLUtils.join(builder.getMasterUrl(), "oapi", builder.getAlaudaAPIVersion()));
// }
if (properties.containsKey(AlaudaDevOpsConfig.ALAUDA_BUILD_TIMEOUT_SYSTEM_PROPERTY)) {
builder.withBuildTimeout(Integer.parseInt((String) properties.get(AlaudaDevOpsConfig.ALAUDA_BUILD_TIMEOUT_SYSTEM_PROPERTY)));
} else {
builder.withBuildTimeout(AlaudaDevOpsConfig.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 DefaultAlaudaDevOpsClient(builder.build());
}
@Deactivate
public void deactivate() {
delegate.close();
}
@Override
public URL getKubernetesUrl() {
return delegate.getKubernetesUrl();
}
@Override
public MixedOperation> builds() {
return delegate.builds();
}
@Override
public MixedOperation> componentstatuses() {
return delegate.componentstatuses();
}
@Override
public MixedOperation> buildConfigs() {
return delegate.buildConfigs();
}
@Override
public MixedOperation> pipelines() {
return delegate.pipelines();
}
@Override
public MixedOperation> pipelineConfigs() {
return delegate.pipelineConfigs();
}
@Override
public MixedOperation> deploymentConfigs() {
return delegate.deploymentConfigs();
}
@Override
public NonNamespaceOperation> groups() {
return delegate.groups();
}
@Override
public MixedOperation> imageStreams() {
return delegate.imageStreams();
}
@Override
public MixedOperation> imageStreamTags() {
return delegate.imageStreamTags();
}
@Override
public NonNamespaceOperation> oAuthAccessTokens() {
return delegate.oAuthAccessTokens();
}
@Override
public NonNamespaceOperation> oAuthAuthorizeTokens() {
return delegate.oAuthAuthorizeTokens();
}
@Override
public NonNamespaceOperation> oAuthClients() {
return delegate.oAuthClients();
}
@Override
public MixedOperation> policies() {
return delegate.policies();
}
@Override
public MixedOperation> policyBindings() {
return delegate.policyBindings();
}
@Override
public NonNamespaceOperation> projects() {
return delegate.projects();
}
@Override
public NonNamespaceOperation> jenkins() {
return delegate.jenkins();
}
@Override
public MixedOperation> jenkinsBindings() {
return delegate.jenkinsBindings();
}
@Override
public ProjectRequestOperation projectrequests() {
return delegate.projectrequests();
}
@Override
public MixedOperation> roles() {
return delegate.roles();
}
@Override
public MixedOperation> roleBindings() {
return delegate.roleBindings();
}
@Override
public MixedOperation> routes() {
return delegate.routes();
}
@Override
public ParameterMixedOperation> templates() {
return delegate.templates();
}
@Override
public NonNamespaceOperation> users() {
return delegate.users();
}
@Override
public SubjectAccessReviewOperation subjectAccessReviews() {
return delegate.subjectAccessReviews();
}
@Override
public MixedOperation> clusterRoleBindings() {
return delegate.clusterRoleBindings();
}
@Override
public ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable load(InputStream is) {
return delegate.load(is);
}
@Override
public NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable resourceList(KubernetesResourceList is) {
return delegate.resourceList(is);
}
@Override
public NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable resourceList(HasMetadata... items) {
return delegate.resourceList(items);
}
@Override
public NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable resourceList(Collection items) {
return delegate.resourceList(items);
}
@Override
public ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable resourceList(String s) {
return delegate.resourceList(s);
}
@Override
public NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable resource(HasMetadata item) {
return delegate.resource(item);
}
@Override
public NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicable resource(String s) {
return delegate.resource(s);
}
@Override
public MixedOperation> endpoints() {
return delegate.endpoints();
}
@Override
public MixedOperation> events() {
return delegate.events();
}
@Override
public NonNamespaceOperation> namespaces() {
return delegate.namespaces();
}
@Override
public NonNamespaceOperation> nodes() {
return delegate.nodes();
}
@Override
public NonNamespaceOperation> persistentVolumes() {
return delegate.persistentVolumes();
}
@Override
public MixedOperation> persistentVolumeClaims() {
return delegate.persistentVolumeClaims();
}
@Override
public MixedOperation> pods() {
return delegate.pods();
}
@Override
public MixedOperation> replicationControllers() {
return delegate.replicationControllers();
}
@Override
public MixedOperation> resourceQuotas() {
return delegate.resourceQuotas();
}
@Override
public MixedOperation> secrets() {
return delegate.secrets();
}
@Override
public MixedOperation> storageClasses() {
return delegate.storageClasses();
}
public MixedOperation> podSecurityPolicies() {
return delegate.podSecurityPolicies();
}
@Override
public MixedOperation> services() {
return delegate.services();
}
@Override
public MixedOperation> serviceAccounts() {
return delegate.serviceAccounts();
}
@Override
public KubernetesListMixedOperation lists() {
return delegate.lists();
}
@Override
public NonNamespaceOperation> securityContextConstraints() {
return delegate.securityContextConstraints();
}
@Override
public MixedOperation> configMaps() {
return delegate.configMaps();
}
@Override
public MixedOperation> limitRanges() {
return delegate.limitRanges();
}
@Override
public > MixedOperation> customResources(CustomResourceDefinition crd, Class resourceType, Class listClass, Class doneClass) {
return delegate.customResources(crd, resourceType, listClass, doneClass);
}
@Override
public > MixedOperation> customResource(CustomResourceDefinition crd, Class resourceType, Class listClass, Class doneClass) {
return customResources(crd, resourceType, listClass, doneClass);
}
@Override
public NonNamespaceOperation> customResourceDefinitions() {
return delegate.customResourceDefinitions();
}
@Override
public C adapt(Class type) {
return delegate.adapt(type);
}
@Override
public URL getMasterUrl() {
return delegate.getMasterUrl();
}
@Override
public String getApiVersion() {
return delegate.getApiVersion();
}
@Override
public String getNamespace() {
return delegate.getNamespace();
}
@Override
public RootPaths rootPaths() {
return delegate.rootPaths();
}
@Override
public void close() {
delegate.close();
}
@Override
public Config getConfiguration() {
return delegate.getConfiguration();
}
@Override
public ExtensionsAPIGroupDSL extensions() {
return delegate.extensions();
}
@Override
public AppsAPIGroupDSL apps() {
return delegate.apps();
}
@Override
public AutoscalingAPIGroupDSL autoscaling() {
return delegate.autoscaling();
}
@Override
public NamespacedAlaudaDevOpsClient inAnyNamespace() {
return delegate.inAnyNamespace();
}
@Override
public NamespacedAlaudaDevOpsClient inNamespace(String name) {
return delegate.inNamespace(name);
}
@Override
public FunctionCallable withRequestConfig(RequestConfig requestConfig) {
return delegate.withRequestConfig(requestConfig);
}
@Override
public User currentUser() {
return delegate.currentUser();
}
@Override
public boolean supportAlaudaAPIGroup(String apiGroup) {
return delegate.supportAlaudaAPIGroup(apiGroup);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy