From f8e17055e3cd6d4be2c58b5f392ab646fbf933f9 Mon Sep 17 00:00:00 2001 From: yuanyi <344476153@qq.com> Date: Sun, 8 Oct 2023 22:27:59 +0800 Subject: [PATCH] add check var --- main.go | 11 +++++++++-- pkg/util/runtime.go | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) delete mode 100644 pkg/util/runtime.go diff --git a/main.go b/main.go index 54dec624..659fce66 100644 --- a/main.go +++ b/main.go @@ -87,8 +87,8 @@ func main() { flag.StringVar(&scaleServerAddr, "scale-server-bind-address", ":6000", "The address the scale server endpoint binds to.") viper.SetDefault(apiServerSustainedQPSFlag, 20) viper.SetDefault(apiServerBurstQPSFlag, 30) - viper.BindEnv(apiServerSustainedQPSFlag) - viper.BindEnv(apiServerBurstQPSFlag) + Must(viper.BindEnv(apiServerSustainedQPSFlag)) + Must(viper.BindEnv(apiServerBurstQPSFlag)) // Add cloud provider flags cloudprovider.InitCloudProviderFlags() @@ -215,3 +215,10 @@ func main() { os.Exit(1) } } + +// Must panics if there is an error +func Must(err error) { + if err != nil { + setupLog.Error(err, "viper.BindEnv error") + } +} diff --git a/pkg/util/runtime.go b/pkg/util/runtime.go deleted file mode 100644 index c7d86821..00000000 --- a/pkg/util/runtime.go +++ /dev/null @@ -1 +0,0 @@ -package util