command

package
v29.1.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 54 Imported by: 0

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"
)

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 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 PromptUserForCredentials

func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword, defaultUsername, serverAddress string) (registrytypes.AuthConfig, error)

PromptUserForCredentials handles the CLI prompt for the user to input credentials. If argUser is not empty, then the user is only prompted for their password. If argPassword is not empty, then the user is only prompted for their username If neither argUser nor argPassword are empty, then the user is not prompted and an AuthConfig is returned with those values. If defaultUsername is not empty, the username prompt includes that username and the user can hit enter without inputting a username to use that default username.

func PruneFilters

func PruneFilters(dockerCLI config.Provider, filters client.Filters) client.Filters

PruneFilters merges prune filters specified in config.json with those specified as command-line flags. It returns a deep copy of filters to prevent mutating the original.

CLI label filters have precedence over those specified in config.json. If a label filter specified as flag conflicts with a label defined in config.json (i.e., "label=some-value" conflicts with "label!=some-value", and vice versa), then the filter defined in config.json is omitted.

func RegisterDefaultStoreEndpoints

func RegisterDefaultStoreEndpoints(ep ...store.NamedTypeGetter)

RegisterDefaultStoreEndpoints registers a new named endpoint metadata type with the default context store config, so that endpoint will be supported by stores using the config returned by DefaultContextStoreConfig.

func ResolveAuthConfig deprecated

func ResolveAuthConfig(cfg *configfile.ConfigFile, index *registrytypes.IndexInfo) registrytypes.AuthConfig

ResolveAuthConfig returns auth-config for the given registry from the credential-store. It returns an empty AuthConfig if no credentials were found.

Deprecated: this function is no longer used, and will be removed in the next release.

func RetrieveAuthTokenFromImage

func RetrieveAuthTokenFromImage(cfg *configfile.ConfigFile, image string) (string, error)

RetrieveAuthTokenFromImage retrieves an encoded auth token given a complete image reference. The auth configuration is serialized as a base64url encoded (RFC 4648, Section 5) JSON string for sending through the "X-Registry-Auth" header.

func ShowHelp