diff --git a/CHANGELOG.md b/CHANGELOG.md index dd9dbb28267..356b8cf447b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,13 @@ ### 4.10-SNAPSHOT #### Bugs +* Fix #2316: Cannot load resource from stream without apiVersion #### Improvements #### Dependency Upgrade * Fix #2355: bump jandex from 2.1.3.Final to 2.2.0.Final -* Fix #2353: bump workflow action-setup-* versions + kubernetes to 1.18.6 +* Fix #2353: bump workflow action-setup- versions + kubernetes to 1.18.6 #### New Features * Fix #2287: Add support for V1 and V1Beta1 CustomResourceDefinition diff --git a/kubernetes-model-generator/kubernetes-model-core/src/main/java/io/fabric8/kubernetes/internal/KubernetesDeserializer.java b/kubernetes-model-generator/kubernetes-model-core/src/main/java/io/fabric8/kubernetes/internal/KubernetesDeserializer.java index 5d7d65610d2..d02009327ba 100644 --- a/kubernetes-model-generator/kubernetes-model-core/src/main/java/io/fabric8/kubernetes/internal/KubernetesDeserializer.java +++ b/kubernetes-model-generator/kubernetes-model-core/src/main/java/io/fabric8/kubernetes/internal/KubernetesDeserializer.java @@ -126,6 +126,9 @@ public static void registerProvider(KubernetesResourceMappingProvider provider) static class Mapping { private static final String KEY_SEPARATOR = "#"; + + // n.b. Packages sorted in order of precedence, deserialization of resources with no + // specific version will default to first available Class in one of these packages: private static final String[] PACKAGES = { "io.fabric8.kubernetes.api.model.", "io.fabric8.kubernetes.api.model.admission", @@ -145,7 +148,6 @@ static class Mapping { "io.fabric8.kubernetes.api.model.coordination.", "io.fabric8.kubernetes.api.model.coordination.v1.", "io.fabric8.kubernetes.api.model.discovery.", - "io.fabric8.kubernetes.api.model.extensions.", "io.fabric8.kubernetes.api.model.events.", "io.fabric8.kubernetes.api.model.networking.", "io.fabric8.kubernetes.api.model.networking.v1beta1.", @@ -154,7 +156,8 @@ static class Mapping { "io.fabric8.kubernetes.api.model.storage.", "io.fabric8.kubernetes.api.model.scheduling.", "io.fabric8.kubernetes.api.model.settings.", - "io.fabric8.openshift.api.model." + "io.fabric8.openshift.api.model.", + "io.fabric8.kubernetes.api.model.extensions." }; private Map> mappings = new ConcurrentHashMap<>(); @@ -248,16 +251,18 @@ private Class getInternalTypeForName(String key) { // If only one class found, return it if (possibleResults.size() == 1) { return possibleResults.get(0); - } - - // Compare with apiVersions being compared for set of classes found - for (Class result : possibleResults) { + } else if (possibleResults.size() > 1) { + // Compare with apiVersions being compared for set of classes found + for (Class result : possibleResults) { String defaultKeyFromClass = getKeyFromClass(result); if (key.equals(defaultKeyFromClass)) { - return result; + return result; } + } + return possibleResults.get(0); + } else { + return null; } - return null; } private String getKeyFromClass(Class clazz) { diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DeploymentTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DeploymentTest.java index e81206066e9..90f4ae70930 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DeploymentTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DeploymentTest.java @@ -41,6 +41,7 @@ import io.fabric8.kubernetes.client.server.mock.KubernetesServer; import io.fabric8.kubernetes.client.utils.Utils; +import io.fabric8.kubernetes.model.util.Helper; import okhttp3.mockwebserver.RecordedRequest; import org.junit.Rule; import org.junit.jupiter.api.DisplayName; @@ -772,4 +773,20 @@ private DeploymentBuilder getDeploymentBuilder() { .endSpec(); } + @Test + void testDeploymentLoadWithoutApiVersion() { + // Given + KubernetesClient client = server.getClient(); + + // When + List list = client.load(getClass().getResourceAsStream("/valid-deployment-without-apiversion.json")).get(); + Deployment deployment = (Deployment) list.get(0); + + // Then + assertNotNull(deployment); + assertEquals("test", deployment.getMetadata().getName()); + assertEquals(1, deployment.getSpec().getReplicas()); + assertEquals(1, deployment.getSpec().getTemplate().getSpec().getContainers().size()); + } + } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1beta1IngressTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1beta1IngressTest.java index d4abfe7edf7..07b38e899b7 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1beta1IngressTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1beta1IngressTest.java @@ -54,7 +54,7 @@ void testLoad() { } @Test - public void testList() { + void testList() { server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/test/ingresses").andReturn(200, new IngressListBuilder().build()).once(); server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/ns1/ingresses").andReturn(200, new IngressListBuilder() .addNewItem().and() @@ -82,7 +82,7 @@ public void testList() { } @Test - public void testListWithLables() { + void testListWithLables() { server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/test/ingresses?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new IngressListBuilder().build()).always(); server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/test/ingresses?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new IngressListBuilder() .addNewItem().and() @@ -112,7 +112,7 @@ public void testListWithLables() { @Test - public void testGet() { + void testGet() { server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/test/ingresses/ingress1").andReturn(200, new IngressBuilder().build()).once(); server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/ns1/ingresses/ingress2").andReturn(200, new IngressBuilder().build()).once(); @@ -130,7 +130,7 @@ public void testGet() { @Test - public void testDelete() { + void testDelete() { server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/test/ingresses/ingress1").andReturn(200, new IngressBuilder().build()).once(); server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/ns1/ingresses/ingress2").andReturn(200, new IngressBuilder().build()).once(); @@ -148,7 +148,7 @@ public void testDelete() { @Test - public void testDeleteMulti() { + void testDeleteMulti() { Ingress ingress1 = new IngressBuilder().withNewMetadata().withName("ingress1").withNamespace("test").and().build(); Ingress ingress2 = new IngressBuilder().withNewMetadata().withName("ingress2").withNamespace("ns1").and().build(); Ingress ingress3 = new IngressBuilder().withNewMetadata().withName("ingress3").withNamespace("any").and().build(); @@ -166,7 +166,7 @@ public void testDeleteMulti() { } @Test - public void testDeleteWithNamespaceMismatch() { + void testDeleteWithNamespaceMismatch() { Assertions.assertThrows(KubernetesClientException.class, () -> { Ingress ingress1 = new IngressBuilder().withNewMetadata().withName("ingress1").withNamespace("test").and().build(); Ingress ingress2 = new IngressBuilder().withNewMetadata().withName("ingress2").withNamespace("ns1").and().build(); @@ -178,7 +178,7 @@ public void testDeleteWithNamespaceMismatch() { } @Test - public void testCreateWithNameMismatch() { + void testCreateWithNameMismatch() { Assertions.assertThrows(KubernetesClientException.class, () -> { Ingress ingress1 = new IngressBuilder().withNewMetadata().withName("ingress1").withNamespace("test").and().build(); Ingress ingress2 = new IngressBuilder().withNewMetadata().withName("ingress2").withNamespace("ns1").and().build(); @@ -188,4 +188,18 @@ public void testCreateWithNameMismatch() { }); } + @Test + void testIngressLoadWithoutApiVersion() { + // Given + KubernetesClient client = server.getClient(); + + // When + List items = client.load(getClass().getResourceAsStream("/test-ingress-no-apiversion.yml")).get(); + + // Then + assertNotNull(items); + assertEquals(1, items.size()); + assertTrue(items.get(0) instanceof Ingress); + } + } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CustomResourceDefinitionTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CustomResourceDefinitionTest.java index 0d85910e809..3c7ac58d9e4 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CustomResourceDefinitionTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CustomResourceDefinitionTest.java @@ -25,6 +25,7 @@ import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.server.mock.KubernetesServer; import org.junit.Rule; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport; @@ -124,6 +125,20 @@ void testDelete() { assertTrue(deleted); } + @Test + void testCustomResourceDefinitionTest() { + // Given + KubernetesClient client = server.getClient(); + + // When + List items = client.load(getClass().getResourceAsStream("/test-crd-no-apiversion.yml")).get(); + + // Then + Assertions.assertNotNull(items); + Assertions.assertEquals(1, items.size()); + Assertions.assertTrue(items.get(0) instanceof CustomResourceDefinition); + } + JSONSchemaProps readSchema() throws IOException { ObjectMapper mapper = new ObjectMapper(); final URL resource = getClass().getResource("/test-crd-validation-schema.json"); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1HorizontalPodAutoscalerTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1HorizontalPodAutoscalerTest.java index 9fe1c8a68f7..71e67be272b 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1HorizontalPodAutoscalerTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1HorizontalPodAutoscalerTest.java @@ -57,7 +57,7 @@ void testLoadAsPlainList() { } @Test - public void testList() { + void testList() { server.expect().withPath("/apis/autoscaling/v1/namespaces/test/horizontalpodautoscalers").andReturn(200, new HorizontalPodAutoscalerListBuilder().build()).once(); server.expect().withPath("/apis/autoscaling/v1/namespaces/ns1/horizontalpodautoscalers").andReturn(200, new HorizontalPodAutoscalerListBuilder() .addNewItem().and() @@ -75,7 +75,7 @@ public void testList() { } @Test - public void testListWithLabels() { + void testListWithLabels() { server.expect().withPath("/apis/autoscaling/v1/namespaces/test/horizontalpodautoscalers?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new HorizontalPodAutoscalerListBuilder().build()).once(); server.expect().withPath("/apis/autoscaling/v1/namespaces/ns1/horizontalpodautoscalers?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new HorizontalPodAutoscalerListBuilder() .addNewItem().and() @@ -101,7 +101,7 @@ public void testListWithLabels() { } @Test - public void testGet() { + void testGet() { server.expect().withPath("/apis/autoscaling/v1/namespaces/test/horizontalpodautoscalers/horizontalpodautoscaler1").andReturn(200, new HorizontalPodAutoscalerBuilder().build()).once(); server.expect().withPath("/apis/autoscaling/v1/namespaces/ns1/horizontalpodautoscalers/horizontalpodautoscaler2").andReturn(200, new HorizontalPodAutoscalerBuilder().build()).once(); @@ -117,7 +117,7 @@ public void testGet() { } @Test - public void testEditMissing() { + void testEditMissing() { Assertions.assertThrows(KubernetesClientException.class, () -> { server.expect().withPath("/apis/autoscaling/v1/namespaces/test/horizontalpodautoscalers/horizontalpodautoscaler").andReturn(404, "error message from kubernetes").always(); @@ -128,7 +128,7 @@ public void testEditMissing() { } @Test - public void testDelete() { + void testDelete() { server.expect().withPath("/apis/autoscaling/v1/namespaces/test/horizontalpodautoscalers/horizontalpodautoscaler1").andReturn(200, new HorizontalPodAutoscalerBuilder().build()).once(); server.expect().withPath("/apis/autoscaling/v1/namespaces/ns1/horizontalpodautoscalers/horizontalpodautoscaler2").andReturn(200, new HorizontalPodAutoscalerBuilder().build()).once(); @@ -144,7 +144,7 @@ public void testDelete() { } @Test - public void testDeleteMulti() { + void testDeleteMulti() { HorizontalPodAutoscaler horizontalPodAutoscaler1 = new HorizontalPodAutoscalerBuilder().withNewMetadata().withName("horizontalpodautoscaler1").withNamespace("test").endMetadata().build(); HorizontalPodAutoscaler horizontalPodAutoscaler2 = new HorizontalPodAutoscalerBuilder().withNewMetadata().withName("horizontalpodautoscaler2").withNamespace("ns1").endMetadata().build(); HorizontalPodAutoscaler horizontalPodAutoscaler3 = new HorizontalPodAutoscalerBuilder().withNewMetadata().withName("horizontalpodautoscaler3").withNamespace("any").endMetadata().build(); @@ -161,7 +161,7 @@ public void testDeleteMulti() { } @Test - public void testCreateWithNameMismatch() { + void testCreateWithNameMismatch() { Assertions.assertThrows(KubernetesClientException.class, () -> { HorizontalPodAutoscaler horizontalPodAutoscaler1 = new HorizontalPodAutoscalerBuilder().withNewMetadata().withName("horizontalpodautoscaler1").withNamespace("test").endMetadata().build(); KubernetesClient client = server.getClient(); @@ -170,14 +170,14 @@ public void testCreateWithNameMismatch() { } @Test - public void testLoadFromFile() { + void testLoadFromFile() { KubernetesClient client = server.getClient(); HorizontalPodAutoscaler horizontalPodAutoscaler = client.autoscaling().v1().horizontalPodAutoscalers().load(getClass().getResourceAsStream("/test-horizontalpodautoscaler.yml")).get(); assertEquals("php-apache", horizontalPodAutoscaler.getMetadata().getName()); } @Test - public void testBuild() { + void testBuild() { HorizontalPodAutoscaler horizontalPodAutoscaler = new HorizontalPodAutoscalerBuilder() .withNewMetadata().withName("test-hpa").withNamespace("test").endMetadata() .withNewSpec() @@ -198,4 +198,18 @@ public void testBuild() { assertNotNull(horizontalPodAutoscaler); } + @Test + void testHorizontalPodAutoscalerLoadWithNoApiVersion() { + // Given + KubernetesClient client = server.getClient(); + + // When + List items = client.load(getClass().getResourceAsStream("/test-hpa-no-apiversion.yml")).get(); + + // Then + assertNotNull(items); + assertEquals(1, items.size()); + assertTrue(items.get(0) instanceof HorizontalPodAutoscaler); + } + } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1MutatingWebhookConfigurationTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1MutatingWebhookConfigurationTest.java index d0796dfc567..5e2004b3abc 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1MutatingWebhookConfigurationTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1MutatingWebhookConfigurationTest.java @@ -27,6 +27,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport; +import java.util.List; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -104,6 +106,20 @@ public void delete() { assertTrue(isDeleted); } + @Test + public void testMutatingWebhookConfigurationLoadWithNoApiVersion() { + // Given + KubernetesClient client = server.getClient(); + + // When + List items = client.load(getClass().getResourceAsStream("/test-mwc-no-apiversion.yml")).get(); + + // Then + assertNotNull(items); + assertEquals(1, items.size()); + assertTrue(items.get(0) instanceof MutatingWebhookConfiguration); + } + public MutatingWebhookConfiguration getMutatingWebhookConfigurationSample() { return new MutatingWebhookConfigurationBuilder() .withNewMetadata().withName("mutatingWebhookConfiguration1").endMetadata() diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1ValidatingWebhookConfigurationTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1ValidatingWebhookConfigurationTest.java index 3f9b9efe20b..80cd6026646 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1ValidatingWebhookConfigurationTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1ValidatingWebhookConfigurationTest.java @@ -14,6 +14,7 @@ * limitations under the License. */ package io.fabric8.kubernetes.client.mock; + import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookBuilder; import io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookConfiguration; @@ -26,6 +27,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport; +import java.util.List; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -112,6 +115,20 @@ public void delete() { assertTrue(isDeleted); } + @Test + public void testValidatingWebhookConfigurationLoadWithNoApiVersion() { + // Given + KubernetesClient client = server.getClient(); + + // When + List items = client.load(getClass().getResourceAsStream("/test-vwc-no-apiversion.yml")).get(); + + // Then + assertNotNull(items); + assertEquals(1, items.size()); + assertTrue(items.get(0) instanceof ValidatingWebhookConfiguration); + } + public ValidatingWebhookConfiguration getValidatingWebhookConfigurationSample() { return new ValidatingWebhookConfigurationBuilder() .withNewMetadata().withName("validatingWebhookConfiguration1").endMetadata() diff --git a/kubernetes-tests/src/test/resources/test-crd-no-apiversion.yml b/kubernetes-tests/src/test/resources/test-crd-no-apiversion.yml new file mode 100644 index 00000000000..c6049f34c06 --- /dev/null +++ b/kubernetes-tests/src/test/resources/test-crd-no-apiversion.yml @@ -0,0 +1,31 @@ +# +# 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. +# + +kind: CustomResourceDefinition +metadata: + name: dummies.demo.fabric8.io +spec: + group: demo.fabric8.io + scope: Namespaced + versions: + - name: v1 + served: true + storage: true + names: + kind: Dummy + plural: dummies + shortNames: + - dummy diff --git a/kubernetes-tests/src/test/resources/test-hpa-no-apiversion.yml b/kubernetes-tests/src/test/resources/test-hpa-no-apiversion.yml new file mode 100644 index 00000000000..08ba23c0778 --- /dev/null +++ b/kubernetes-tests/src/test/resources/test-hpa-no-apiversion.yml @@ -0,0 +1,34 @@ +# +# 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. +# + +kind: HorizontalPodAutoscaler +metadata: + name: php-apache + namespace: default +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: php-apache + minReplicas: 1 + maxReplicas: 10 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 diff --git a/kubernetes-tests/src/test/resources/test-ingress-no-apiversion.yml b/kubernetes-tests/src/test/resources/test-ingress-no-apiversion.yml new file mode 100644 index 00000000000..0dc09ad47de --- /dev/null +++ b/kubernetes-tests/src/test/resources/test-ingress-no-apiversion.yml @@ -0,0 +1,30 @@ +# +# 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. +# + +kind: Ingress +metadata: + name: test-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + rules: + - http: + paths: + - path: /testpath + pathType: Prefix + backend: + serviceName: test + servicePort: 80 diff --git a/kubernetes-tests/src/test/resources/test-mwc-no-apiversion.yml b/kubernetes-tests/src/test/resources/test-mwc-no-apiversion.yml new file mode 100644 index 00000000000..9781ce4c3d8 --- /dev/null +++ b/kubernetes-tests/src/test/resources/test-mwc-no-apiversion.yml @@ -0,0 +1,30 @@ +# +# 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. +# + +kind: MutatingWebhookConfiguration +metadata: + name: "my-webhook.example.com" +webhooks: + - name: my-webhook.example.com + objectSelector: + matchLabels: + foo: bar + rules: + - operations: ["CREATE"] + apiGroups: ["*"] + apiVersions: ["*"] + resources: ["*"] + scope: "*" diff --git a/kubernetes-tests/src/test/resources/test-vwc-no-apiversion.yml b/kubernetes-tests/src/test/resources/test-vwc-no-apiversion.yml new file mode 100644 index 00000000000..01018ae8852 --- /dev/null +++ b/kubernetes-tests/src/test/resources/test-vwc-no-apiversion.yml @@ -0,0 +1,35 @@ +# +# 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. +# + +kind: ValidatingWebhookConfiguration +metadata: + name: "pod-policy.example.com" +webhooks: + - name: "pod-policy.example.com" + rules: + - apiGroups: [""] + apiVersions: ["v1"] + operations: ["CREATE"] + resources: ["pods"] + scope: "Namespaced" + clientConfig: + service: + namespace: "example-namespace" + name: "example-service" + caBundle: "Ci0tLS0tQk...<`caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate.>...tLS0K" + admissionReviewVersions: ["v1", "v1beta1"] + sideEffects: None + timeoutSeconds: 5 diff --git a/kubernetes-tests/src/test/resources/valid-deployment-without-apiversion.json b/kubernetes-tests/src/test/resources/valid-deployment-without-apiversion.json new file mode 100644 index 00000000000..3bdb6e14b67 --- /dev/null +++ b/kubernetes-tests/src/test/resources/valid-deployment-without-apiversion.json @@ -0,0 +1,39 @@ +{ + "kind": "Deployment", + "metadata": { + "name": "test", + "labels": { + "app": "test" + } + }, + "spec": { + "selector": { + "matchLabels": { + "app": "test" + } + }, + "replicas": 1, + "template": { + "metadata": { + "labels": { + "app": "test" + } + }, + "spec": { + "containers": [ + { + "name": "test", + "image": "busybox:latest", + "command": [ + "/bin/sh", + "-c" + ], + "args": [ + "sleep 60" + ] + } + ] + } + } + } +}