From 0847cf53dea64dec1331f853045a2df626bc3dff Mon Sep 17 00:00:00 2001 From: Anand Inguva Date: Fri, 3 May 2024 17:43:43 -0400 Subject: [PATCH] Move secret name and password under if condition --- .../com/google/cloud/teleport/v2/templates/KafkaToGcs2.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/v2/kafka-to-gcs/src/main/java/com/google/cloud/teleport/v2/templates/KafkaToGcs2.java b/v2/kafka-to-gcs/src/main/java/com/google/cloud/teleport/v2/templates/KafkaToGcs2.java index 2860a8bc83..475d2cf2e8 100644 --- a/v2/kafka-to-gcs/src/main/java/com/google/cloud/teleport/v2/templates/KafkaToGcs2.java +++ b/v2/kafka-to-gcs/src/main/java/com/google/cloud/teleport/v2/templates/KafkaToGcs2.java @@ -244,14 +244,13 @@ public static PipelineResult run(KafkaToGcsOptions options) throws UnsupportedOp options.setStreaming(true); - String kafkaSaslPlainUserName = SecretManagerUtils.getSecret(options.getUserNameSecretID()); - String kafkaSaslPlainPassword = SecretManagerUtils.getSecret(options.getPasswordSecretID()); - Map kafkaConfig = new HashMap<>(); // Set offset to either earliest or latest. kafkaConfig.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, options.getOffset()); // Authenticate to Kafka only when user provides authentication params. if (useKafkaAuth) { + String kafkaSaslPlainUserName = SecretManagerUtils.getSecret(options.getUserNameSecretID()); + String kafkaSaslPlainPassword = SecretManagerUtils.getSecret(options.getPasswordSecretID()); kafkaConfig.putAll( ClientAuthConfig.getSaslPlainConfig(kafkaSaslPlainUserName, kafkaSaslPlainPassword)); }