Documentation
¶
Overview ¶
Package cmd contains common flags and routines for all CLIs.
Index ¶
Constants ¶
View Source
const ( OutputPlaintext = "text" OutputJSON = "json" )
Variables ¶
View Source
var ( PflagKey = &pflag.Flag{ Name: "key", Shorthand: "k", Usage: "signing key name, for a key previously added to notation's key list. This is mutually exclusive with the --id and --plugin flags", } SetPflagKey = func(fs *pflag.FlagSet, p *string) { fs.StringVarP(p, PflagKey.Name, PflagKey.Shorthand, "", PflagKey.Usage) } PflagSignatureFormat = &pflag.Flag{ Name: "signature-format", Usage: "signature envelope format, options: \"jws\", \"cose\"", } SetPflagSignatureFormat = func(fs *pflag.FlagSet, p *string) { config, err := configutil.LoadConfigOnce() if err != nil || config.SignatureFormat == "" { fs.StringVar(p, PflagSignatureFormat.Name, envelope.JWS, PflagSignatureFormat.Usage) return } fs.StringVar(p, PflagSignatureFormat.Name, config.SignatureFormat, PflagSignatureFormat.Usage) } PflagID = &pflag.Flag{ Name: "id", Usage: "key id (required if --plugin is set). This is mutually exclusive with the --key flag", } SetPflagID = func(fs *pflag.FlagSet, p *string) { fs.StringVar(p, PflagID.Name, "", PflagID.Usage) } PflagPlugin = &pflag.Flag{ Name: "plugin", Usage: "signing plugin name (required if --id is set). This is mutually exclusive with the --key flag", } SetPflagPlugin = func(fs *pflag.FlagSet, p *string) { fs.StringVar(p, PflagPlugin.Name, "", PflagPlugin.Usage) } PflagExpiry = &pflag.Flag{ Name: "expiry", Shorthand: "e", Usage: "optional expiry that provides a \"best by use\" time for the artifact. The duration is specified in minutes(m) and/or hours(h). For example: 12h, 30m, 3h20m", } SetPflagExpiry = func(fs *pflag.FlagSet, p *time.Duration) { fs.DurationVarP(p, PflagExpiry.Name, PflagExpiry.Shorthand, time.Duration(0), PflagExpiry.Usage) } PflagReference = &pflag.Flag{ Name: "reference", Shorthand: "r", Usage: "original reference", } SetPflagReference = func(fs *pflag.FlagSet, p *string) { fs.StringVarP(p, PflagReference.Name, PflagReference.Shorthand, "", PflagReference.Usage) } PflagPluginConfig = &pflag.Flag{ Name: "plugin-config", Usage: "{key}={value} pairs that are passed as it is to a plugin, refer plugin's documentation to set appropriate values", } SetPflagPluginConfig = func(fs *pflag.FlagSet, p *[]string) { fs.StringArrayVar(p, PflagPluginConfig.Name, nil, PflagPluginConfig.Usage) } PflagUserMetadata = &pflag.Flag{ Name: "user-metadata", Shorthand: "m", } PflagUserMetadataSignUsage = "{key}={value} pairs that are added to the signature payload" PflagUserMetadataVerifyUsage = "user defined {key}={value} pairs that must be present in the signature for successful verification if provided" SetPflagUserMetadata = func(fs *pflag.FlagSet, p *[]string, usage string) { fs.StringArrayVarP(p, PflagUserMetadata.Name, PflagUserMetadata.Shorthand, nil, usage) } PflagReferrersAPI = &pflag.Flag{ Name: "allow-referrers-api", } PflagReferrersUsageFormat = "[Experimental] use the Referrers API to %s signatures, if not supported (returns 404), fallback to the Referrers tag schema" SetPflagReferrersAPI = func(fs *pflag.FlagSet, p *bool, usage string) { fs.BoolVar(p, PflagReferrersAPI.Name, false, usage) fs.MarkHidden(PflagReferrersAPI.Name) } PflagReferrersTag = &pflag.Flag{ Name: "force-referrers-tag", } SetPflagReferrersTag = func(fs *pflag.FlagSet, p *bool, usage string) { fs.BoolVar(p, PflagReferrersTag.Name, true, usage) } PflagOutput = &pflag.Flag{ Name: "output", Shorthand: "o", } PflagOutputUsage = fmt.Sprintf("output format, options: '%s', '%s'", OutputJSON, OutputPlaintext) SetPflagOutput = func(fs *pflag.FlagSet, p *string, usage string) { fs.StringVarP(p, PflagOutput.Name, PflagOutput.Shorthand, OutputPlaintext, usage) } )
Functions ¶
Types ¶
type KeyValueSlice ¶
KeyValueSlice is a flag with type int
type LoggingFlagOpts ¶
LoggingFlagOpts option struct.
func (*LoggingFlagOpts) ApplyFlags ¶
func (opts *LoggingFlagOpts) ApplyFlags(fs *pflag.FlagSet)
ApplyFlags applies flags to a command flag set.
func (*LoggingFlagOpts) InitializeLogger ¶
func (opts *LoggingFlagOpts) InitializeLogger(ctx context.Context) context.Context
InitializeLogger sets up the logger based on common options.
type SignerFlagOpts ¶
SignerFlagOpts cmd opts for using cmd.GetSigner
func (*SignerFlagOpts) ApplyFlagsToCommand ¶
func (opts *SignerFlagOpts) ApplyFlagsToCommand(command *cobra.Command)
ApplyFlags set flags and their default values for the FlagSet
Click to show internal directories.
Click to hide internal directories.