Skip to content

Commit d04c967

Browse files
committed
fix error handling, fix lint issues and tidy go.mod
Signed-off-by: Omar Farag <[email protected]>
1 parent f08569f commit d04c967

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

cmd/operator-controller/main.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ var (
8282
)
8383

8484
type config struct {
85-
metricsAddr string
86-
certFile string
87-
keyFile string
88-
enableLeaderElection bool
89-
probeAddr string
90-
cachePath string
91-
systemNamespace string
92-
catalogdCasDir string
93-
pullCasDir string
94-
globalPullSecret string
85+
metricsAddr string
86+
certFile string
87+
keyFile string
88+
enableLeaderElection bool
89+
probeAddr string
90+
cachePath string
91+
systemNamespace string
92+
catalogdCasDir string
93+
pullCasDir string
94+
globalPullSecret string
9595
}
9696

9797
const authFilePrefix = "operator-controller-global-pull-secrets"
@@ -113,7 +113,7 @@ var operatorControllerCmd = &cobra.Command{
113113
Short: "operator-controller is the central component of Operator Lifecycle Manager (OLM) v1",
114114
RunE: func(cmd *cobra.Command, args []string) error {
115115
if err := validateMetricsFlags(); err != nil {
116-
return fmt.Errorf("Error: %v\n", err)
116+
return err
117117
}
118118
return run()
119119
},
@@ -128,7 +128,6 @@ var versionCommand = &cobra.Command{
128128
}
129129

130130
func init() {
131-
132131
//create flagset, the collection of flags for this command
133132
flags := operatorControllerCmd.Flags()
134133
flags.StringVar(&cfg.metricsAddr, "metrics-bind-address", "", "The address for the metrics endpoint. Requires tls-cert and tls-key. (Default: ':8443')")
@@ -157,7 +156,6 @@ func init() {
157156

158157
//add feature gate flags to flagset
159158
features.OperatorControllerFeatureGate.AddFlag(flags)
160-
161159
}
162160
func validateMetricsFlags() error {
163161
if (cfg.certFile != "" && cfg.keyFile == "") || (cfg.certFile == "" && cfg.keyFile != "") {
@@ -485,7 +483,8 @@ func run() error {
485483
}
486484

487485
func main() {
488-
489-
operatorControllerCmd.Execute()
490-
486+
if err := operatorControllerCmd.Execute(); err != nil {
487+
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
488+
os.Exit(1)
489+
}
491490
}

0 commit comments

Comments
 (0)