Skip to content

Commit a68cbc7

Browse files
committed
Fix linter issues
1 parent 0bf5fc6 commit a68cbc7

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

cmd/application-load-balancer-controller-manager/main.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package main
1818

1919
import (
2020
"crypto/tls"
21+
"errors"
2122
"flag"
2223
"fmt"
2324
"io"
@@ -65,40 +66,34 @@ type Config struct {
6566
}
6667

6768
// ReadConfig reads the ALB infrastructure configuration provided via the cloud-config flag.
68-
func ReadConfig(cloudConfig string) Config {
69+
func ReadConfig(cloudConfig string) (Config, error) {
6970
configFile, err := os.Open(cloudConfig)
7071
if err != nil {
71-
setupLog.Error(err, "Failed to open the cloud config file")
72-
os.Exit(1)
72+
return Config{}, err
7373
}
7474
defer configFile.Close()
7575

7676
var config Config
7777
content, err := io.ReadAll(configFile)
7878
if err != nil {
79-
setupLog.Error(err, "Failed to read config content")
80-
os.Exit(1)
79+
return Config{}, err
8180
}
8281

8382
err = yaml.Unmarshal(content, &config)
8483
if err != nil {
85-
setupLog.Error(err, "Failed to parse config as YAML")
86-
os.Exit(1)
84+
return Config{}, err
8785
}
8886

8987
if config.ProjectID == "" {
90-
setupLog.Error(err, "projectId must be set")
91-
os.Exit(1)
88+
return Config{}, errors.New("project ID must be set")
9289
}
9390
if config.Region == "" {
94-
setupLog.Error(err, "region must be set")
95-
os.Exit(1)
91+
return Config{}, errors.New("region must be set")
9692
}
9793
if config.NetworkID == "" {
98-
setupLog.Error(err, "networkId must be set")
99-
os.Exit(1)
94+
return Config{}, errors.New("network ID must be set")
10095
}
101-
return config
96+
return config, nil
10297
}
10398

10499
// nolint:gocyclo,funlen // TODO: Refactor into smaller functions.
@@ -144,7 +139,11 @@ func main() {
144139

145140
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
146141

147-
config := ReadConfig(cloudConfig)
142+
config, err := ReadConfig(cloudConfig)
143+
if err != nil {
144+
setupLog.Error(err, "Failed to read cloud config")
145+
os.Exit(1)
146+
}
148147

149148
// if the enable-http2 flag is false (the default), http/2 should be disabled
150149
// due to its vulnerabilities. More specifically, disabling http/2 will

pkg/alb/ingress/ingressclass_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (r *IngressClassReconciler) handleIngressClassDeletion(
324324
}
325325

326326
// detectChange checks if there is any difference between the current and desired ALB configuration.
327-
func detectChange(alb *albsdk.LoadBalancer, albPayload *albsdk.CreateLoadBalancerPayload) bool { //nolint:gocyclo // We check a lot of fields. Not much complexity.
327+
func detectChange(alb *albsdk.LoadBalancer, albPayload *albsdk.CreateLoadBalancerPayload) bool { //nolint:gocyclo,funlen // We check a lot of fields. Not much complexity.
328328
if len(alb.Listeners) != len(albPayload.Listeners) {
329329
return true
330330
}

0 commit comments

Comments
 (0)