Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6159 Removing deprecated method in util class #6504

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected void validate() {
if (kind == null) {
throw new IllegalArgumentException("Neither kind nor plural was set, at least one is required");
}
plural = Utils.getPluralFromKind(kind);
plural = HasMetadata.getPlural(kind.getClass());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,17 +341,6 @@ public static String toUrlEncoded(String str) {
return null;
}

/**
*
* @param kind
* @return
* @deprecated use {@link io.fabric8.kubernetes.api.model.HasMetadata#getPlural(Class)}
*/
@Deprecated
public static String getPluralFromKind(String kind) {
return Pluralize.toPlural(kind.toLowerCase(Locale.ROOT));
}

/**
* Reads @Namespaced annotation in resource class to check whether
* resource is namespaced or not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,65 +175,6 @@ void interpolateStringWithParametersTest() {
assertEquals("This is a \"template string\" and the following is code ${NOT_REPLACED}: '1' === '1'; /* END */", result);
}

@Test
void testGetPluralFromKind() {
// Given
SortedMap<String, Class> pluralToKubernetesResourceMap = new TreeMap<>();
pluralToKubernetesResourceMap.put("bindings", Binding.class);
pluralToKubernetesResourceMap.put("componentstatuses", ComponentStatus.class);
pluralToKubernetesResourceMap.put("configmaps", ConfigMap.class);
pluralToKubernetesResourceMap.put("endpoints", Endpoints.class);
pluralToKubernetesResourceMap.put("events", Event.class);
pluralToKubernetesResourceMap.put("limitranges", LimitRange.class);
pluralToKubernetesResourceMap.put("namespaces", Namespace.class);
pluralToKubernetesResourceMap.put("nodes", Node.class);
pluralToKubernetesResourceMap.put("persistentvolumeclaims", PersistentVolumeClaim.class);
pluralToKubernetesResourceMap.put("persistentvolumes", PersistentVolume.class);
pluralToKubernetesResourceMap.put("pods", Pod.class);
pluralToKubernetesResourceMap.put("podtemplates", PodTemplate.class);
pluralToKubernetesResourceMap.put("replicationcontrollers", ReplicationController.class);
pluralToKubernetesResourceMap.put("resourcequotas", ResourceQuota.class);
pluralToKubernetesResourceMap.put("secrets", Secret.class);
pluralToKubernetesResourceMap.put("serviceaccounts", ServiceAccount.class);
pluralToKubernetesResourceMap.put("services", Service.class);
pluralToKubernetesResourceMap.put("mutatingwebhookconfigurations", MutatingWebhookConfiguration.class);
pluralToKubernetesResourceMap.put("validatingwebhookconfigurations", ValidatingWebhookConfiguration.class);
pluralToKubernetesResourceMap.put("customresourcedefinitions", CustomResourceDefinition.class);
pluralToKubernetesResourceMap.put("controllerrevisions", ControllerRevision.class);
pluralToKubernetesResourceMap.put("daemonsets", DaemonSet.class);
pluralToKubernetesResourceMap.put("deployments", Deployment.class);
pluralToKubernetesResourceMap.put("replicasets", ReplicaSet.class);
pluralToKubernetesResourceMap.put("statefulsets", StatefulSet.class);
pluralToKubernetesResourceMap.put("tokenreviews", TokenReview.class);
pluralToKubernetesResourceMap.put("localsubjectaccessreviews", LocalSubjectAccessReview.class);
pluralToKubernetesResourceMap.put("selfsubjectaccessreviews", SelfSubjectAccessReview.class);
pluralToKubernetesResourceMap.put("selfsubjectrulesreviews", SelfSubjectRulesReview.class);
pluralToKubernetesResourceMap.put("subjectaccessreviews", SubjectAccessReview.class);
pluralToKubernetesResourceMap.put("horizontalpodautoscalers", HorizontalPodAutoscaler.class);
pluralToKubernetesResourceMap.put("cronjobs", CronJob.class);
pluralToKubernetesResourceMap.put("jobs", Job.class);
pluralToKubernetesResourceMap.put("certificatesigningrequests", CertificateSigningRequest.class);
pluralToKubernetesResourceMap.put("leases", Lease.class);
pluralToKubernetesResourceMap.put("endpointslices", EndpointSlice.class);
pluralToKubernetesResourceMap.put("ingresses", Ingress.class);
pluralToKubernetesResourceMap.put("networkpolicies", NetworkPolicy.class);
pluralToKubernetesResourceMap.put("poddisruptionbudgets", PodDisruptionBudget.class);
pluralToKubernetesResourceMap.put("podsecuritypolicies", PodSecurityPolicy.class);
pluralToKubernetesResourceMap.put("clusterrolebindings", ClusterRoleBinding.class);
pluralToKubernetesResourceMap.put("clusterroles", ClusterRole.class);
pluralToKubernetesResourceMap.put("rolebindings", RoleBinding.class);
pluralToKubernetesResourceMap.put("roles", Role.class);
pluralToKubernetesResourceMap.put("priorityclasses", PriorityClass.class);
pluralToKubernetesResourceMap.put("csidrivers", CSIDriver.class);
pluralToKubernetesResourceMap.put("csinodes", CSINode.class);
pluralToKubernetesResourceMap.put("storageclasses", StorageClass.class);
pluralToKubernetesResourceMap.put("volumeattachments", VolumeAttachment.class);

// When & Then
pluralToKubernetesResourceMap.forEach(
(plural, kubernetesResource) -> assertEquals(plural, Utils.getPluralFromKind(kubernetesResource.getSimpleName())));
}

@Test
@DisplayName("Should test whether resource is namespaced or not")
void testWhetherNamespacedOrNot() {
Expand Down