Change toolbox template flag for consistency

This commit is contained in:
John Gardiner Myers 2020-06-25 22:32:07 -07:00
parent 26309f0016
commit 3f24a29cca
4 changed files with 11 additions and 4 deletions

1
cmd/kops/BUILD.bazel generated
View File

@ -102,6 +102,7 @@ go_library(
"//vendor/github.com/blang/semver/v4:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/github.com/spf13/cobra/doc:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/github.com/spf13/viper:go_default_library",
"//vendor/golang.org/x/crypto/ssh:go_default_library",
"//vendor/helm.sh/helm/v3/pkg/cli/values:go_default_library",

View File

@ -96,8 +96,6 @@ func NewCmdToolboxDump(f *util.Factory, out io.Writer) *cobra.Command {
},
}
// TODO: Push up to top-level command?
// Yes please! (@kris-nova)
cmd.Flags().StringVarP(&options.Output, "output", "o", options.Output, "output format. One of: yaml, json")
cmd.Flags().StringVar(&options.Dir, "dir", options.Dir, "target directory; if specified will collect logs and other information.")

View File

@ -26,6 +26,7 @@ import (
"strings"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"helm.sh/helm/v3/pkg/strvals"
"k8s.io/kubectl/pkg/util/i18n"
"k8s.io/kubectl/pkg/util/templates"
@ -101,10 +102,17 @@ func NewCmdToolboxTemplate(f *util.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringSliceVar(&options.templatePath, "template", options.templatePath, "Path to template file or directory of templates to render")
cmd.Flags().StringSliceVar(&options.snippetsPath, "snippets", options.snippetsPath, "Path to directory containing snippets used for templating")
cmd.Flags().StringVar(&options.channel, "channel", options.channel, "Channel to use for the channel* functions")
cmd.Flags().StringVar(&options.outputPath, "output", options.outputPath, "Path to output file, otherwise defaults to stdout")
cmd.Flags().StringVar(&options.outputPath, "out", options.outputPath, "Path to output file, otherwise defaults to stdout")
cmd.Flags().StringVar(&options.configValue, "config-value", "", "Show the value of a specific configuration value")
cmd.Flags().BoolVar(&options.failOnMissing, "fail-on-missing", true, "Fail on referencing unset variables in templates")
cmd.Flags().BoolVar(&options.formatYAML, "format-yaml", false, "Attempt to format the generated yaml content before output")
cmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
// Old flag name for outputPath
if name == "output" {
name = "out"
}
return pflag.NormalizedName(name)
})
return cmd
}

View File

@ -34,7 +34,7 @@ kops toolbox template [flags]
--fail-on-missing Fail on referencing unset variables in templates (default true)
--format-yaml Attempt to format the generated yaml content before output
-h, --help help for template
--output string Path to output file, otherwise defaults to stdout
--out string Path to output file, otherwise defaults to stdout
--set stringArray Set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
--set-string stringArray Set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
--snippets strings Path to directory containing snippets used for templating