Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private ManagerConfig generateStateManagerConfig() {
.setDeleteDisabled(parent.isDeleteDisabled())
.setIncludeUnchangedEnabled(false)
.setSkipAclsDisabled(parent.areAclsDisabled())
.setConfigFile(parent.getConfigFile())
.setNullableConfigFile(parent.getConfigFile())
.setStateFile(parent.getStateFile())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private ManagerConfig generateStateManagerConfig() {
.setDeleteDisabled(parent.isDeleteDisabled())
.setIncludeUnchangedEnabled(false)
.setSkipAclsDisabled(parent.areAclsDisabled())
.setConfigFile(parent.getConfigFile())
.setNullableConfigFile(parent.getConfigFile())
.setStateFile(parent.getStateFile())
.setNullablePlanFile(planFile)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private ManagerConfig generateStateManagerConfig() {
.setVerboseRequested(parent.isVerboseRequested())
.setDeleteDisabled(parent.isDeleteDisabled())
.setIncludeUnchangedEnabled(includeUnchanged)
.setConfigFile(parent.getConfigFile())
.setNullableConfigFile(parent.getConfigFile())
.setStateFile(parent.getStateFile())
.setSkipAclsDisabled(parent.areAclsDisabled())
.setNullablePlanFile(outputFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private ManagerConfig generateStateManagerConfig() {
.setDeleteDisabled(parent.isDeleteDisabled())
.setIncludeUnchangedEnabled(false)
.setSkipAclsDisabled(parent.areAclsDisabled())
.setConfigFile(parent.getConfigFile())
.setNullableConfigFile(parent.getConfigFile())
.setStateFile(parent.getStateFile())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static void setConfigFromFile(File configFile, KafkaGitopsConfig.Builder
if (configFile == null) {
return;
}
try(InputStream inputStream = new FileInputStream(configFile)) {
try (InputStream inputStream = new FileInputStream(configFile)) {
Properties properties = new Properties();
properties.load(inputStream);
properties.forEach( (k, v) -> builder.putConfig(k.toString(), v));
Expand All @@ -60,21 +60,21 @@ private static void setConfigFromEnvironment(KafkaGitopsConfig.Builder builder)
}
});

handleDefaultConfig(config);
handleAuthentication(username, password, config);

log.info("Kafka Config: {}", config);

builder.putAllConfig(config);
handleDefaultConfig(builder);
}

private static void handleDefaultConfig(Map<String, Object> config) {
if (!config.containsKey(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG)) {
config.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
private static void handleDefaultConfig(KafkaGitopsConfig.Builder builder) {
if (!builder.getConfig().containsKey(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG)) {
builder.putConfig(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
}

if (!config.containsKey(CommonClientConfigs.CLIENT_ID_CONFIG)) {
config.put(CommonClientConfigs.CLIENT_ID_CONFIG, "kafka-gitops");
if (!builder.getConfig().containsKey(CommonClientConfigs.CLIENT_ID_CONFIG)) {
builder.putConfig(CommonClientConfigs.CLIENT_ID_CONFIG, "kafka-gitops");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface ManagerConfig {

boolean isSkipAclsDisabled();

File getConfigFile();
Optional<File> getConfigFile();

File getStateFile();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ class KafkaGitopsConfigLoaderSpec extends Specification {
void 'test command config file'() {
setup:
File configFile = new File(getClass().getResource("/command.properties").toURI())
environmentVariables.clear("KAFKA_BOOTSTRAP_SERVERS")

when:
KafkaGitopsConfig config = KafkaGitopsConfigLoader.load(configFile)

then:
config.config.get(CommonClientConfigs.CLIENT_ID_CONFIG) == "kafka-gitops"
config.config.get(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG) == "localhost:9092"
config.config.get(CommonClientConfigs.CLIENT_ID_CONFIG) == "kafka-client-id"
config.config.get(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG) == "example.com:9092"
config.config.get(SaslConfigs.SASL_MECHANISM) == "PLAIN"
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/command.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bootstrap.servers=commande.9092
client.id=kafka-gitops
bootstrap.servers=example.com:9092
client.id=kafka-client-id