cmd

package
v0.12.0-beta.1.dev.202... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cmd contains common flags and routines for all CLIs.

Index

Constants

This section is empty.

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.",
	}
	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) {
		defaultSignatureFormat := envelope.JWS

		config, err := configutil.LoadConfigOnce()
		if err == nil && config.SignatureFormat != "" {
			defaultSignatureFormat = config.SignatureFormat
		}

		fs.StringVar(p, PflagSignatureFormat.Name, defaultSignatureFormat, PflagSignatureFormat.Usage)
	}

	PflagTimestamp = &pflag.Flag{
		Name:      "timestamp",
		Shorthand: "t",
		Usage:     "timestamp the signed signature via the remote TSA",
	}
	SetPflagTimestamp = func(fs *pflag.FlagSet, p *string) {
		fs.StringVarP(p, PflagTimestamp.Name, PflagTimestamp.Shorthand, "", PflagTimestamp.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",
		Shorthand: "c",
		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.StringArrayVarP(p, PflagPluginConfig.Name, PflagPluginConfig.Shorthand, nil, PflagPluginConfig.Usage)
	}
)

Functions

func GetExpiry

func GetExpiry(expiry time.Duration) time.Time

GetExpiry returns the signature expiry according to the CLI context.

func GetSigner

func GetSigner(opts *SignerFlagOpts) (notation.Signer, error)

GetSigner returns a signer according to the CLI context.

func ParseFlagPluginConfig

func ParseFlagPluginConfig(config []string) (map[string]string, error)

Types

type KeyValueSlice

type KeyValueSlice interface {
	Set(value string) error
	String() string
}

KeyValueSlice is a flag with type int

type SignerFlagOpts

type SignerFlagOpts struct {
	Key             string
	SignatureFormat string
}

SignerFlagOpts cmd opts for using cmd.GetSigner

func (*SignerFlagOpts) ApplyFlags

func (opts *SignerFlagOpts) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags set flags and their default values for the FlagSet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL