Skip to content

Commit

Permalink
Fix fabric8io#1565: CRD's Enums are prefixed with "Raw: " keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanKanojia committed Jul 26, 2019
1 parent f5ebea6 commit 60127c8
Show file tree
Hide file tree
Showing 10 changed files with 3,303 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### 4.3-SNAPSHOT
Bugs
* Fix #1565: CRD's Enums are prefixed with Raw keyword

Improvements
* Cleaned up kubernetes-model pom.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class RawCustomResourceIT {

private CustomResourceDefinitionContext customResourceDefinitionContext;

private CustomResourceDefinitionContext customResourceDefinitionContextWithOpenAPIV3Schema;

@Before
public void initCustomResourceDefinition() {
currentNamespace = session.getNamespace();
Expand All @@ -64,6 +66,18 @@ public void initCustomResourceDefinition() {
.withPlural("animals")
.withScope("Namespaced")
.build();

// Create a Custom Resource Definition with OpenAPIV3 validation schema
CustomResourceDefinition aComplexCrd = client.customResourceDefinitions().load(getClass().getResourceAsStream("/kafka-crd.yml")).get();
client.customResourceDefinitions().create(aComplexCrd);

customResourceDefinitionContextWithOpenAPIV3Schema = new CustomResourceDefinitionContext.Builder()
.withName("kafkas.kafka.strimzi.io")
.withGroup("kafka.strimzi.io")
.withPlural("kafkas")
.withScope("Namespaced")
.withVersion("v1beta1")
.build();
}

@Test
Expand Down Expand Up @@ -96,14 +110,21 @@ public void testCrud() throws IOException {
object = client.customResource(customResourceDefinitionContext).edit(currentNamespace, "walrus", new ObjectMapper().writeValueAsString(object));
assertThat(((HashMap<String, Object>)object.get("spec")).get("image")).isEqualTo("my-updated-awesome-walrus-image");

// Test creation with openAPIV3Schema
Map<String, Object> ret = client.customResource(customResourceDefinitionContextWithOpenAPIV3Schema).create(currentNamespace, getClass().getResourceAsStream("/kafka-cr.yml"));
assertThat(ret).isNotNull();
assertThat(((Map<String, Object>)ret.get("metadata")).get("name")).isEqualTo("kafka-single");

// Test Delete:
client.customResource(customResourceDefinitionContext).delete(currentNamespace, "otter");
client.customResource(customResourceDefinitionContextWithOpenAPIV3Schema).delete(currentNamespace, "kafka-single");
client.customResource(customResourceDefinitionContext).delete(currentNamespace);
}

@After
public void cleanup() {
// Delete Custom Resource Definition Animals:
client.customResourceDefinitions().withName(customResourceDefinitionContext.getName()).delete();
client.customResourceDefinitions().withName(customResourceDefinitionContextWithOpenAPIV3Schema.getName()).delete();
}
}
41 changes: 41 additions & 0 deletions kubernetes-itests/src/test/resources/kafka-cr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# 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.
#

apiVersion: kafka.strimzi.io/v1beta1
kind: Kafka
metadata:
name: kafka-single
spec:
kafka:
version: 2.1.1
replicas: 1
listeners:
plain: {}
tls: {}
config:
offsets.topic.replication.factor: 1
transaction.state.log.replication.factor: 1
transaction.state.log.min.isr: 1
log.message.format.version: "2.1"
storage:
type: ephemeral
zookeeper:
replicas: 1
storage:
type: ephemeral
entityOperator:
topicOperator: {}
userOperator: {}
Loading

0 comments on commit 60127c8

Please sign in to comment.