diff --git a/CHANGELOG.md b/CHANGELOG.md index e5229d7d841..da5ced0b4f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ #### Improvements * Fix #2717: Remove edit() methods from RawCustomResourceOperationsImpl taking InputStream arguments +* Fix #2694: Remove deprecated methods from KubernetesClient DSL #### Dependency Upgrade * update Tekton Triggers model to v0.11.1 @@ -16,7 +17,13 @@ * Fix #2702 : Add support for discovery.k8s.io/v1beta1 EndpointSlice in KubernetesClient DSL _**Note**_: Breaking changes in the API +##### DSL Changes: - `client.settings()` DSL has been removed since PodPreset v1alpha1 API is no longer present in Kubernetes 1.20.x +- `client.customResourceDefinitions()` has been removed. Use `client.apiextensions().v1beta1().customResourceDefinitions()` instead +- `client.events()` has been removed. Use `client.v1().events()` instead +- `client.customResources(...)` methods having `CustomResourceDefinitionContext`/`CustomResourceDefinition` as argument for typed CustomResource API have been removed. Use the new annotations `@Version`, `@Group` introduced in 5.x versions of client. + +##### Model Changes: - Classes in `io.fabric8.kubernetes.api.model.scheduling` have been moved to `io.fabric8.kubernetes.api.model.scheduling.v1` and `io.fabric8.kubernetes.api.model.scheduling.v1beta1` - Classes in `io.fabric8.kubernetes.api.model.admission` have been moved to `io.fabric8.kubernetes.api.model.admission.v1` and `io.fabric8.kubernetes.api.model.admission.v1beta1` - Classes in `io.fabric8.kubernetes.api.model.certificates` have been moved to `io.fabric8.kubernetes.api.model.certificates.v1` and `io.fabric8.kubernetes.api.model.certificates.v1beta1` diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AutoAdaptableKubernetesClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AutoAdaptableKubernetesClient.java index b83252e5929..18d37933c08 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AutoAdaptableKubernetesClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/AutoAdaptableKubernetesClient.java @@ -21,8 +21,6 @@ import io.fabric8.kubernetes.api.model.ConfigMapList; import io.fabric8.kubernetes.api.model.Endpoints; import io.fabric8.kubernetes.api.model.EndpointsList; -import io.fabric8.kubernetes.api.model.Event; -import io.fabric8.kubernetes.api.model.EventList; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesResourceList; import io.fabric8.kubernetes.api.model.LimitRange; @@ -182,11 +180,6 @@ public MixedOperation> endpoints() return delegate.endpoints(); } - @Override - public MixedOperation> events() { - return delegate.events(); - } - @Override public NonNamespaceOperation> namespaces() { return delegate.namespaces(); diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/DefaultKubernetesClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/DefaultKubernetesClient.java index 7e0408ff054..2261581f6a3 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/DefaultKubernetesClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/DefaultKubernetesClient.java @@ -22,16 +22,12 @@ 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.v1beta1.CustomResourceDefinition; -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionList; import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.ConfigMapList; import io.fabric8.kubernetes.api.model.ComponentStatus; import io.fabric8.kubernetes.api.model.ComponentStatusList; import io.fabric8.kubernetes.api.model.Endpoints; import io.fabric8.kubernetes.api.model.EndpointsList; -import io.fabric8.kubernetes.api.model.Event; -import io.fabric8.kubernetes.api.model.EventList; import io.fabric8.kubernetes.api.model.LimitRange; import io.fabric8.kubernetes.api.model.LimitRangeList; import io.fabric8.kubernetes.api.model.Namespace; @@ -65,7 +61,6 @@ import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; import io.fabric8.kubernetes.client.dsl.internal.ClusterOperationsImpl; import io.fabric8.kubernetes.client.dsl.internal.CreateOnlyResourceOperationsImpl; -import io.fabric8.kubernetes.client.dsl.internal.apiextensions.v1beta1.CustomResourceDefinitionOperationsImpl; import io.fabric8.kubernetes.client.dsl.internal.CustomResourceOperationContext; import io.fabric8.kubernetes.client.dsl.internal.CustomResourceOperationsImpl; import io.fabric8.kubernetes.client.dsl.internal.KubernetesListOperationsImpl; @@ -222,14 +217,6 @@ public MixedOperation> endpoints() return new EndpointsOperationsImpl(httpClient, getConfiguration()); } - /** - * {@inheritDoc} - */ - @Override - public MixedOperation> events() { - return new EventOperationsImpl(httpClient, getConfiguration()); - } - /** * {@inheritDoc} */ @@ -347,14 +334,6 @@ public MixedOperation> limitRan return new LimitRangeOperationsImpl(httpClient, getConfiguration()); } - /** - * {@inheritDoc} - */ - @Override - public NonNamespaceOperation> customResourceDefinitions() { - return new CustomResourceDefinitionOperationsImpl(httpClient, getConfiguration()); - } - /** * {@inheritDoc} */ @@ -392,7 +371,7 @@ public Createable tokenReviews() { */ @Override public MixedOperation, Resource> customResources(Class resourceType) { - return customResources(CustomResourceDefinitionContext.fromCustomResourceType(resourceType), resourceType, null); + return customResources(resourceType, null); } @@ -401,29 +380,8 @@ public MixedOperation, R */ @Override public > MixedOperation> customResources(Class resourceType, Class listClass) { - return customResources(CustomResourceDefinitionContext.fromCustomResourceType(resourceType), resourceType, listClass); - } - - - /** - * {@inheritDoc} - */ - @Override - public > MixedOperation> customResources(CustomResourceDefinitionContext crdContext, Class resourceType, Class listClass) { - return new CustomResourceOperationsImpl<>(new CustomResourceOperationContext().withOkhttpClient(httpClient).withConfig(getConfiguration()) - .withCrdContext(crdContext) - .withType(resourceType) - .withListType(listClass) - .withPropagationPolicy(DEFAULT_PROPAGATION_POLICY)); - } - - /** - * {@inheritDoc} - */ - @Override - public > MixedOperation> customResources(CustomResourceDefinition crd, Class resourceType, Class listClass) { return new CustomResourceOperationsImpl<>(new CustomResourceOperationContext().withOkhttpClient(httpClient).withConfig(getConfiguration()) - .withCrd(crd) + .withCrdContext(CustomResourceDefinitionContext.fromCustomResourceType(resourceType)) .withType(resourceType) .withListType(listClass) .withPropagationPolicy(DEFAULT_PROPAGATION_POLICY)); @@ -437,15 +395,6 @@ public RawCustomResourceOperationsImpl customResource(CustomResourceDefinitionCo return new RawCustomResourceOperationsImpl(httpClient, getConfiguration(), customResourceDefinition); } - - /** - * {@inheritDoc} - */ - @Override - public > MixedOperation> customResource(CustomResourceDefinition crd, Class resourceType, Class listClass) { - return customResources(crd, resourceType, listClass); - } - @Override public DiscoveryAPIGroupDSL discovery() { return adapt(DiscoveryAPIGroupClient.class); diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java index 35f5ea84809..cc0e4eb2272 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/KubernetesClient.java @@ -27,8 +27,6 @@ import io.fabric8.kubernetes.api.model.ComponentStatusList; import io.fabric8.kubernetes.api.model.Endpoints; import io.fabric8.kubernetes.api.model.EndpointsList; -import io.fabric8.kubernetes.api.model.Event; -import io.fabric8.kubernetes.api.model.EventList; import io.fabric8.kubernetes.api.model.LimitRange; import io.fabric8.kubernetes.api.model.LimitRangeList; import io.fabric8.kubernetes.api.model.Namespace; @@ -59,8 +57,6 @@ import io.fabric8.kubernetes.api.model.node.v1beta1.RuntimeClass; import io.fabric8.kubernetes.api.model.node.v1beta1.RuntimeClassList; import io.fabric8.kubernetes.client.dsl.*; -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition; -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionList; import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; import io.fabric8.kubernetes.client.dsl.internal.RawCustomResourceOperationsImpl; import io.fabric8.kubernetes.client.extended.leaderelection.LeaderElectorBuilder; @@ -76,18 +72,6 @@ */ public interface KubernetesClient extends Client { - /** - * API entrypoint for CustomResourcedefinition(CRDs). This offers basic operations like - * load, get, create, update, delete and watch for APIGroup apiextensions/v1beta1 - * - * @deprecated Use {@link #apiextensions()}: {@link ApiextensionsAPIGroupDSL#v1beta1()} - * or {@link ApiextensionsAPIGroupDSL#v1()} to access Custom Resource Definition DSL for specific API versions. - * - * @return NonNamespaceOperation object for CustomResourceDefinition - */ - @Deprecated - NonNamespaceOperation> customResourceDefinitions(); - /** * API entrypoint for apiextensions resources. Currently support both * v1 and v1beta1 @@ -120,7 +104,6 @@ public interface KubernetesClient extends Client { */ MixedOperation, Resource> customResources(Class resourceType); - /** * 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 @@ -140,78 +123,6 @@ public interface KubernetesClient extends Client { */ > MixedOperation> customResources(Class resourceType, Class listClass); - - /** - * 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 - * specific to CustomResource. - * - *

