From fcd29b3f940089557910bc1f8ad6407ca08d96bd Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Thu, 4 Jan 2024 00:55:39 +0530 Subject: [PATCH] chore : Remove `networking.k8s.io/v1alpha1` ClusterCIDR from Kubernetes Client DSL `networking.k8s.io/v1alpha1` ClusterCIDR has been removed from Kubernetes 1.29. Signed-off-by: Rohan Kumar --- .../client/V1Alpha1NetworkAPIGroupDSL.java | 19 --- .../impl/V1Alpha1NetworkAPIGroupClient.java | 7 -- .../client/mock/ClusterCIDRTest.java | 115 ------------------ 3 files changed, 141 deletions(-) delete mode 100644 kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterCIDRTest.java diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/V1Alpha1NetworkAPIGroupDSL.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/V1Alpha1NetworkAPIGroupDSL.java index 6289bcbb930..aab95f5fad4 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/V1Alpha1NetworkAPIGroupDSL.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/V1Alpha1NetworkAPIGroupDSL.java @@ -15,8 +15,6 @@ */ package io.fabric8.kubernetes.client; -import io.fabric8.kubernetes.api.model.networking.v1alpha1.ClusterCIDR; -import io.fabric8.kubernetes.api.model.networking.v1alpha1.ClusterCIDRList; import io.fabric8.kubernetes.api.model.networking.v1alpha1.IPAddress; import io.fabric8.kubernetes.api.model.networking.v1alpha1.IPAddressList; import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; @@ -32,21 +30,4 @@ public interface V1Alpha1NetworkAPIGroupDSL extends Client { * @return {@link NonNamespaceOperation} for IPAddress */ NonNamespaceOperation> ipAddresses(); - - /** - * API entrypoint for networking.k8s.io/v1alpha1 ClusterCIDR - *
- * ClusterCIDR represents a single configuration for per-Node Pod CIDR - * allocations when the MultiCIDRRangeAllocator is enabled (see the config for - * kube-controller-manager). A cluster may have any number of ClusterCIDR - * resources, all of which will be considered when allocating a CIDR for a - * Node. A ClusterCIDR is eligible to be used for a given Node when the node - * selector matches the node in question and has free CIDRs to allocate. In - * case of multiple matching ClusterCIDR resources, the allocator will attempt - * to break ties using internal heuristics, but any ClusterCIDR whose node - * selector matches the Node may be used. - * - * @return {@link NonNamespaceOperation} for ClusterCIDR - */ - NonNamespaceOperation> clusterCIDRs(); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/V1Alpha1NetworkAPIGroupClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/V1Alpha1NetworkAPIGroupClient.java index 31f2fd923fd..53226dde64b 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/V1Alpha1NetworkAPIGroupClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/V1Alpha1NetworkAPIGroupClient.java @@ -15,8 +15,6 @@ */ package io.fabric8.kubernetes.client.impl; -import io.fabric8.kubernetes.api.model.networking.v1alpha1.ClusterCIDR; -import io.fabric8.kubernetes.api.model.networking.v1alpha1.ClusterCIDRList; import io.fabric8.kubernetes.api.model.networking.v1alpha1.IPAddress; import io.fabric8.kubernetes.api.model.networking.v1alpha1.IPAddressList; import io.fabric8.kubernetes.client.V1Alpha1NetworkAPIGroupDSL; @@ -31,11 +29,6 @@ public NonNamespaceOperation> ipAd return resources(IPAddress.class, IPAddressList.class); } - @Override - public NonNamespaceOperation> clusterCIDRs() { - return resources(ClusterCIDR.class, ClusterCIDRList.class); - } - @Override public V1Alpha1NetworkAPIGroupClient newInstance() { return new V1Alpha1NetworkAPIGroupClient(); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterCIDRTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterCIDRTest.java deleted file mode 100644 index 81954453ccb..00000000000 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterCIDRTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * 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.mock; - -import io.fabric8.kubernetes.api.model.NodeSelectorBuilder; -import io.fabric8.kubernetes.api.model.NodeSelectorTermBuilder; -import io.fabric8.kubernetes.api.model.networking.v1alpha1.ClusterCIDR; -import io.fabric8.kubernetes.api.model.networking.v1alpha1.ClusterCIDRBuilder; -import io.fabric8.kubernetes.api.model.networking.v1alpha1.ClusterCIDRList; -import io.fabric8.kubernetes.api.model.networking.v1alpha1.ClusterCIDRListBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; -import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer; -import org.junit.jupiter.api.Test; - -import java.net.HttpURLConnection; -import java.util.Collections; - -import static org.assertj.core.api.Assertions.assertThat; - -@EnableKubernetesMockClient -class ClusterCIDRTest { - KubernetesMockServer server; - KubernetesClient client; - - @Test - void get() { - // Given - server.expect().get().withPath("/apis/networking.k8s.io/v1alpha1/clustercidrs/test-get") - .andReturn(HttpURLConnection.HTTP_OK, createNewClusterCIDR("test-get")) - .once(); - - // When - ClusterCIDR clusterCIDR = client.network().v1alpha1().clusterCIDRs().withName("test-get").get(); - - // Then - assertThat(clusterCIDR) - .isNotNull() - .hasFieldOrPropertyWithValue("metadata.name", "test-get"); - } - - @Test - void list() { - // Given - server.expect().get().withPath("/apis/networking.k8s.io/v1alpha1/clustercidrs") - .andReturn(HttpURLConnection.HTTP_OK, new ClusterCIDRListBuilder() - .addToItems(createNewClusterCIDR("test-list")) - .build()) - .once(); - - // When - ClusterCIDRList clusterCIDRList = client.network().v1alpha1().clusterCIDRs().list(); - - // Then - assertThat(clusterCIDRList).isNotNull(); - assertThat(clusterCIDRList.getItems()).hasSize(1); - assertThat(clusterCIDRList.getItems().get(0)) - .hasFieldOrPropertyWithValue("metadata.name", "test-list"); - } - - @Test - void delete() { - // Given - server.expect().delete().withPath("/apis/networking.k8s.io/v1alpha1/clustercidrs/test-delete") - .andReturn(HttpURLConnection.HTTP_OK, createNewClusterCIDR("test-delete")) - .once(); - - // When - boolean isDeleted = client.network().v1alpha1().clusterCIDRs().withName("test-delete").delete() - .size() == 1; - - // Then - assertThat(isDeleted).isTrue(); - } - - private ClusterCIDR createNewClusterCIDR(String name) { - return new ClusterCIDRBuilder() - .withNewMetadata() - .withName(name) - .endMetadata() - .withNewSpec() - .withIpv4("10.0.0.0/8") - .withIpv6("2001:db8::/64") - .withPerNodeHostBits(4) - .withNodeSelector(new NodeSelectorBuilder() - .withNodeSelectorTerms(Collections.singletonList(new NodeSelectorTermBuilder() - .addNewMatchField() - .withKey("metadata.name") - .withOperator("In") - .withValues("test-name") - .endMatchField() - .addNewMatchExpression() - .withKey("metadata.name") - .withOperator("In") - .withValues("test-name") - .endMatchExpression() - .build())) - .build()) - .endSpec() - .build(); - } -}