From 3ef0bb5ce7ae2dc9d77ad521b412e421368cd00d Mon Sep 17 00:00:00 2001 From: Matt Bush Date: Thu, 13 Jul 2023 18:11:56 -0700 Subject: [PATCH] add connection details for cluster.kafka --- config/kafka/config.go | 34 ++++++++++++++++++++++++++++++++++ examples/kafka/cluster.yaml | 3 +++ 2 files changed, 37 insertions(+) diff --git a/config/kafka/config.go b/config/kafka/config.go index c236b448d7..58f580cf2f 100644 --- a/config/kafka/config.go +++ b/config/kafka/config.go @@ -26,5 +26,39 @@ func Configure(p *config.Provider) { Type: "github.com/upbound/provider-aws/apis/ec2/v1beta1.SecurityGroup", } r.UseAsync = true + r.Sensitive.AdditionalConnectionDetailsFn = func(attr map[string]any) (map[string][]byte, error) { + conn := map[string][]byte{} + if a, ok := attr["bootstrap_brokers"].(string); ok { + conn["bootstrap_brokers"] = []byte(a) + } + if a, ok := attr["bootstrap_brokers_sasl_iam"].(string); ok { + conn["bootstrap_brokers_sasl_iam"] = []byte(a) + } + if a, ok := attr["bootstrap_brokers_sasl_scram"].(string); ok { + conn["bootstrap_brokers_sasl_scram"] = []byte(a) + } + if a, ok := attr["bootstrap_brokers_tls"].(string); ok { + conn["bootstrap_brokers_tls"] = []byte(a) + } + if a, ok := attr["bootstrap_brokers_public"].(string); ok { + conn["bootstrap_brokers_public"] = []byte(a) + } + if a, ok := attr["bootstrap_brokers_public_sasl_iam"].(string); ok { + conn["bootstrap_brokers_public_sasl_iam"] = []byte(a) + } + if a, ok := attr["bootstrap_brokers_public_sasl_scram"].(string); ok { + conn["bootstrap_brokers_public_sasl_scram"] = []byte(a) + } + if a, ok := attr["bootstrap_brokers_public_tls"].(string); ok { + conn["bootstrap_brokers_public_tls"] = []byte(a) + } + if a, ok := attr["zookeeper_connect_string"].(string); ok { + conn["zookeeper_connect_string"] = []byte(a) + } + if a, ok := attr["zookeeper_connect_string_tls"].(string); ok { + conn["zookeeper_connect_string_tls"] = []byte(a) + } + return conn, nil + } }) } diff --git a/examples/kafka/cluster.yaml b/examples/kafka/cluster.yaml index 65045681c1..db1e0675ef 100644 --- a/examples/kafka/cluster.yaml +++ b/examples/kafka/cluster.yaml @@ -39,6 +39,9 @@ spec: region: us-west-1 tags: foo: bar + writeConnectionSecretToRef: + name: example-msk-cluster + namespace: upbound-system ---