diff --git a/src/go/k8s/cmd/configurator/main.go b/src/go/k8s/cmd/configurator/main.go index 2cbf36278..3c8f6dc1b 100644 --- a/src/go/k8s/cmd/configurator/main.go +++ b/src/go/k8s/cmd/configurator/main.go @@ -593,24 +593,24 @@ func setAdditionalListeners(additionalListenersCfg, hostIP string, hostIndex int if len(nodeConfig.Redpanda.AdvertisedKafkaAPI) > 0 { cfg.Redpanda.AdvertisedKafkaAPI = append(cfg.Redpanda.AdvertisedKafkaAPI, nodeConfig.Redpanda.AdvertisedKafkaAPI...) // Assume that the advertised kafka api use the same TLS configuration as the default external one. - var serverTlsCfg *config.ServerTLS + var serverTLSCfg *config.ServerTLS for i := 0; i < len(cfg.Redpanda.KafkaAPITLS); i++ { tlsCfg := &cfg.Redpanda.KafkaAPITLS[i] if tlsCfg.Name == resources.ExternalListenerName { - serverTlsCfg = tlsCfg + serverTLSCfg = tlsCfg break } } - if serverTlsCfg != nil { + if serverTLSCfg != nil { for i := 0; i < len(nodeConfig.Redpanda.AdvertisedKafkaAPI); i++ { cfg.Redpanda.KafkaAPITLS = append(cfg.Redpanda.KafkaAPITLS, config.ServerTLS{ Name: nodeConfig.Redpanda.AdvertisedKafkaAPI[i].Name, - Enabled: serverTlsCfg.Enabled, - CertFile: serverTlsCfg.CertFile, - KeyFile: serverTlsCfg.KeyFile, - TruststoreFile: serverTlsCfg.TruststoreFile, - RequireClientAuth: serverTlsCfg.RequireClientAuth, - Other: serverTlsCfg.Other, + Enabled: serverTLSCfg.Enabled, + CertFile: serverTLSCfg.CertFile, + KeyFile: serverTLSCfg.KeyFile, + TruststoreFile: serverTLSCfg.TruststoreFile, + RequireClientAuth: serverTLSCfg.RequireClientAuth, + Other: serverTLSCfg.Other, }) } } @@ -633,24 +633,24 @@ func setAdditionalListeners(additionalListenersCfg, hostIP string, hostIndex int cfg.Pandaproxy.AdvertisedPandaproxyAPI = append(cfg.Pandaproxy.AdvertisedPandaproxyAPI, nodeConfig.Pandaproxy.AdvertisedPandaproxyAPI...) // Assume that the advertised panda proxies use the same TLS configuration as the default external one. - var serverTlsCfg *config.ServerTLS + var serverTLSCfg *config.ServerTLS for i := 0; i < len(cfg.Pandaproxy.PandaproxyAPITLS); i++ { tlsCfg := &cfg.Pandaproxy.PandaproxyAPITLS[i] if tlsCfg.Name == resources.PandaproxyPortExternalName { - serverTlsCfg = tlsCfg + serverTLSCfg = tlsCfg break } } - if serverTlsCfg != nil { + if serverTLSCfg != nil { for i := 0; i < len(nodeConfig.Pandaproxy.AdvertisedPandaproxyAPI); i++ { cfg.Pandaproxy.PandaproxyAPITLS = append(cfg.Pandaproxy.PandaproxyAPITLS, config.ServerTLS{ Name: nodeConfig.Pandaproxy.AdvertisedPandaproxyAPI[i].Name, - Enabled: serverTlsCfg.Enabled, - CertFile: serverTlsCfg.CertFile, - KeyFile: serverTlsCfg.KeyFile, - TruststoreFile: serverTlsCfg.TruststoreFile, - RequireClientAuth: serverTlsCfg.RequireClientAuth, - Other: serverTlsCfg.Other, + Enabled: serverTLSCfg.Enabled, + CertFile: serverTLSCfg.CertFile, + KeyFile: serverTLSCfg.KeyFile, + TruststoreFile: serverTLSCfg.TruststoreFile, + RequireClientAuth: serverTLSCfg.RequireClientAuth, + Other: serverTLSCfg.Other, }) } } diff --git a/src/go/k8s/cmd/configurator/main_test.go b/src/go/k8s/cmd/configurator/main_test.go index 329ff6da4..88e52959f 100644 --- a/src/go/k8s/cmd/configurator/main_test.go +++ b/src/go/k8s/cmd/configurator/main_test.go @@ -35,7 +35,7 @@ func TestPopulateRack(t *testing.T) { } } -func TestAdditionalListeners(t *testing.T) { +func TestAdditionalListeners(t *testing.T) { //nolint sasl := "sasl" tests := []struct { name string @@ -246,7 +246,8 @@ func TestAdditionalListeners(t *testing.T) { }, }, } - for _, tt := range tests { + for i := 0; i < len(tests); i++ { + tt := &tests[i] err := setAdditionalListeners(tt.addtionalListenersCfg, tt.hostIP, tt.hostIndex, &tt.nodeCfg) if tt.expectedError { assert.Error(t, err) diff --git a/src/go/k8s/pkg/resources/statefulset.go b/src/go/k8s/pkg/resources/statefulset.go index 5921b6426..f04353358 100644 --- a/src/go/k8s/pkg/resources/statefulset.go +++ b/src/go/k8s/pkg/resources/statefulset.go @@ -888,7 +888,7 @@ func (r *StatefulSetResource) getPorts() []corev1.ContainerPort { return ports } -// additionalListenersEnvVars returns the env var containing the additioanl listeners specified in additionalConfiguration. +// AdditionalListenersEnvVars returns the env var containing the additioanl listeners specified in additionalConfiguration. func (r *StatefulSetResource) AdditionalListenersEnvVars() []corev1.EnvVar { if len(r.pandaCluster.Spec.AdditionalConfiguration) == 0 { return nil