Skip to content

Commit

Permalink
Move secret name and password under if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandInguva committed May 3, 2024
1 parent 634fb33 commit 0847cf5
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> 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());

Check warning on line 253 in v2/kafka-to-gcs/src/main/java/com/google/cloud/teleport/v2/templates/KafkaToGcs2.java

View check run for this annotation

Codecov / codecov/patch

v2/kafka-to-gcs/src/main/java/com/google/cloud/teleport/v2/templates/KafkaToGcs2.java#L252-L253

Added lines #L252 - L253 were not covered by tests
kafkaConfig.putAll(
ClientAuthConfig.getSaslPlainConfig(kafkaSaslPlainUserName, kafkaSaslPlainPassword));
}
Expand Down

0 comments on commit 0847cf5

Please sign in to comment.