Skip to content

Commit

Permalink
fix gocritic linter
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Ramlot <[email protected]>
  • Loading branch information
inteon committed Apr 3, 2024
1 parent cae6bb8 commit 1578a57
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ issues:
- linters:
- gosec
- errorlint
- gocritic
- goimports
text: ".*"
linters:
Expand Down
35 changes: 24 additions & 11 deletions examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,23 @@ func main() {
klog.SetLogger(logr)
ctrl.SetLogger(logr)

if err := run(
clusterResourceNamespace,
metricsAddr,
enableLeaderElection,
probeAddr,
); err != nil {
logr.Error(err, "error running manager")
os.Exit(1)
}
}

func run(
clusterResourceNamespace string,
metricsAddr string,
enableLeaderElection bool,
probeAddr string,
) error {
setupLog := ctrl.Log.WithName("setup")

setupLog.Info("versionInfo", "Version", Version)
Expand All @@ -123,7 +140,6 @@ func main() {
} else {
setupLog.Error(err, "unexpected error while getting in-cluster Namespace")
}
os.Exit(1)
}

scheme := runtime.NewScheme()
Expand Down Expand Up @@ -159,30 +175,27 @@ func main() {

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options)
if err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
return fmt.Errorf("unable to start manager: %w", err)
}

if err = (&controller.Signer{}).SetupWithManager(ctx, mgr); err != nil {
setupLog.Error(err, "unable to create controller")
os.Exit(1)
return fmt.Errorf("unable to create controller: %w", err)
}
// +kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
os.Exit(1)
return fmt.Errorf("unable to set up health check: %w", err)
}
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up ready check")
os.Exit(1)
return fmt.Errorf("unable to set up ready check: %w", err)
}

setupLog.Info("starting manager")
if err := mgr.Start(ctx); err != nil {
setupLog.Error(err, "problem running manager")
os.Exit(1)
return fmt.Errorf("problem running manager: %w", err)
}

return nil
}

var errNotInCluster = errors.New("not running in-cluster")
Expand Down

0 comments on commit 1578a57

Please sign in to comment.