Skip to content

Commit

Permalink
chore #3906: deprecating CustomResourceList
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins authored and manusa committed Jul 4, 2022
1 parent f1e8eb2 commit a5285fb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
5 changes: 3 additions & 2 deletions doc/MIGRATION-v6.md
Expand Up @@ -244,10 +244,11 @@ We've removed setter methods `setIntVal`, `setKind`, `setStrVal` from the class.

- DSL methods available off of a resource context involving a resource - `client.configMaps().withName("name").create(configMap)` - should instead use a no-argument method - `client.configMaps().resource(configMap).create()` or `client.resource(configMap).create()`.

- DSL methods available off of a collection context involving a resource - `client.configMaps().create(configMap)` - should instead use a no-argument method - `client.configMaps().resource(configMap).create()` or `client.resource(configMap).create()`.

- DSL methods available off of a collection context involving a resource - `client.configMaps().create(configMap)` - should instead use a no-argument method - `client.configMaps().resource(configMap).create()` or `client.resource(configMap).create()`.
The only exception to the above is `patch(PatchContext, item)` - it is valid to be called after withName.

- CustomResourceList was deprecated - use DefaultKubernetesResourceList instead.

## Object Sorting

`KubernetesList` and `Template` will no longer automatically sort their objects by default. You may use the `HasMetadataComparator` yourself to sort the items as needed.
Expand Down
Expand Up @@ -18,5 +18,9 @@
import io.fabric8.kubernetes.api.model.DefaultKubernetesResourceList;
import io.fabric8.kubernetes.api.model.HasMetadata;

/**
* @deprecated use DefaultKubernetesResourceList instead
*/
@Deprecated
public class CustomResourceList<T extends HasMetadata> extends DefaultKubernetesResourceList<T> {
}
Expand Up @@ -21,7 +21,6 @@
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionList;
import io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaPropsBuilder;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.client.CustomResourceList;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.KubernetesClientException;
Expand Down Expand Up @@ -111,23 +110,23 @@ public static void main(String[] args) {
System.out.println("Found CRD: " + dummyCRD.getMetadata().getSelfLink());
} else {
dummyCRD = CustomResourceDefinitionContext.v1CRDFromCustomResourceType(Dummy.class)
.editSpec()
.editVersion(0)
.withNewSchema()
.withNewOpenAPIV3Schema()
.withTitle("dummy")
.withType("object")
.addToRequired("spec")
.addToProperties("spec", new JSONSchemaPropsBuilder()
.editSpec()
.editVersion(0)
.withNewSchema()
.withNewOpenAPIV3Schema()
.withTitle("dummy")
.withType("object")
.addToProperties("foo", new JSONSchemaPropsBuilder().withType("string").build())
.addToProperties("bar", new JSONSchemaPropsBuilder().withType("string").build())
.build())
.endOpenAPIV3Schema()
.endSchema()
.endVersion()
.endSpec()
.build();
.addToRequired("spec")
.addToProperties("spec", new JSONSchemaPropsBuilder()
.withType("object")
.addToProperties("foo", new JSONSchemaPropsBuilder().withType("string").build())
.addToProperties("bar", new JSONSchemaPropsBuilder().withType("string").build())
.build())
.endOpenAPIV3Schema()
.endSchema()
.endVersion()
.endSpec()
.build();

client.apiextensions().v1().customResourceDefinitions().create(dummyCRD);
System.out.println("Created CRD " + dummyCRD.getMetadata().getName());
Expand All @@ -141,7 +140,7 @@ public static void main(String[] args) {
if (resourceNamespaced) {
dummyClient = ((MixedOperation<Dummy, DummyList, Resource<Dummy>>) dummyClient).inNamespace(namespace);
}
CustomResourceList<Dummy> dummyList = dummyClient.list();
DummyList dummyList = dummyClient.list();
List<Dummy> items = dummyList.getItems();
System.out.println(" found " + items.size() + " dummies");
for (Dummy item : items) {
Expand Down
Expand Up @@ -15,12 +15,12 @@
*/
package io.fabric8.kubernetes.examples;

import io.fabric8.kubernetes.api.model.DefaultKubernetesResourceList;
import io.fabric8.kubernetes.api.model.Namespaced;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaPropsBuilder;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.client.CustomResourceList;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
Expand Down Expand Up @@ -82,7 +82,7 @@ public Show(String metaName, ShowSpec spec) {
}
}

public static final class ShowList extends CustomResourceList<Show> {
public static final class ShowList extends DefaultKubernetesResourceList<Show> {
}

@SuppressWarnings("unused")
Expand Down
Expand Up @@ -15,7 +15,7 @@
*/
package io.fabric8.kubernetes.examples.crds;

import io.fabric8.kubernetes.client.CustomResourceList;
import io.fabric8.kubernetes.api.model.DefaultKubernetesResourceList;

public class DummyList extends CustomResourceList<Dummy> {
public class DummyList extends DefaultKubernetesResourceList<Dummy> {
}

0 comments on commit a5285fb

Please sign in to comment.