From 7affabbbc2fa695114a54284487e00d8a28623a1 Mon Sep 17 00:00:00 2001 From: Bernd Verst <4535280+berndverst@users.noreply.github.com> Date: Thu, 7 Oct 2021 16:48:10 -0700 Subject: [PATCH] Allow specifying of runtime-version via Env Var for `dapr init` (#806) * Allow specifying of runtime-version via Env Var * Change order of preference for runtimeVersion command --- cmd/init.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/init.go b/cmd/init.go index 9ad12746..28ed36e3 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -93,11 +93,17 @@ dapr init -s } func init() { + defaultRuntimeVersion := "latest" + viper.BindEnv("runtime_version_override", "DAPR_RUNTIME_VERSION") + runtimeVersionEnv := viper.GetString("runtime_version_override") + if runtimeVersionEnv != "" { + defaultRuntimeVersion = runtimeVersionEnv + } InitCmd.Flags().BoolVarP(&kubernetesMode, "kubernetes", "k", false, "Deploy Dapr to a Kubernetes cluster") InitCmd.Flags().BoolVarP(&wait, "wait", "", false, "Wait for Kubernetes initialization to complete") InitCmd.Flags().UintVarP(&timeout, "timeout", "", 300, "The wait timeout for the Kubernetes installation") InitCmd.Flags().BoolVarP(&slimMode, "slim", "s", false, "Exclude placement service, Redis and Zipkin containers from self-hosted installation") - InitCmd.Flags().StringVarP(&runtimeVersion, "runtime-version", "", "latest", "The version of the Dapr runtime to install, for example: 1.0.0") + InitCmd.Flags().StringVarP(&runtimeVersion, "runtime-version", "", defaultRuntimeVersion, "The version of the Dapr runtime to install, for example: 1.0.0") InitCmd.Flags().StringVarP(&dashboardVersion, "dashboard-version", "", "latest", "The version of the Dapr dashboard to install, for example: 1.0.0") InitCmd.Flags().StringVarP(&initNamespace, "namespace", "n", "dapr-system", "The Kubernetes namespace to install Dapr in") InitCmd.Flags().BoolVarP(&enableMTLS, "enable-mtls", "", true, "Enable mTLS in your cluster")