- * Note: your CustomResource POJO (T in this context) must implement - * - * io.fabric8.kubernetes.api.model.Namespaced - * if it is a Namespaced scoped resource. - *

- * - * @param crdContext CustomResourceDefinitionContext describes the core fields used to search for CustomResources - * @param resourceType Class for CustomResource - * @param listClass Class for list object for CustomResource - * @param T type represents CustomResource type. If it's Namespaced resource, it must implement - * io.fabric8.kubernetes.api.model.Namespaced - * @param L type represents CustomResourceList type - * @return returns a MixedOperation object with which you can do basic CustomResource operations - */ - > MixedOperation> customResources(CustomResourceDefinitionContext crdContext, Class resourceType, Class listClass); - - /** - * 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 - * specific to CustomResource. - * - *

- * Note: your CustomResource POJO (T in this context) must implement - * - * io.fabric8.kubernetes.api.model.Namespaced - * if it is a Namespaced scoped resource. - *

- * - * @deprecated use {@link #customResources(CustomResourceDefinitionContext, Class, Class)}, which takes a {@link CustomResourceDefinitionContext} - * instead of a full {@link CustomResourceDefinition}. - * - * @param crd CustomResourceDefinition object on basic of which this CustomResource was created - * @param resourceType Class for CustomResource - * @param listClass Class for list object for CustomResource - * @param T type represents CustomResource type. If it's Namespaced resource, it must implement - * io.fabric8.kubernetes.api.model.Namespaced - * @param L type represents CustomResourceList type - * @return returns a MixedOperation object with which you can do basic CustomResource operations - */ - @Deprecated - > MixedOperation> customResources(CustomResourceDefinition crd, Class resourceType, Class listClass); - - /** - * Old API for dealing with CustomResources. - * - * @deprecated use {@link #customResources(CustomResourceDefinitionContext, Class, Class)}, which takes a {@link CustomResourceDefinitionContext} - * instead of a full {@link CustomResourceDefinition}. - * - *

- * Note: your CustomResource POJO (T in this context) must implement - * - * io.fabric8.kubernetes.api.model.Namespaced - * if it is a Namespaced scoped resource. - *

- * - * @param crd Custom Resource Definition - * @param resourceType resource type Pojo - * @param listClass list class Pojo - * @param template argument for resource. If it's Namespaced resource, it must implement - * io.fabric8.kubernetes.api.model.Namespaced - * @param template argument for list - * @return Kubernetes client object for manipulating custom resource. - */ - > MixedOperation> customResource(CustomResourceDefinition crd, Class resourceType, Class listClass); - /** * Discovery API entrypoint for APIGroup discovery.k8s.io * @@ -393,14 +304,6 @@ public interface KubernetesClient extends Client { */ MixedOperation> endpoints(); - /** - * API entrypoint for getting events in Kubernetes. Events (core/v1) - * - * @deprecated Use KubernetesClient#v1#events instead. - * @return MixedOperation object for doing operations for Events - */ - MixedOperation> events(); - /** * API entrypoint for namespace related operations in Kubernetes. Namespace (core/v1) * diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/osgi/ManagedKubernetesClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/osgi/ManagedKubernetesClient.java index 15ef7d20cb5..fffba4dd471 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/osgi/ManagedKubernetesClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/osgi/ManagedKubernetesClient.java @@ -1,5 +1,4 @@ -/** - * Copyright (C) 2015 Red Hat, Inc. +/** 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. @@ -25,8 +24,6 @@ import io.fabric8.kubernetes.api.model.ConfigMapList; import io.fabric8.kubernetes.api.model.Endpoints; import io.fabric8.kubernetes.api.model.EndpointsList; -import io.fabric8.kubernetes.api.model.Event; -import io.fabric8.kubernetes.api.model.EventList; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesResourceList; import io.fabric8.kubernetes.api.model.LimitRange; @@ -51,8 +48,6 @@ import io.fabric8.kubernetes.api.model.ServiceAccount; import io.fabric8.kubernetes.api.model.ServiceAccountList; import io.fabric8.kubernetes.api.model.ServiceList; -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition; -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionList; import io.fabric8.kubernetes.api.model.certificates.v1beta1.CertificateSigningRequest; import io.fabric8.kubernetes.api.model.certificates.v1beta1.CertificateSigningRequestList; import io.fabric8.kubernetes.api.model.authentication.TokenReview; @@ -333,10 +328,6 @@ public MixedOperation> events() { - return delegate.events(); - } - public MixedOperation> replicationControllers() { return delegate.replicationControllers(); } @@ -402,11 +393,6 @@ public AutoscalingAPIGroupDSL autoscaling() { @Override public RbacAPIGroupDSL rbac() { return delegate.rbac(); } - @Override - public NonNamespaceOperation> customResourceDefinitions() { - return delegate.customResourceDefinitions(); - } - @Override public ApiextensionsAPIGroupDSL apiextensions() { return delegate.apiextensions(); @@ -437,21 +423,6 @@ public > MixedOper return delegate.customResources(resourceType, listClass); } - @Override - public > MixedOperation> customResources(CustomResourceDefinitionContext crdContext, Class resourceType, Class listClass) { - return delegate.customResources(crdContext, resourceType, listClass); - } - - @Override - public > MixedOperation> customResources(CustomResourceDefinition crd, Class resourceType, Class listClass) { - return delegate.customResources(crd, resourceType, listClass); - } - - @Override - public > MixedOperation> customResource(CustomResourceDefinition crd, Class resourceType, Class listClass) { - return customResources(crd, resourceType, listClass); - } - @Override public DiscoveryAPIGroupDSL discovery() { return delegate.discovery(); diff --git a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CRDExample.java b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CRDExample.java index 39fc0195f95..952c2b2cbc4 100644 --- a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CRDExample.java +++ b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CRDExample.java @@ -93,7 +93,7 @@ public static void main(String[] args) { } } - CustomResourceDefinitionList crds = client.customResourceDefinitions().list(); + CustomResourceDefinitionList crds = client.apiextensions().v1beta1().customResourceDefinitions().list(); List crdsItems = crds.getItems(); System.out.println("Found " + crdsItems.size() + " CRD(s)"); CustomResourceDefinition dummyCRD = null; @@ -119,7 +119,7 @@ public static void main(String[] args) { KubernetesDeserializer.registerCustomKind(HasMetadata.getApiVersion(Dummy.class), dummyCRD.getKind(), Dummy.class); // lets create a client for the CRD - NonNamespaceOperation> dummyClient = client.customResources(dummyCRD, Dummy.class, DummyList.class); + NonNamespaceOperation> dummyClient = client.customResources(Dummy.class, DummyList.class); if (resourceNamespaced) { dummyClient = ((MixedOperation>) dummyClient).inNamespace(namespace); } diff --git a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceInformerExample.java b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceInformerExample.java index 953a8f3eeb4..8e06a1c3fc5 100644 --- a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceInformerExample.java +++ b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceInformerExample.java @@ -95,7 +95,7 @@ public void onDelete(Dummy pod, boolean deletedFinalStateUnknown) { .map(HasMetadata::getMetadata).map(ObjectMeta::getNamespace).orElse("default")); } - client.customResources(crdContext, Dummy.class, DummyList.class).createOrReplace(toCreate); + client.customResources(Dummy.class, DummyList.class).createOrReplace(toCreate); // Wait for some time now TimeUnit.MINUTES.sleep(5); } catch (InterruptedException interruptedException) { diff --git a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceV1Example.java b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceV1Example.java index e2912a08254..03581983dc2 100644 --- a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceV1Example.java +++ b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceV1Example.java @@ -55,7 +55,7 @@ public static void main(String... args) { kc.apiextensions().v1().customResourceDefinitions().createOrReplace(crd); System.out.println("Created custom shows.example.com Kubernetes API"); final NonNamespaceOperation> shows = - kc.customResources(CustomResourceDefinitionContext.fromCrd(crd), Show.class, ShowList.class) + kc.customResources(Show.class, ShowList.class) .inNamespace("default"); shows.list(); shows.createOrReplace(new Show("breaking-bad", new ShowSpec("Breaking Bad", 10))); diff --git a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/kubectl/equivalents/CustomResourceCreateDemo.java b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/kubectl/equivalents/CustomResourceCreateDemo.java index fa6fa33ec1d..5a4f5bfd39a 100644 --- a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/kubectl/equivalents/CustomResourceCreateDemo.java +++ b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/kubectl/equivalents/CustomResourceCreateDemo.java @@ -19,7 +19,6 @@ import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; -import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; import io.fabric8.kubernetes.examples.crds.Dummy; import io.fabric8.kubernetes.examples.crds.DummyList; @@ -34,18 +33,9 @@ public static void main(String[] args) { try (final KubernetesClient k8s = new DefaultKubernetesClient()) { // Dummy Client MixedOperation> dummyClient = null; - CustomResourceDefinitionContext context = new CustomResourceDefinitionContext - .Builder() - .withGroup("demo.fabric8.io") - .withKind("Dummy") - .withName("dummies.demo.fabric8.io") - .withPlural("dummies") - .withScope("Namespaced") - .withVersion("v1") - .build(); // Initializing Dummy Client - dummyClient = k8s.customResources(context, Dummy.class, DummyList.class); + dummyClient = k8s.customResources(Dummy.class, DummyList.class); // Get Dummy CustomResource Dummy dummy = dummyClient.load(CustomResourceCreateDemo.class.getResourceAsStream("/test-customresource.yaml")).get(); diff --git a/kubernetes-itests/src/test/java/io/fabric8/commons/DeleteEntity.java b/kubernetes-itests/src/test/java/io/fabric8/commons/DeleteEntity.java index cfcf96fcc69..d680d8f634d 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/commons/DeleteEntity.java +++ b/kubernetes-itests/src/test/java/io/fabric8/commons/DeleteEntity.java @@ -80,7 +80,7 @@ public Boolean call() { case "ClusterRole": return isDeleted(this.client.rbac().clusterRoles().withName(this.name).get()); case "CustomResourceDefinition": - return isDeleted(this.client.customResourceDefinitions().withName(this.name).get()); + return isDeleted(this.client.apiextensions().v1beta1().customResourceDefinitions().withName(this.name).get()); case "RoleBinding": return isDeleted(this.client.rbac().roleBindings().inNamespace(this.namespace).withName(this.name).get()); case "Role": diff --git a/kubernetes-itests/src/test/java/io/fabric8/commons/ReadyEntity.java b/kubernetes-itests/src/test/java/io/fabric8/commons/ReadyEntity.java index 68034db4ad7..ac81d4a0649 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/commons/ReadyEntity.java +++ b/kubernetes-itests/src/test/java/io/fabric8/commons/ReadyEntity.java @@ -50,7 +50,7 @@ public Boolean call() { case "ConfigMap": return this.client.configMaps().inNamespace(this.namespace).withName(this.name).get()!= null; case "CustomResourceDefinition": - return this.client.customResourceDefinitions().withName(this.namespace).get() != null; + return this.client.apiextensions().v1beta1().customResourceDefinitions().withName(this.namespace).get() != null; case "StatefulSet": return this.client.apps().statefulSets().inNamespace(this.namespace).withName(this.name).get()!= null; case "Deployment": diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CustomResourceDefinitionIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CustomResourceDefinitionIT.java index 817aef05495..073025d4d29 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CustomResourceDefinitionIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CustomResourceDefinitionIT.java @@ -65,7 +65,7 @@ public CustomResourceDefinition createCRD() { @Test public void testCrdOperations() { // Load - CustomResourceDefinition crd1 = client.customResourceDefinitions().load(getClass().getResourceAsStream("/test-crd.yml")).get(); + CustomResourceDefinition crd1 = client.apiextensions().v1beta1().customResourceDefinitions().load(getClass().getResourceAsStream("/test-crd.yml")).get(); assertThat(crd1).isNotNull(); // Create diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java index e0009a0ca5d..09b7b92c828 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java @@ -47,27 +47,26 @@ class CustomResourceCrudTest { public KubernetesServer kubernetesServer = new KubernetesServer(true,true); private CustomResourceDefinition cronTabCrd; - private CustomResourceDefinitionContext crdContext; @BeforeEach void setUp() { KubernetesDeserializer.registerCustomKind("stable.example.com/v1", "CronTab", CronTab.class); cronTabCrd = kubernetesServer.getClient() + .apiextensions().v1beta1() .customResourceDefinitions() .load(getClass().getResourceAsStream("/crontab-crd.yml")) .get(); - kubernetesServer.getClient().customResourceDefinitions().create(cronTabCrd); - crdContext = CustomResourceDefinitionContext.fromCrd(cronTabCrd); + kubernetesServer.getClient().apiextensions().v1beta1().customResourceDefinitions().create(cronTabCrd); } @Test - void testCrud() throws IOException { + void testCrud() { CronTab cronTab1 = createCronTab("my-new-cron-object", "* * * * */5", 3, "my-awesome-cron-image"); CronTab cronTab2 = createCronTab("my-second-cron-object", "* * * * */4", 2, "my-second-cron-image"); CronTab cronTab3 = createCronTab("my-third-cron-object", "* * * * */3", 1, "my-third-cron-image"); KubernetesClient client = kubernetesServer.getClient(); - MixedOperation> cronTabClient = client.customResources(crdContext, CronTab.class, CronTabList.class); + MixedOperation> cronTabClient = client.customResources(CronTab.class, CronTabList.class); cronTabClient.inNamespace("test-ns").create(cronTab1); cronTabClient.inNamespace("test-ns").create(cronTab2); @@ -117,14 +116,14 @@ void testCreateOrReplaceRaw() throws IOException { } @Test - void testCrudWithDashSymbolInCRDName() throws IOException { + void testCrudWithDashSymbolInCRDName() { CronTab cronTab1 = createCronTab("my-new-cron-object", "* * * * */5", 3, "my-awesome-cron-image"); CronTab cronTab2 = createCronTab("my-second-cron-object", "* * * * */4", 2, "my-second-cron-image"); CronTab cronTab3 = createCronTab("my-third-cron-object", "* * * * */3", 1, "my-third-cron-image"); KubernetesClient client = kubernetesServer.getClient(); MixedOperation> cronTabClient = client - .customResources(cronTabCrd, CronTab.class, CronTabList.class); + .customResources(CronTab.class, CronTabList.class); cronTabClient.inNamespace("test-ns").create(cronTab1); cronTabClient.inNamespace("test-ns").create(cronTab2); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudWithCRDContextTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudWithCRDContextTest.java index 360eba05416..8f66b61f678 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudWithCRDContextTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudWithCRDContextTest.java @@ -49,17 +49,10 @@ class CustomResourceCrudWithCRDContextTest { @Test void testCreateAndGet() { // Given - CustomResourceDefinitionContext crdContext = new CustomResourceDefinitionContext.Builder() - .withScope("Namespaced") - .withPlural("entandobundlereleases") - .withVersion("v1alpha1") - .withGroup("demo.fabric8.io") - .withKind("EntandoBundleRelease") - .build(); KubernetesClient client = kubernetesServer.getClient(); KubernetesDeserializer.registerCustomKind("demo.fabric8.io/v1alpha1", "EntandoBundleRelease", EntandoBundleRelease.class); MixedOperation> ebrClient = client - .customResources(crdContext, EntandoBundleRelease.class, EntandoBundleReleaseList.class); + .customResources(EntandoBundleRelease.class, EntandoBundleReleaseList.class); // When ebrClient.inNamespace("ns1").create(getMockedEntandoBundleRelease()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java index 4e1f5acc372..6cb5a5b00d8 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java @@ -159,7 +159,7 @@ void testListWithFields() { .toUrlEncoded("key1=value1,key2=value2,key3!=value3,key3!=value4")).andReturn(HttpURLConnection.HTTP_CREATED, customResourceDefinitionList).once(); KubernetesClient client = server.getClient(); - CustomResourceDefinitionList list = client.customResourceDefinitions() + CustomResourceDefinitionList list = client.apiextensions().v1beta1().customResourceDefinitions() .withField("key1", "value1") .withField("key2","value2") .withoutField("key3","value3") diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PropagationPolicyTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PropagationPolicyTest.java index d47d0548851..526861bda3e 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PropagationPolicyTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PropagationPolicyTest.java @@ -406,7 +406,7 @@ void testDeleteCustomResource() throws InterruptedException { // Given server.expect().delete().withPath("/apis/demo.k8s.io/v1alpha1/namespaces/test/podsets/example-podset").andReturn(HttpURLConnection.HTTP_OK, new PodSet()).once(); MixedOperation> podSetClient = server.getClient() - .customResources(CustomResourceDefinitionContext.v1beta1CRDFromCustomResourceType(PodSet.class).build(), PodSet.class, PodSetList.class); + .customResources(PodSet.class, PodSetList.class); // When boolean isDeleted = podSetClient.inNamespace("test").withName("example-podset").delete(); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/TypedClusterScopeCustomResourceApiTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/TypedClusterScopeCustomResourceApiTest.java index 49d6a932957..41989ef7a73 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/TypedClusterScopeCustomResourceApiTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/TypedClusterScopeCustomResourceApiTest.java @@ -57,7 +57,7 @@ void setupCrd() { void create() { server.expect().post().withPath("/apis/example.crd.com/v1alpha1/stars").andReturn(200, getStar()).once(); - starClient = server.getClient().customResources(crdContext, Star.class, StarList.class); + starClient = server.getClient().customResources(Star.class, StarList.class); Star returnedStar = starClient.inNamespace("test").create(getStar()); assertNotNull(returnedStar); @@ -69,7 +69,7 @@ void list() { StarList starList = new StarList(); starList.setItems(Collections.singletonList(getStar())); server.expect().get().withPath("/apis/example.crd.com/v1alpha1/stars").andReturn(200, starList).once(); - starClient = server.getClient().customResources(crdContext, Star.class, StarList.class); + starClient = server.getClient().customResources(Star.class, StarList.class); starList = starClient.inNamespace("test").list(); assertNotNull(starList); @@ -83,7 +83,7 @@ void createOrReplace() { server.expect().post().withPath("/apis/example.crd.com/v1alpha1/stars").andReturn(HttpURLConnection.HTTP_CONFLICT, getStar()).times(2); server.expect().put().withPath("/apis/example.crd.com/v1alpha1/stars/sun").andReturn(HttpURLConnection.HTTP_OK, getStar()).once(); - starClient = server.getClient().customResources(crdContext, Star.class, StarList.class); + starClient = server.getClient().customResources(Star.class, StarList.class); Star returnedStar = starClient.inNamespace("test").createOrReplace(getStar()); assertNotNull(returnedStar); @@ -94,7 +94,7 @@ void createOrReplace() { void delete() { server.expect().delete().withPath("/apis/example.crd.com/v1alpha1/stars/sun").andReturn(200, getStar()).once(); - starClient = server.getClient().customResources(crdContext, Star.class, StarList.class); + starClient = server.getClient().customResources(Star.class, StarList.class); boolean isDeleted = starClient.inNamespace("test").withName("sun").delete(); assertTrue(isDeleted); @@ -104,7 +104,7 @@ void delete() { void testCascadingDeletion() throws InterruptedException { server.expect().delete().withPath("/apis/example.crd.com/v1alpha1/stars/sun").andReturn(200, getStar()).once(); - starClient = server.getClient().customResources(crdContext, Star.class, StarList.class); + starClient = server.getClient().customResources(Star.class, StarList.class); boolean isDeleted = starClient.inNamespace("test").withName("sun").cascading(true).delete(); assertTrue(isDeleted); @@ -118,7 +118,7 @@ void testCascadingDeletion() throws InterruptedException { void testPropagationPolicyDeletion() throws InterruptedException { server.expect().delete().withPath("/apis/example.crd.com/v1alpha1/stars/sun").andReturn(200, getStar()).once(); - starClient = server.getClient().customResources(crdContext, Star.class, StarList.class); + starClient = server.getClient().customResources(Star.class, StarList.class); boolean isDeleted = starClient.inNamespace("test").withName("sun").withPropagationPolicy(DeletionPropagation.ORPHAN).delete(); assertTrue(isDeleted); @@ -136,7 +136,7 @@ void testStatusUpdate() throws InterruptedException { updatedStar.setStatus(starStatus); server.expect().put().withPath("/apis/example.crd.com/v1alpha1/stars/sun/status").andReturn(200, updatedStar).once(); - starClient = server.getClient().customResources(crdContext, Star.class, StarList.class); + starClient = server.getClient().customResources(Star.class, StarList.class); starClient.inNamespace("test").updateStatus(updatedStar); RecordedRequest recordedRequest = server.getLastRequest(); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/TypedCustomResourceApiTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/TypedCustomResourceApiTest.java index 5fa3dfb4dd4..be3f8d71450 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/TypedCustomResourceApiTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/TypedCustomResourceApiTest.java @@ -47,18 +47,11 @@ class TypedCustomResourceApiTest { private MixedOperation> podSetClient; - private CustomResourceDefinitionContext crdContext; - - @BeforeEach - void setupCrd() { - crdContext = CustomResourceDefinitionContext.fromCustomResourceType(PodSet.class); - } - @Test void create() { server.expect().post().withPath("/apis/demo.k8s.io/v1alpha1/namespaces/test/podsets").andReturn(200, getPodSet()).once(); - podSetClient = server.getClient().customResources(crdContext, PodSet.class, PodSetList.class); + podSetClient = server.getClient().customResources(PodSet.class, PodSetList.class); PodSet returnedPodSet = podSetClient.inNamespace("test").create(getPodSet()); assertNotNull(returnedPodSet); @@ -70,7 +63,7 @@ void list() { PodSetList podSetList = new PodSetList(); podSetList.setItems(Collections.singletonList(getPodSet())); server.expect().get().withPath("/apis/demo.k8s.io/v1alpha1/namespaces/test/podsets").andReturn(200, podSetList).once(); - podSetClient = server.getClient().customResources(crdContext, PodSet.class, PodSetList.class); + podSetClient = server.getClient().customResources(PodSet.class, PodSetList.class); podSetList = podSetClient.inNamespace("test").list(); assertNotNull(podSetList); @@ -84,7 +77,7 @@ void createOrReplace() { server.expect().post().withPath("/apis/demo.k8s.io/v1alpha1/namespaces/test/podsets").andReturn(HttpURLConnection.HTTP_CONFLICT, getPodSet()).times(2); server.expect().put().withPath("/apis/demo.k8s.io/v1alpha1/namespaces/test/podsets/example-podset").andReturn(HttpURLConnection.HTTP_OK, getPodSet()).once(); - podSetClient = server.getClient().customResources(crdContext, PodSet.class, PodSetList.class); + podSetClient = server.getClient().customResources(PodSet.class, PodSetList.class); PodSet returnedPodSet = podSetClient.inNamespace("test").createOrReplace(getPodSet()); assertNotNull(returnedPodSet); @@ -95,7 +88,7 @@ void createOrReplace() { void delete() { server.expect().delete().withPath("/apis/demo.k8s.io/v1alpha1/namespaces/test/podsets/example-podset").andReturn(200, getPodSet()).once(); - podSetClient = server.getClient().customResources(crdContext, PodSet.class, PodSetList.class); + podSetClient = server.getClient().customResources(PodSet.class, PodSetList.class); boolean isDeleted = podSetClient.inNamespace("test").withName("example-podset").delete(); assertTrue(isDeleted); @@ -105,7 +98,7 @@ void delete() { void testCascadingDeletion() throws InterruptedException { server.expect().delete().withPath("/apis/demo.k8s.io/v1alpha1/namespaces/test/podsets/example-podset").andReturn(200, getPodSet()).once(); - podSetClient = server.getClient().customResources(crdContext, PodSet.class, PodSetList.class); + podSetClient = server.getClient().customResources(PodSet.class, PodSetList.class); boolean isDeleted = podSetClient.inNamespace("test").withName("example-podset").cascading(true).delete(); assertTrue(isDeleted); @@ -119,7 +112,7 @@ void testCascadingDeletion() throws InterruptedException { void testPropagationPolicyDeletion() throws InterruptedException { server.expect().delete().withPath("/apis/demo.k8s.io/v1alpha1/namespaces/test/podsets/example-podset").andReturn(200, getPodSet()).once(); - podSetClient = server.getClient().customResources(crdContext, PodSet.class, PodSetList.class); + podSetClient = server.getClient().customResources(PodSet.class, PodSetList.class); boolean isDeleted = podSetClient.inNamespace("test").withName("example-podset").withPropagationPolicy(DeletionPropagation.ORPHAN).delete(); assertTrue(isDeleted); @@ -137,7 +130,7 @@ void testStatusUpdate() throws InterruptedException { updatedPodSet.setStatus(podSetStatus); server.expect().put().withPath("/apis/demo.k8s.io/v1alpha1/namespaces/test/podsets/example-podset/status").andReturn(200, updatedPodSet).once(); - podSetClient = server.getClient().customResources(crdContext, PodSet.class, PodSetList.class); + podSetClient = server.getClient().customResources(PodSet.class, PodSetList.class); podSetClient.inNamespace("test").updateStatus(updatedPodSet); RecordedRequest recordedRequest = server.getLastRequest(); diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java b/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java index 92f9fd15373..59fd5109dc6 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/DefaultOpenShiftClient.java @@ -25,8 +25,6 @@ import io.fabric8.kubernetes.api.model.DeletionPropagation; import io.fabric8.kubernetes.api.model.Endpoints; import io.fabric8.kubernetes.api.model.EndpointsList; -import io.fabric8.kubernetes.api.model.Event; -import io.fabric8.kubernetes.api.model.EventList; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesList; import io.fabric8.kubernetes.api.model.KubernetesListBuilder; @@ -54,8 +52,6 @@ import io.fabric8.kubernetes.api.model.ServiceAccount; import io.fabric8.kubernetes.api.model.ServiceAccountList; import io.fabric8.kubernetes.api.model.ServiceList; -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition; -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionList; import io.fabric8.kubernetes.api.model.authentication.TokenReview; import io.fabric8.kubernetes.api.model.certificates.v1beta1.CertificateSigningRequest; import io.fabric8.kubernetes.api.model.certificates.v1beta1.CertificateSigningRequestList; @@ -393,11 +389,6 @@ public MixedOperation, Resource> events() { - return delegate.events(); - } - @Override public NonNamespaceOperation> namespaces() { return delegate.namespaces(); @@ -479,31 +470,11 @@ public > MixedOper return new CustomResourceOperationsImpl<>(new CustomResourceOperationContext().withOkhttpClient(httpClient).withConfig(getConfiguration()).withCrdContext(CustomResourceDefinitionContext.fromCustomResourceType(resourceType)).withType(resourceType).withListType(listClass)); } - @Override - public > MixedOperation> customResources(CustomResourceDefinitionContext crdContext, Class resourceType, Class listClass) { - return new CustomResourceOperationsImpl<>(new CustomResourceOperationContext().withOkhttpClient(httpClient).withConfig(getConfiguration()).withCrdContext(crdContext).withType(resourceType).withListType(listClass)); - } - - @Override - public > MixedOperation> customResources(CustomResourceDefinition crd, Class resourceType, Class listClass) { - return new CustomResourceOperationsImpl<>(new CustomResourceOperationContext().withOkhttpClient(httpClient).withConfig(getConfiguration()).withCrd(crd).withType(resourceType).withListType(listClass)); - } - - @Override - public > MixedOperation> customResource(CustomResourceDefinition crd, Class resourceType, Class listClass) { - return customResources(crd, resourceType, listClass); - } - @Override public DiscoveryAPIGroupDSL discovery() { return delegate.discovery(); } - @Override - public NonNamespaceOperation> customResourceDefinitions() { - return new CustomResourceDefinitionOperationsImpl(httpClient, getConfiguration()); - } - @Override public ApiextensionsAPIGroupDSL apiextensions() { return delegate.apiextensions(); diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java b/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java index ef1b88d8928..7f7f51c7e0a 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java @@ -25,8 +25,6 @@ import io.fabric8.kubernetes.api.model.ConfigMapList; import io.fabric8.kubernetes.api.model.Endpoints; import io.fabric8.kubernetes.api.model.EndpointsList; -import io.fabric8.kubernetes.api.model.Event; -import io.fabric8.kubernetes.api.model.EventList; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.KubernetesList; import io.fabric8.kubernetes.api.model.KubernetesResourceList; @@ -52,8 +50,6 @@ import io.fabric8.kubernetes.api.model.ServiceAccount; import io.fabric8.kubernetes.api.model.ServiceAccountList; import io.fabric8.kubernetes.api.model.ServiceList; -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition; -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionList; import io.fabric8.kubernetes.api.model.authentication.TokenReview; import io.fabric8.kubernetes.api.model.certificates.v1beta1.CertificateSigningRequest; import io.fabric8.kubernetes.api.model.certificates.v1beta1.CertificateSigningRequestList; @@ -475,11 +471,6 @@ public MixedOperation, Resource> events() { - return delegate.events(); - } - @Override public NonNamespaceOperation> namespaces() { return delegate.namespaces(); @@ -570,31 +561,11 @@ public > MixedOper return delegate.customResources(resourceType, listClass); } - @Override - public > MixedOperation> customResources(CustomResourceDefinitionContext crdContext, Class resourceType, Class listClass) { - return delegate.customResources(crdContext, resourceType, listClass); - } - - @Override - public > MixedOperation> customResources(CustomResourceDefinition crd, Class resourceType, Class listClass) { - return delegate.customResources(crd, resourceType, listClass); - } - - @Override - public > MixedOperation> customResource(CustomResourceDefinition crd, Class resourceType, Class listClass) { - return customResources(crd, resourceType, listClass); - } - @Override public DiscoveryAPIGroupDSL discovery() { return delegate.discovery(); } - @Override - public NonNamespaceOperation> customResourceDefinitions() { - return delegate.customResourceDefinitions(); - } - @Override public ApiextensionsAPIGroupDSL apiextensions() { return delegate.apiextensions();