const TagReferenceMessage string = `Image reference %s uses a tag, not a digest, to identify the image to sign. This can lead you to sign a different image than the intended one. Please use a digest (example.com/ubuntu@sha256:abc123...) rather than tag (example.com/ubuntu:latest) for the input to cosign. The ability to refer to images by tag will be removed in a future release. `
func ConfirmContinue(ctx context.Context) error
ConfirmContinue prompts the user whether they would like to continue and returns the parsed answer.
If the user enters anything other than "y" or "Y", ConfirmContinue returns an error.
func Infof(ctx context.Context, msg string, a ...any)
Infof logs an informational message. It works like fmt.Printf, except that it always has a trailing newline.
func RunWithTestCtx(callback callbackFunc) string
RunWithTestCtx runs the provided callback in a context with the UI environment swapped out for one that allows for easy testing and captures STDOUT.
The callback has access to a function that writes to the test STDIN.
func Warnf(ctx context.Context, msg string, a ...any)
Warnf logs a warning message (prefixed by "WARNING:"). It works like fmt.Printf, except that it always has a trailing newline.
func WithEnv(ctx context.Context, e *Env) context.Context
WithEnv adds the environment to the context.
An Env is the environment that the CLI exists in.
It contains handles to STDERR and STDIN. Eventually, it will contain configuration pertaining to the current invocation (e.g., is this a terminal or not).
UI methods should be defined on an Env. Then, the Env can be changed for easy testing. The Env will be retrieved from the current application context.
type Env struct { Stderr io.Writer Stdin io.Reader }
type ErrInvalidInput struct { Got string Allowed string }
func (e *ErrInvalidInput) Error() string
type ErrPromptDeclined struct{}
func (e *ErrPromptDeclined) Error() string
type WriteFunc func(string)