command

package
v28.5.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 56 Imported by: 4,906

Documentation

Index

Constants

View Source
const (
	// DefaultContextName is the name reserved for the default context (config & env based)
	DefaultContextName = "default"

	// EnvOverrideContext is the name of the environment variable that can be
	// used to override the context to use. If set, it overrides the context
	// that's set in the CLI's configuration file, but takes no effect if the
	// "DOCKER_HOST" env-var is set (which takes precedence.
	EnvOverrideContext = "DOCKER_CONTEXT"
)
View Source
const ErrPromptTerminated = prompt.ErrTerminated

ErrPromptTerminated is returned if the user terminated the prompt.

Deprecated: this error is for internal use and will be removed in the next release.

Variables

This section is empty.

Functions

func BaseCommandAttributes

func BaseCommandAttributes(cmd *cobra.Command, streams Streams) []attribute.KeyValue

BaseCommandAttributes returns an attribute.Set containing attributes to attach to metrics/traces

func DefaultContextStoreConfig

func DefaultContextStoreConfig() store.Config

DefaultContextStoreConfig returns a new store.Config with the default set of endpoints configured.

func DisableInputEcho deprecated

func DisableInputEcho(ins *streams.In) (restore func() error, err error)

DisableInputEcho disables input echo on the provided streams.In. This is useful when the user provides sensitive information like passwords. The function returns a restore function that should be called to restore the terminal state.

Deprecated: this function is for internal use and will be removed in the next release.

func GetDefaultAuthConfig

func GetDefaultAuthConfig(cfg *configfile.ConfigFile, checkCredStore bool, serverAddress string, isDefaultRegistry bool) (registrytypes.AuthConfig, error)

GetDefaultAuthConfig gets the default auth config given a serverAddress If credentials for given serverAddress exists in the credential store, the configuration will be populated with values in it

func NewAPIClientFromFlags

func NewAPIClientFromFlags(opts *cliflags.ClientOptions, configFile *configfile.ConfigFile) (client.APIClient, error)

NewAPIClientFromFlags creates a new APIClient from command line flags

func PromptForConfirmation deprecated

func PromptForConfirmation(ctx context.Context, ins io.Reader, outs io.Writer, message string) (bool, error)

PromptForConfirmation requests and checks confirmation from the user. This will display the provided message followed by ' y/N '. If the user input 'y' or 'Y' it returns true otherwise false. If no message is provided, "Are you sure you want to proceed? y/N " will be used instead.

If the user terminates the CLI with SIGINT or SIGTERM while the prompt is active, the prompt will return false with an ErrPromptTerminated error. When the prompt returns an error, the caller should propagate the error up the stack and close the io.Reader used for the prompt which will prevent the background goroutine from blocking indefinitely.

Deprecated: this function is for internal use and will be removed in the next release.

func PromptForInput deprecated

func PromptForInput(ctx context.Context, in io.Reader, out io.Writer, message string) (string, error)

PromptForInput requests input from the user.

If the user terminates the CLI with SIGINT or SIGTERM while the prompt is active, the prompt will return an empty string ("") with an ErrPromptTerminated error. When the prompt returns an error, the caller should propagate the error up the stack and close the io.Reader used for the prompt which will prevent the background goroutine from blocking indefinitely.

Deprecated: this function is for internal use and will be removed in the next release.