From 0504bf7178421668ee9bad224436a476eea064f0 Mon Sep 17 00:00:00 2001 From: Cindy Bang Date: Tue, 6 Feb 2024 14:49:44 -0500 Subject: [PATCH] fixup! Create and delete machines via controller (#36) --- cmd/main.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 5e30a5726..a1353b226 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -55,17 +55,16 @@ func init() { } func main() { - linodeToken := os.Getenv("LINODE_TOKEN") - if linodeToken == "" { - setupLog.Error(errors.New("failed to get LINODE_TOKEN environment variable"), "unable to start operator") - os.Exit(1) - } - - var machineWatchFilter string - var clusterWatchFilter string - var metricsAddr string - var enableLeaderElection bool - var probeAddr string + var ( + // Environment variables + linodeToken string = os.Getenv("LINODE_TOKEN") + + machineWatchFilter string + clusterWatchFilter string + metricsAddr string + enableLeaderElection bool + probeAddr string + ) flag.StringVar(&machineWatchFilter, "machine-watch-filter", "", "The machines to watch by label.") flag.StringVar(&clusterWatchFilter, "cluster-watch-filter", "", "The clusters to watch by label.") flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") @@ -81,6 +80,12 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) + // Check environment variables + if linodeToken == "" { + setupLog.Error(errors.New("failed to get LINODE_TOKEN environment variable"), "unable to start operator") + os.Exit(1) + } + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, Metrics: metricsserver.Options{BindAddress: metricsAddr},