Skip to content

Commit

Permalink
fix: Resolved issue with kafka secret not returning SASL and TLS (#628)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Olafsen <[email protected]>
  • Loading branch information
krise86 committed Jul 25, 2022
1 parent 0b07bb3 commit c8eb9f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 9 additions & 2 deletions runner/sidecar/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ func kafkaFromSecret(k *dfv1.Kafka, secret *corev1.Secret) error {

tls := tlsFromSecret(secret)
sasl := saslFromSecret(secret)

if tls == nil && sasl == nil {
return nil
}

k.NET = &dfv1.KafkaNET{}

if tls != nil {
k.NET = &dfv1.KafkaNET{TLS: tls}
k.NET.TLS = tls
}
if sasl != nil {
k.NET = &dfv1.KafkaNET{SASL: sasl}
k.NET.SASL = sasl
}
return nil
}
Expand Down
15 changes: 15 additions & 0 deletions runner/sidecar/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ func Test_kafkaFromSecret(t *testing.T) {
assert.NotNil(t, x.NET.SASL)
}
})
t.Run("NetSASLAndTLS", func(t *testing.T) {
x := &dfv1.Kafka{}
err := kafkaFromSecret(x, &corev1.Secret{
Data: map[string][]byte{
"net.sasl.user": []byte(""),
"net.sasl.password": []byte(""),
"net.tls.caCert": []byte(""),
},
})
assert.NoError(t, err)
if assert.NotNil(t, x.NET) {
assert.NotNil(t, x.NET.SASL)
assert.NotNil(t, x.NET.TLS)
}
})
}

func Test_enrichKafka(t *testing.T) {
Expand Down

0 comments on commit c8eb9f7

Please sign in to comment.