From 3b9384a23c3ff2fff505feab61d62a994eb1fa93 Mon Sep 17 00:00:00 2001 From: Kyle Rockman Date: Fri, 2 Mar 2018 13:37:56 -0600 Subject: [PATCH] Add cluster name environment variable - Add an environment variable to configure cluster name - Expose envionrment variable in CLI documentation --- cmd/kops/root.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/kops/root.go b/cmd/kops/root.go index af3b792d40..7ade766833 100644 --- a/cmd/kops/root.go +++ b/cmd/kops/root.go @@ -126,9 +126,10 @@ func NewCmdRoot(f *util.Factory, out io.Writer) *cobra.Command { if strings.HasSuffix(defaultStateStore, "/") { defaultStateStore = strings.TrimSuffix(defaultStateStore, "/") } - cmd.PersistentFlags().StringVarP(&rootCommand.RegistryPath, "state", "", defaultStateStore, "Location of state storage") + cmd.PersistentFlags().StringVarP(&rootCommand.RegistryPath, "state", "", defaultStateStore, "Location of state storage. Overrides $KOPS_STATE_STORE") - cmd.PersistentFlags().StringVarP(&rootCommand.clusterName, "name", "", "", "Name of cluster") + defaultClusterName := os.Getenv("KOPS_CLUSTER_NAME") + cmd.PersistentFlags().StringVarP(&rootCommand.clusterName, "name", "", defaultClusterName, "Name of cluster. Overrides $KOPS_CLUSTER_NAME") // create subcommands cmd.AddCommand(NewCmdCompletion(f, out))