Skip to content

Commit

Permalink
[CLOUDTRUST-3991] Parametrize TLS for kafka (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
basbeu committed May 31, 2023
1 parent 45efd7b commit 203e7a6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion events/kafkaproducer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type KafkaProducerConfig struct {
ClientSecret string
TokenURL string
Noop bool
TLSEnabled bool
}

// GetKafkaProducerConfig gets a KafkaProducerConfig
Expand All @@ -31,6 +32,7 @@ func GetKafkaProducerConfig(c cs.Configuration, prefix string) KafkaProducerConf
cfg.ClientID = c.GetString(prefix + "-client-id")
cfg.ClientSecret = c.GetString(prefix + "-client-secret")
cfg.TokenURL = c.GetString(prefix + "-token-url")
cfg.TLSEnabled = c.GetBool(prefix + "-tls-enabled")
}

return cfg
Expand All @@ -57,7 +59,7 @@ func NewEventKafkaProducer(ctx context.Context, c KafkaProducerConfig, logger lo
config.Net.SASL.Mechanism = sarama.SASLTypeOAuth
config.Net.SASL.TokenProvider = NewTokenProvider(c.ClientID, c.ClientSecret, c.TokenURL)

config.Net.TLS.Enable = true
config.Net.TLS.Enable = c.TLSEnabled

producer, err := sarama.NewSyncProducer(c.Brokers, config)
if err != nil {
Expand Down

0 comments on commit 203e7a6

Please sign in to comment.