Skip to content

Commit

Permalink
Remove KafkaCAPath check
Browse files Browse the repository at this point in the history
  • Loading branch information
r14chandra committed Apr 25, 2024
1 parent 1f380c8 commit 0a60708
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions internal/util/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ type kafkautil struct{}
func (k kafkautil) NewReader(topic string) *kafka.Reader {
var dialer *kafka.Dialer

if config.DefaultConfig.KafkaCAPath != "" {
saslMechanism, tlsConfig := getSaslAndTLSConfig()
dialer = &kafka.Dialer{
Timeout: 10 * time.Second,
DualStack: true,
TLS: tlsConfig,
}
if config.DefaultConfig.KafkaUsername != "" && config.DefaultConfig.KafkaPassword != "" {
dialer.SASLMechanism = saslMechanism
}
saslMechanism, tlsConfig := getSaslAndTLSConfig()
dialer = &kafka.Dialer{
Timeout: 10 * time.Second,
DualStack: true,
TLS: tlsConfig,
}
if config.DefaultConfig.KafkaUsername != "" && config.DefaultConfig.KafkaPassword != "" {
dialer.SASLMechanism = saslMechanism
}

return kafka.NewReader(kafka.ReaderConfig{
Expand All @@ -49,15 +47,12 @@ func (k kafkautil) NewReader(topic string) *kafka.Reader {
func (k kafkautil) NewWriter(topic string) *kafka.Writer {
var transport *kafka.Transport = kafka.DefaultTransport.(*kafka.Transport)

Check failure on line 48 in internal/util/kafka.go

View workflow job for this annotation

GitHub Actions / Lint code

ineffectual assignment to transport (ineffassign)

if config.DefaultConfig.KafkaCAPath != "" {
saslMechanism, tlsConfig := getSaslAndTLSConfig()

transport = &kafka.Transport{
TLS: tlsConfig,
}
if config.DefaultConfig.KafkaUsername != "" && config.DefaultConfig.KafkaPassword != "" {
transport.SASL = saslMechanism
}
saslMechanism, tlsConfig := getSaslAndTLSConfig()
transport = &kafka.Transport{
TLS: tlsConfig,
}
if config.DefaultConfig.KafkaUsername != "" && config.DefaultConfig.KafkaPassword != "" {
transport.SASL = saslMechanism
}

return &kafka.Writer{
Expand Down

0 comments on commit 0a60708

Please sign in to comment.