Skip to content

Commit

Permalink
DBZ-6493 restructured spec.source to more extendable format
Browse files Browse the repository at this point in the history
  • Loading branch information
jcechace committed May 31, 2023
1 parent 3d04238 commit b730b91
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ spec:
# other sink properties
source:
class: String
# other source connector properties
config:
# other source connector properties
```
21 changes: 11 additions & 10 deletions examples/postgres/010_debezium-server-ephemeral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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



11 changes: 7 additions & 4 deletions k8/debeziumservers.debezium.io-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 11 additions & 13 deletions src/main/java/io/debezium/operator/model/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,7 +13,11 @@
public class Source implements ConfigMappable {

private String sourceClass;
private Map<String, Object> props = new HashMap<>(0);
private ConfigProperties config;

public Source() {
this.config = new ConfigProperties();
}

@JsonProperty("class")
public String getSourceClass() {
Expand All @@ -29,20 +28,19 @@ public void setSourceClass(String clazz) {
this.sourceClass = clazz;
}

@JsonAnyGetter
public Map<String, Object> 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;
}
}

0 comments on commit b730b91

Please sign in to comment.