From b730b91968e4775379188645a365eaaf4b459795 Mon Sep 17 00:00:00 2001 From: jcechace Date: Wed, 31 May 2023 18:31:58 +0200 Subject: [PATCH] DBZ-6493 restructured spec.source to more extendable format --- README.md | 3 ++- .../010_debezium-server-ephemeral.yml | 21 ++++++++-------- k8/debeziumservers.debezium.io-v1.yml | 11 +++++---- .../io/debezium/operator/model/Source.java | 24 +++++++++---------- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 28db480..8b41bbe 100644 --- a/README.md +++ b/README.md @@ -57,5 +57,6 @@ spec: # other sink properties source: class: String - # other source connector properties + config: + # other source connector properties ``` \ No newline at end of file diff --git a/examples/postgres/010_debezium-server-ephemeral.yml b/examples/postgres/010_debezium-server-ephemeral.yml index 7c05c40..a3a4395 100644 --- a/examples/postgres/010_debezium-server-ephemeral.yml +++ b/examples/postgres/010_debezium-server-ephemeral.yml @@ -18,16 +18,17 @@ spec: producer.value.serializer: org.apache.kafka.common.serialization.StringSerializer source: class: io.debezium.connector.postgresql.PostgresConnector - tasks.max: - offset.storage.file.filename: /debezium/data/offsets.dat - database.history: io.debezium.relational.history.FileDatabaseHistory - database.hostname: postgresql - database.port: 5432 - database.user: ${POSTGRES_USER} - database.password: ${POSTGRES_PASSWORD} - database.dbname: ${POSTGRES_DB} - topic.prefix: inventory - schema.include.list: inventory + config: + tasks.max: + offset.storage.file.filename: /debezium/data/offsets.dat + database.history: io.debezium.relational.history.FileDatabaseHistory + database.hostname: postgresql + database.port: 5432 + database.user: ${POSTGRES_USER} + database.password: ${POSTGRES_PASSWORD} + database.dbname: ${POSTGRES_DB} + topic.prefix: inventory + schema.include.list: inventory \ No newline at end of file diff --git a/k8/debeziumservers.debezium.io-v1.yml b/k8/debeziumservers.debezium.io-v1.yml index 24c5d6e..ccd2420 100644 --- a/k8/debeziumservers.debezium.io-v1.yml +++ b/k8/debeziumservers.debezium.io-v1.yml @@ -765,13 +765,16 @@ spec: properties: class: 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 format: properties: key: diff --git a/src/main/java/io/debezium/operator/model/Source.java b/src/main/java/io/debezium/operator/model/Source.java index f1ef1b7..8f5def7 100644 --- a/src/main/java/io/debezium/operator/model/Source.java +++ b/src/main/java/io/debezium/operator/model/Source.java @@ -5,11 +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 com.fasterxml.jackson.annotation.JsonProperty; import io.debezium.operator.config.ConfigMappable; @@ -18,7 +13,11 @@ public class Source implements ConfigMappable { private String sourceClass; - private Map props = new HashMap<>(0); + private ConfigProperties config; + + public Source() { + this.config = new ConfigProperties(); + } @JsonProperty("class") public String getSourceClass() { @@ -29,20 +28,19 @@ public void setSourceClass(String clazz) { this.sourceClass = clazz; } - @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); + var config = ConfigMapping.empty(); config.put("connector.class", sourceClass); + config.put(this.config); return config; } }