diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a8317d0467..ed3ff75cdcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### 4.4-SNAPSHOT Bugs + * Fix #1690: Endpoints is always pluralized Improvements diff --git a/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractor.java b/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractor.java index 0b1e0011194..f943d78117f 100644 --- a/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractor.java +++ b/kubernetes-server-mock/src/main/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractor.java @@ -160,7 +160,8 @@ else if (kind.equalsIgnoreCase("PodSecurityPolicies") || kind.equalsIgnoreCase("NetworkPolicies")){ kind = kind.substring(0,kind.length() - 3) + "y"; } - else if (kind.equalsIgnoreCase("securityContextConstraints")){ + else if (kind.equalsIgnoreCase("securityContextConstraints") || + kind.equalsIgnoreCase("endpoints")){ // do nothing // because its a case which is ending with s but its name is // like that, it is not plural diff --git a/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractorTest.java b/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractorTest.java index 64f99695ebd..02a4f62e462 100644 --- a/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractorTest.java +++ b/kubernetes-server-mock/src/test/java/io/fabric8/kubernetes/client/server/mock/KubernetesAttributesExtractorTest.java @@ -132,6 +132,17 @@ public void shouldHandleIngress() { Assert.assertTrue("Expected " + attributes + " to match " + expected, attributes.matches(expected)); } + @Test + public void shouldHandleEndpoints() { + KubernetesAttributesExtractor extractor = new KubernetesAttributesExtractor(); + AttributeSet attributes = extractor.extract("/api/v1/namespaces/myns/endpoints"); + + AttributeSet expected = new AttributeSet(); + expected = expected.add(new Attribute("kind", "endpoints")); + expected = expected.add(new Attribute("namespace", "myns")); + Assert.assertTrue("Expected " + attributes + " to match " + expected, attributes.matches(expected)); + } + @Test public void shouldHandleIngresses() { KubernetesAttributesExtractor extractor = new KubernetesAttributesExtractor();