Skip to content

Commit

Permalink
Fix fabric8io#2287: Add support for V1 and V1Beta1 CustomResourceDefi…
Browse files Browse the repository at this point in the history
…nition

Introduced a new api entrypoint called `client.apiextensions()` which would
route to `apiextensions/v1` and `apiextensions/v1beta1` CustomResourceDefinitions
  • Loading branch information
rohanKanojia committed Jul 17, 2020
1 parent c87dd30 commit c28bcc2
Show file tree
Hide file tree
Showing 56 changed files with 3,681 additions and 450 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,8 +6,11 @@
#### Improvements

#### Dependency Upgrade
* Fix #2355: bump jandex from 2.1.3.Final to 2.2.0.Final
* Fix #2353: bump workflow action-setup-* versions + kubernetes to 1.18.6

#### New Features
* Fix #2287: Add support for V1 and V1Beta1 CustomResourceDefinition

### 4.10.3 (2020-07-14)
#### Bugs
Expand Down
@@ -0,0 +1,40 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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.fabric8.kubernetes.client;

import io.fabric8.kubernetes.client.dsl.ApiextensionsAPIGroupDSL;
import okhttp3.OkHttpClient;

public class ApiextensionsAPIGroupClient extends BaseClient implements ApiextensionsAPIGroupDSL {
public ApiextensionsAPIGroupClient() {
super();
}

public ApiextensionsAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}


@Override
public V1ApiextensionAPIGroupDSL v1() {
return adapt(V1ApiextensionsAPIGroupClient.class);
}

@Override
public V1beta1ApiextensionAPIGroupDSL v1beta1() {
return adapt(V1beta1ApiextensionsAPIGroupClient.class);
}
}
@@ -0,0 +1,37 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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.fabric8.kubernetes.client;

import okhttp3.OkHttpClient;

public class ApiextensionsAPIGroupExtensionAdapter extends APIGroupExtensionAdapter<ApiextensionsAPIGroupClient> {

@Override
protected String getAPIGroupName() {
return "apiextension";
}

@Override
public Class<ApiextensionsAPIGroupClient> getExtensionType() {
return ApiextensionsAPIGroupClient.class;
}

@Override
protected ApiextensionsAPIGroupClient newInstance(Client client) {
return new ApiextensionsAPIGroupClient(client.adapt(OkHttpClient.class), client.getConfiguration());
}

}
Expand Up @@ -25,9 +25,9 @@
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.KubernetesListBuilder;
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinitionList;
import io.fabric8.kubernetes.api.model.apiextensions.DoneableCustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionList;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.DoneableCustomResourceDefinition;
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapList;
import io.fabric8.kubernetes.api.model.DoneableConfigMap;
Expand Down Expand Up @@ -288,6 +288,11 @@ public NonNamespaceOperation<CustomResourceDefinition, CustomResourceDefinitionL
return new CustomResourceDefinitionOperationsImpl(httpClient, getConfiguration());
}

@Override
public ApiextensionsAPIGroupDSL apiextensions() {
return adapt(ApiextensionsAPIGroupClient.class);
}

