Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
paulzhang97 committed Nov 22, 2023
1 parent 3eb596b commit ddba7d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
36 changes: 18 additions & 18 deletions src/go/k8s/cmd/configurator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
}
Expand All @@ -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,
})
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/go/k8s/cmd/configurator/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/go/k8s/pkg/resources/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ddba7d1

Please sign in to comment.