From 94224375ab6e67526af4d9d84009b0f4bc6c34fa Mon Sep 17 00:00:00 2001 From: Mathieu Bruyen Date: Tue, 6 Aug 2019 11:27:27 +0200 Subject: [PATCH 1/2] Endpoints should stay pluralized Mock web server is currently removing the trailing s from endpoints when searching for objects in the API. This prevents it from finding created endpoints. Adding endpoints to the exception list of objects to be considered pluralized. --- .../server/mock/KubernetesAttributesExtractor.java | 3 ++- .../mock/KubernetesAttributesExtractorTest.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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(); From a62bf0c4ef327a9752fd148f70accebdb1dad117 Mon Sep 17 00:00:00 2001 From: Mathieu Bruyen Date: Tue, 6 Aug 2019 14:02:31 +0200 Subject: [PATCH 2/2] add note in changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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