From 45f27e51f6c487f7ec79efa7464e554e0ac5dbb4 Mon Sep 17 00:00:00 2001 From: Allan Guwatudde Date: Thu, 4 Jan 2024 17:32:26 +0300 Subject: [PATCH] Warn users when the target environment for the CLI is staging (#2071) Staging can sometimes be unstable and there's need to warn users about this --- cmd/cli/app/root.go | 7 +++++++ internal/constants/prod.go | 2 ++ internal/constants/staging.go | 2 ++ 3 files changed, 11 insertions(+) diff --git a/cmd/cli/app/root.go b/cmd/cli/app/root.go index ca98605c02..a632ea4f2b 100644 --- a/cmd/cli/app/root.go +++ b/cmd/cli/app/root.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/viper" clientconfig "github.com/stacklok/minder/internal/config/client" + "github.com/stacklok/minder/internal/constants" ghclient "github.com/stacklok/minder/internal/providers/github" "github.com/stacklok/minder/internal/util/cli" ) @@ -37,6 +38,12 @@ var ( Long: `For more information about minder, please visit: https://docs.stacklok.com/minder`, SilenceErrors: true, // don't print errors twice, we handle them in cli.ExitNicelyOnError + PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + if constants.TargetEnv == "staging" { + cmd.Print("WARNING: This build uses a test environment and may not be stable \n") + } + return nil + }, } ) diff --git a/internal/constants/prod.go b/internal/constants/prod.go index cdee205718..9f9949cc07 100644 --- a/internal/constants/prod.go +++ b/internal/constants/prod.go @@ -18,6 +18,8 @@ package constants const ( + // TargetEnv is the environment the build will point to + TargetEnv = "prod" // IdentitySeverURL is the URL of the identity server IdentitySeverURL = "https://auth.stacklok.com" // MinderGRPCHost is the host of the minder gRPC server diff --git a/internal/constants/staging.go b/internal/constants/staging.go index 99cd2226f2..2621091165 100644 --- a/internal/constants/staging.go +++ b/internal/constants/staging.go @@ -18,6 +18,8 @@ package constants const ( + // TargetEnv is the environment the build will point to + TargetEnv = "staging" // IdentitySeverURL is the URL of the identity server IdentitySeverURL = "https://auth.staging.stacklok.dev" // MinderGRPCHost is the host of the minder gRPC server