Documentation
¶
Overview ¶
Package cmdutil provides utilities that are shared between multiple commands like flags, documentation helpers and errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyOutputDir is returned if the user passed an empty string as the // output directory. ErrEmptyOutputDir = errors.New("output dir must not be an empty string") // ErrInvalidOutputFormat is returned if the output format flag contains an // invalid value. ErrInvalidOutputFormat = errors.New("--output must be 'yaml' or 'json'") )
Functions ¶
func AddConfigFlag ¶
AddConfigFlag adds the --config flag to cmd and binds it to val.
func AddForceFlag ¶
AddForceFlag adds the --force flag to cmd and binds it to val.
Types ¶
type ConfigFlags ¶
type ConfigFlags struct {
config.Config
ConfigPath string
// contains filtered or unexported fields
}
ConfigFlags provide a flag for configuring the path to the kickoff config file. Can be used to automatically populate the kickoff config with defaults and optionally override them if the user passed a different config path via the CLI flag.
func (*ConfigFlags) AddFlags ¶
func (f *ConfigFlags) AddFlags(cmd *cobra.Command)
AddFlags adds flags for configuring the config file location to cmd.
func (*ConfigFlags) AllowMissingConfig ¶
func (f *ConfigFlags) AllowMissingConfig()
AllowMissingConfig allows the config file at ConfigPath to be absent. A nonexistent config file will not cause errors but is simply ignored. This is useful for initialization commands to be able to specify an alternative config file which may not exist yet.
func (*ConfigFlags) Complete ¶
func (f *ConfigFlags) Complete() (err error)
Complete completes the embedded kickoff configuration. It will load the config file from the path provided by the user and merge it into the configuration and apply configuration defaults to unset fields. Returns an error if the config file does not exist, could not be read or contains invalid configuration. If the user did not provide any config file path, the default config file will be loaded instead, if it exists.
type OutputFlags ¶
type OutputFlags struct {
Output string
}
OutputFlags manage and validate flags related to output format.
func (*OutputFlags) AddFlags ¶
func (f *OutputFlags) AddFlags(cmd *cobra.Command)
AddFlags adds flags for configuring output format to cmd.
func (*OutputFlags) Validate ¶
func (f *OutputFlags) Validate() error
Validate validates the output format and returns an error if the user provided an invalid value.