package config

import "github.com/docker/cli/cli/config"

Index

Constants

const (
	// EnvOverrideConfigDir is the name of the environment variable that can be
	// used to override the location of the client configuration files (~/.docker).
	//
	// It takes priority over the default, but can be overridden by the "--config"
	// command line option.
	EnvOverrideConfigDir = "DOCKER_CONFIG"

	// ConfigFileName is the name of the client configuration file inside the
	// config-directory.
	ConfigFileName = "config.json"
)

Functions

func ContextStoreDir

func ContextStoreDir() string

ContextStoreDir returns the directory the docker contexts are stored in

func Dir

func Dir() string

Dir returns the directory the configuration file is stored in

func Load

func Load(configDir string) (*configfile.ConfigFile, error)

Load reads the configuration file (ConfigFileName) from the given directory. If no directory is given, it uses the default Dir. A *configfile.ConfigFile is returned containing the contents of the configuration file, or a default struct if no configfile exists in the given location.

Load returns an error if a configuration file exists in the given location, but cannot be read, or is malformed. Consumers must handle errors to prevent overwriting an existing configuration file.

func LoadDefaultConfigFile

func LoadDefaultConfigFile(stderr io.Writer) *configfile.ConfigFile

LoadDefaultConfigFile attempts to load the default config file and returns a reference to the ConfigFile struct. If none is found or when failing to load the configuration file, it initializes a default ConfigFile struct. If no credentials-store is set in the configuration file, it attempts to discover the default store to use for the current platform.

Important: LoadDefaultConfigFile prints a warning to stderr when failing to load the configuration file, but otherwise ignores errors. Consumers should consider using Load (and credentials.DetectDefaultStore) to detect errors when updating the configuration file, to prevent discarding a (malformed) configuration file.

func LoadFromReader

func LoadFromReader(configData io.Reader) (*configfile.ConfigFile, error)

LoadFromReader is a convenience function that creates a ConfigFile object from a reader. It returns an error if configData is malformed.

func Path

func Path(p ...string) (string, error)

Path returns the path to a file relative to the config dir

func SetDir

func SetDir(dir string)

SetDir sets the directory the configuration file is stored in

Source Files

config.go

Directories

PathSynopsis
cli/config/configfile
cli/config/credentials
cli/config/types
Version
v27.0.3+incompatible
Published
Jun 28, 2024
Platform
linux/amd64
Imports
12 packages
Last checked
now

Tools for package owners.