@Override
public <T extends HasMetadata, L extends KubernetesResourceList<T>, D extends Doneable<T>> MixedOperation<T, L, D, Resource<T, D>> customResources(CustomResourceDefinitionContext crdContext, Class<T> resourceType, Class<L> listClass, Class<D> doneClass) {
return new CustomResourceOperationsImpl<>(new CustomResourceOperationContext().withOkhttpClient(httpClient).withConfig(getConfiguration())
Expand Down
Expand Up @@ -73,9 +73,9 @@
import io.fabric8.kubernetes.api.model.coordination.v1.Lease;
import io.fabric8.kubernetes.api.model.coordination.v1.LeaseList;
import io.fabric8.kubernetes.client.dsl.*;
import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinitionList;
import io.fabric8.kubernetes.api.model.apiextensions.DoneableCustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionList;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.DoneableCustomResourceDefinition;
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
import io.fabric8.kubernetes.client.dsl.internal.RawCustomResourceOperationsImpl;
import io.fabric8.kubernetes.client.extended.leaderelection.LeaderElectorBuilder;
Expand All @@ -98,6 +98,14 @@ public interface KubernetesClient extends Client {
*/
NonNamespaceOperation<CustomResourceDefinition, CustomResourceDefinitionList, DoneableCustomResourceDefinition, Resource<CustomResourceDefinition, DoneableCustomResourceDefinition>> customResourceDefinitions();

/**
* API entrypoint for apiextensions resources. Currently support both
* v1 and v1beta1
*
* @return ApiextensionsAPIGroupDSL which routes to v1 or v1beta1
*/
ApiextensionsAPIGroupDSL apiextensions();

/**
* Typed API for managing CustomResources. You would need to provide POJOs for
* CustomResource into this and with it you would be able to instantiate a client
Expand Down
@@ -0,0 +1,26 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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.fabric8.kubernetes.client;

import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionList;
import io.fabric8.kubernetes.api.model.apiextensions.v1.DoneableCustomResourceDefinition;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;

public interface V1ApiextensionAPIGroupDSL extends Client {
MixedOperation<CustomResourceDefinition, CustomResourceDefinitionList, DoneableCustomResourceDefinition, Resource<CustomResourceDefinition, DoneableCustomResourceDefinition>> customResourceDefinitions();
}
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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.fabric8.kubernetes.client;

import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionList;
import io.fabric8.kubernetes.api.model.apiextensions.v1.DoneableCustomResourceDefinition;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.internal.apiextensions.v1.CustomResourceDefinitionOperationsImpl;
import okhttp3.OkHttpClient;

public class V1ApiextensionsAPIGroupClient extends BaseClient implements V1ApiextensionAPIGroupDSL {
public V1ApiextensionsAPIGroupClient() {
super();
}

public V1ApiextensionsAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}

public MixedOperation<CustomResourceDefinition, CustomResourceDefinitionList, DoneableCustomResourceDefinition, Resource<CustomResourceDefinition, DoneableCustomResourceDefinition>> customResourceDefinitions() {
return new CustomResourceDefinitionOperationsImpl(httpClient, getConfiguration());
}
}
@@ -0,0 +1,35 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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.fabric8.kubernetes.client;

import okhttp3.OkHttpClient;

public class V1ApiextensionsAPIGroupExtensionAdapter extends APIGroupExtensionAdapter<V1ApiextensionsAPIGroupClient> {
@Override
protected String getAPIGroupName() {
return "apiextensions/v1";
}

@Override
public Class<V1ApiextensionsAPIGroupClient> getExtensionType() {
return V1ApiextensionsAPIGroupClient.class;
}

@Override
protected V1ApiextensionsAPIGroupClient newInstance(Client client) {
return new V1ApiextensionsAPIGroupClient(client.adapt(OkHttpClient.class), client.getConfiguration());
}
}
@@ -0,0 +1,26 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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.fabric8.kubernetes.client;

import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionList;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.DoneableCustomResourceDefinition;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;

public interface V1beta1ApiextensionAPIGroupDSL extends Client {
MixedOperation<CustomResourceDefinition, CustomResourceDefinitionList, DoneableCustomResourceDefinition, Resource<CustomResourceDefinition, DoneableCustomResourceDefinition>> customResourceDefinitions();
}
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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.fabric8.kubernetes.client;

import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionList;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.DoneableCustomResourceDefinition;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.internal.apiextensions.v1beta1.CustomResourceDefinitionOperationsImpl;
import okhttp3.OkHttpClient;

public class V1beta1ApiextensionsAPIGroupClient extends BaseClient implements V1beta1ApiextensionAPIGroupDSL {
public V1beta1ApiextensionsAPIGroupClient() {
super();
}

public V1beta1ApiextensionsAPIGroupClient(OkHttpClient httpClient, final Config config) {
super(httpClient, config);
}

public MixedOperation<CustomResourceDefinition, CustomResourceDefinitionList, DoneableCustomResourceDefinition, Resource<CustomResourceDefinition, DoneableCustomResourceDefinition>> customResourceDefinitions() {
return new CustomResourceDefinitionOperationsImpl(httpClient, getConfiguration());
}
}
@@ -0,0 +1,35 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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.fabric8.kubernetes.client;

import okhttp3.OkHttpClient;

public class V1beta1ApiextensionsAPIGroupExtensionAdapter extends APIGroupExtensionAdapter<V1beta1ApiextensionsAPIGroupClient> {
@Override
protected String getAPIGroupName() {
return "apiextensions/v1beta1";
}

@Override
public Class<V1beta1ApiextensionsAPIGroupClient> getExtensionType() {
return V1beta1ApiextensionsAPIGroupClient.class;
}

@Override
protected V1beta1ApiextensionsAPIGroupClient newInstance(Client client) {
return new V1beta1ApiextensionsAPIGroupClient(client.adapt(OkHttpClient.class), client.getConfiguration());
}
}
@@ -0,0 +1,25 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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.fabric8.kubernetes.client.dsl;

import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.client.V1ApiextensionAPIGroupDSL;
import io.fabric8.kubernetes.client.V1beta1ApiextensionAPIGroupDSL;

public interface ApiextensionsAPIGroupDSL extends Client {
V1ApiextensionAPIGroupDSL v1();
V1beta1ApiextensionAPIGroupDSL v1beta1();
}
Expand Up @@ -15,7 +15,7 @@
*/
package io.fabric8.kubernetes.client.dsl.base;

import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;

public class CustomResourceDefinitionContext {
private String name;
Expand Down
Expand Up @@ -18,7 +18,7 @@
import java.util.Map;

import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
Expand Down

0 comments on commit c28bcc2

Please sign in to comment.