From db7d374fef4ba8777414671afef74516b0e3ccf9 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 --- k8/debeziumservers.debezium.io-v1.yml | 57 ++++++++++++------- .../debezium/operator/model/FormatType.java | 23 +++----- .../io/debezium/operator/model/Predicate.java | 28 +++++---- .../io/debezium/operator/model/Quarkus.java | 28 +-------- .../operator/model/Transformation.java | 27 +++------ 5 files changed, 65 insertions(+), 98 deletions(-) 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/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..461d8e2 100644 --- a/src/main/java/io/debezium/operator/model/Quarkus.java +++ b/src/main/java/io/debezium/operator/model/Quarkus.java @@ -5,31 +5,5 @@ */ 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 Map props = new HashMap<>(0); - - @JsonAnyGetter - public Map getProps() { - return props; - } - - @JsonAnySetter - public void setProps(String name, Object value) { - getProps().put(name, value); - } - - @Override - public ConfigMapping asConfiguration() { - return ConfigMapping.from(props); - } +public class Quarkus extends ConfigProperties { } 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; } }