From e51ab27be2a53d86466130dd782343c9b49fd07c Mon Sep 17 00:00:00 2001 From: jcechace Date: Fri, 2 Jun 2023 00:56:00 +0200 Subject: [PATCH] DBZ-6493 refactored dynamic properties of all subresources into config property --- .../010_debezium-server-ephemeral.yml | 17 ++++-- k8/debeziumservers.debezium.io-v1.yml | 57 ++++++++++++------- .../dependent/DeploymentDependent.java | 2 +- .../debezium/operator/model/FormatType.java | 23 +++----- .../io/debezium/operator/model/Predicate.java | 28 +++++---- .../io/debezium/operator/model/Quarkus.java | 25 ++++---- .../operator/model/Transformation.java | 27 +++------ 7 files changed, 87 insertions(+), 92 deletions(-) diff --git a/examples/postgres/010_debezium-server-ephemeral.yml b/examples/postgres/010_debezium-server-ephemeral.yml index a3a4395..8ae1c4c 100644 --- a/examples/postgres/010_debezium-server-ephemeral.yml +++ b/examples/postgres/010_debezium-server-ephemeral.yml @@ -7,9 +7,10 @@ spec: storage: type: ephemeral quarkus: - log.console.json: false - kubernetes-config.enabled: true - kubernetes-config.secrets: postgresql-credentials + config: + log.console.json: false + kubernetes-config.enabled: true + kubernetes-config.secrets: postgresql-credentials sink: type: kafka config: @@ -29,6 +30,10 @@ spec: database.dbname: ${POSTGRES_DB} topic.prefix: inventory schema.include.list: inventory - - - \ No newline at end of file + format: + value: + type: json + config: + schemas.enable: false + key: + type: json diff --git a/k8/debeziumservers.debezium.io-v1.yml b/k8/debeziumservers.debezium.io-v1.yml index ccd2420..5d9c6f1 100644 --- a/k8/debeziumservers.debezium.io-v1.yml +++ b/k8/debeziumservers.debezium.io-v1.yml @@ -701,13 +701,16 @@ spec: type: string type: type: string - props: - additionalProperties: - type: object + config: + properties: + props: + additionalProperties: + type: object + type: object + x-kubernetes-preserve-unknown-fields: true type: object x-kubernetes-preserve-unknown-fields: true type: object - x-kubernetes-preserve-unknown-fields: true type: array sink: properties: @@ -730,13 +733,16 @@ spec: type: string type: type: string - props: - additionalProperties: - type: object + config: + properties: + props: + additionalProperties: + type: object + type: object + x-kubernetes-preserve-unknown-fields: true type: object x-kubernetes-preserve-unknown-fields: true type: object - x-kubernetes-preserve-unknown-fields: true type: array storage: properties: @@ -758,9 +764,7 @@ spec: additionalProperties: type: object type: object - x-kubernetes-preserve-unknown-fields: true type: object - x-kubernetes-preserve-unknown-fields: true source: properties: class: @@ -781,35 +785,44 @@ spec: properties: type: type: string - props: - additionalProperties: - type: object + config: + properties: + props: + additionalProperties: + type: object + type: object + x-kubernetes-preserve-unknown-fields: true type: object x-kubernetes-preserve-unknown-fields: true type: object - x-kubernetes-preserve-unknown-fields: true value: properties: type: type: string - props: - additionalProperties: - type: object + config: + properties: + props: + additionalProperties: + type: object + type: object + x-kubernetes-preserve-unknown-fields: true type: object x-kubernetes-preserve-unknown-fields: true type: object - x-kubernetes-preserve-unknown-fields: true header: properties: type: type: string - props: - additionalProperties: - type: object + config: + properties: + props: + additionalProperties: + type: object + type: object + x-kubernetes-preserve-unknown-fields: true type: object x-kubernetes-preserve-unknown-fields: true type: object - x-kubernetes-preserve-unknown-fields: true type: object type: object status: diff --git a/src/main/java/io/debezium/operator/dependent/DeploymentDependent.java b/src/main/java/io/debezium/operator/dependent/DeploymentDependent.java index 4c7c88c..7ae4d78 100644 --- a/src/main/java/io/debezium/operator/dependent/DeploymentDependent.java +++ b/src/main/java/io/debezium/operator/dependent/DeploymentDependent.java @@ -80,7 +80,7 @@ protected Deployment desired(DebeziumServer primary, Context con .orElseThrow(); var quarkus = primary.getSpec().getQuarkus(); - var probePort = quarkus.getProps().getOrDefault("http.port", 8080); + var probePort = quarkus.getConfig().getProps().getOrDefault("http.port", 8080); var deployment = new DeploymentBuilder() .withMetadata(new ObjectMetaBuilder() diff --git a/src/main/java/io/debezium/operator/model/FormatType.java b/src/main/java/io/debezium/operator/model/FormatType.java index bb0576d..b15cd6a 100644 --- a/src/main/java/io/debezium/operator/model/FormatType.java +++ b/src/main/java/io/debezium/operator/model/FormatType.java @@ -5,12 +5,6 @@ */ package io.debezium.operator.model; -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; - import io.debezium.operator.config.ConfigMappable; import io.debezium.operator.config.ConfigMapping; @@ -18,21 +12,19 @@ public class FormatType implements ConfigMappable { private String type; - private final Map props; + private ConfigProperties config; public FormatType() { type = "json"; - props = new HashMap<>(0); + this.config = new ConfigProperties(); } - @JsonAnyGetter - public Map getProps() { - return props; + public ConfigProperties getConfig() { + return config; } - @JsonAnySetter - public void setProps(String name, Object value) { - getProps().put(name, value); + public void setConfig(ConfigProperties config) { + this.config = config; } public String getType() { @@ -45,7 +37,8 @@ public void setType(String type) { @Override public ConfigMapping asConfiguration() { - var config = ConfigMapping.from(props); + var config = ConfigMapping.empty(); + config.put(this.config); config.rootValue(type); return config; } diff --git a/src/main/java/io/debezium/operator/model/Predicate.java b/src/main/java/io/debezium/operator/model/Predicate.java index 6f6d393..bd9df09 100644 --- a/src/main/java/io/debezium/operator/model/Predicate.java +++ b/src/main/java/io/debezium/operator/model/Predicate.java @@ -5,12 +5,6 @@ */ package io.debezium.operator.model; -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; - import io.debezium.operator.config.ConfigMappable; import io.debezium.operator.config.ConfigMapping; @@ -18,7 +12,11 @@ public class Predicate implements ConfigMappable { private String name; private String type; - private Map props = new HashMap<>(0); + private ConfigProperties config; + + public Predicate() { + this.config = new ConfigProperties(); + } public String getName() { return name; @@ -36,20 +34,20 @@ public void setType(String type) { this.type = type; } - @JsonAnyGetter - public Map getProps() { - return props; + public ConfigProperties getConfig() { + return config; } - @JsonAnySetter - public void setProps(String name, Object value) { - getProps().put(name, value); + public void setConfig(ConfigProperties config) { + this.config = config; } @Override public ConfigMapping asConfiguration() { - var config = ConfigMapping.from(props); - config.rootValue(type); + var config = ConfigMapping.prefixed(name); + config.put("type", type); + config.put(this.config); return config; + } } diff --git a/src/main/java/io/debezium/operator/model/Quarkus.java b/src/main/java/io/debezium/operator/model/Quarkus.java index 510b4bf..45919d4 100644 --- a/src/main/java/io/debezium/operator/model/Quarkus.java +++ b/src/main/java/io/debezium/operator/model/Quarkus.java @@ -5,31 +5,28 @@ */ package io.debezium.operator.model; -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; - import io.debezium.operator.config.ConfigMappable; import io.debezium.operator.config.ConfigMapping; public class Quarkus implements ConfigMappable { + private ConfigProperties config; - private Map props = new HashMap<>(0); + public Quarkus() { + this.config = new ConfigProperties(); + } - @JsonAnyGetter - public Map getProps() { - return props; + public ConfigProperties getConfig() { + return config; } - @JsonAnySetter - public void setProps(String name, Object value) { - getProps().put(name, value); + public void setConfig(ConfigProperties config) { + this.config = config; } @Override public ConfigMapping asConfiguration() { - return ConfigMapping.from(props); + var config = ConfigMapping.empty(); + config.putAll(this.config); + return config; } } diff --git a/src/main/java/io/debezium/operator/model/Transformation.java b/src/main/java/io/debezium/operator/model/Transformation.java index 60d2dcc..f1d67a1 100644 --- a/src/main/java/io/debezium/operator/model/Transformation.java +++ b/src/main/java/io/debezium/operator/model/Transformation.java @@ -5,12 +5,6 @@ */ package io.debezium.operator.model; -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; - import io.debezium.operator.config.ConfigMappable; import io.debezium.operator.config.ConfigMapping; @@ -20,7 +14,7 @@ public class Transformation implements ConfigMappable { private String type; private String predicate; private boolean negate = false; - private Map props = new HashMap<>(0); + private ConfigProperties config; public String getName() { return name; @@ -30,10 +24,6 @@ public void setName(String name) { this.name = name; } - public void setProps(Map props) { - this.props = props; - } - public String getType() { return type; } @@ -58,22 +48,21 @@ public void setNegate(boolean negate) { this.negate = negate; } - @JsonAnyGetter - public Map getProps() { - return props; + public ConfigProperties getConfig() { + return config; } - @JsonAnySetter - public void setProps(String name, Object value) { - getProps().put(name, value); + public void setConfig(ConfigProperties config) { + this.config = config; } @Override public ConfigMapping asConfiguration() { - var config = ConfigMapping.from(props); - config.rootValue(type); + var config = ConfigMapping.empty(); + config.put("type", type); config.put("predicate", predicate); config.put("negate", negate); + config.put(this.config); return config; } }