Use K3K_ env prefix for k3kcli viper binding

This commit is contained in:
copilot-swe-agent[bot]
2026-06-30 23:39:11 +00:00
committed by GitHub
parent 50fae88a84
commit 1b9a28ffee
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -92,10 +92,10 @@ func CobraFlagNamespace(appCtx *AppContext, flag *pflag.FlagSet) {
}
func InitializeConfig(cmd *cobra.Command) {
// Use a "K3KCLI" prefix so that only namespaced environment variables (e.g.
// K3KCLI_VERSION) bind to flags. Without a prefix, common environment variables
// Use a "K3K" prefix so that only namespaced environment variables (e.g.
// K3K_VERSION) bind to flags. Without a prefix, common environment variables
// such as VERSION, MODE or TOKEN would silently override the matching CLI flags.
viper.SetEnvPrefix("K3KCLI")
viper.SetEnvPrefix("K3K")
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
viper.AutomaticEnv()
+1 -1
View File
@@ -21,7 +21,7 @@ func Test_InitializeConfig_envPrefix(t *testing.T) {
},
{
name: "prefixed env binds to flag",
envName: "K3KCLI_VERSION",
envName: "K3K_VERSION",
want: "1h",
},
}