From 3239b22eedc78de24b82ee05983fd6577d159fa9 Mon Sep 17 00:00:00 2001 From: justinsb Date: Thu, 23 Nov 2023 11:25:29 -0500 Subject: [PATCH] kops: Don't try to split --set flags on commas Passing quotes in very difficult with the --set flag, because the pflag library tries to parse it using strict CSV semantics. We switch to using the StringArrayVar, which does not attempt splitting. This is a breaking change; compound flags must now be written as two flags, but I think that is clearer. Example: `--set=a,b` must now be `--set=a --set=b` --- cmd/kops/create_cluster.go | 4 ++-- cmd/kops/edit_cluster.go | 2 +- cmd/kops/edit_instancegroup.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/kops/create_cluster.go b/cmd/kops/create_cluster.go index e1b427928a54c..f21be6464bdac 100644 --- a/cmd/kops/create_cluster.go +++ b/cmd/kops/create_cluster.go @@ -408,9 +408,9 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command { return []string{"json", "yaml"}, cobra.ShellCompDirectiveNoFileComp }) - cmd.Flags().StringSliceVar(&options.Sets, "override", options.Sets, "Directly set values in the spec") + cmd.Flags().StringArrayVar(&options.Sets, "override", options.Sets, "Directly set values in the spec") cmd.Flags().MarkDeprecated("override", "use --set instead") - cmd.Flags().StringSliceVar(&options.Sets, "set", options.Sets, "Directly set values in the spec") + cmd.Flags().StringArrayVar(&options.Sets, "set", options.Sets, "Directly set values in the spec") cmd.RegisterFlagCompletionFunc("set", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return nil, cobra.ShellCompDirectiveNoFileComp }) diff --git a/cmd/kops/edit_cluster.go b/cmd/kops/edit_cluster.go index 09f1518ea087b..934e132873e11 100644 --- a/cmd/kops/edit_cluster.go +++ b/cmd/kops/edit_cluster.go @@ -84,7 +84,7 @@ func NewCmdEditCluster(f *util.Factory, out io.Writer) *cobra.Command { }, } - cmd.Flags().StringSliceVar(&options.Sets, "set", options.Sets, "Directly set values in the spec") + cmd.Flags().StringArrayVar(&options.Sets, "set", options.Sets, "Directly set values in the spec") cmd.RegisterFlagCompletionFunc("set", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return nil, cobra.ShellCompDirectiveNoFileComp }) diff --git a/cmd/kops/edit_instancegroup.go b/cmd/kops/edit_instancegroup.go index 96661825f84bf..2edffff097b2b 100644 --- a/cmd/kops/edit_instancegroup.go +++ b/cmd/kops/edit_instancegroup.go @@ -107,7 +107,7 @@ func NewCmdEditInstanceGroup(f *util.Factory, out io.Writer) *cobra.Command { }, } - cmd.Flags().StringSliceVar(&options.Sets, "set", options.Sets, "Directly set values in the spec") + cmd.Flags().StringArrayVar(&options.Sets, "set", options.Sets, "Directly set values in the spec") cmd.RegisterFlagCompletionFunc("set", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return nil, cobra.ShellCompDirectiveNoFileComp })