Documentation ¶
Index ¶
- Variables
- func ConfigPath() (string, error)
- func DecodeBase64Auth(auth AuthConfig) (string, string, error)
- func FromFile(configPath string, cfg *Config) error
- func GetCredentialsFromHelper(helper, hostname string) (string, string, error)
- func GetRegistryCredentials(hostname string) (string, string, error)
- func ResolveRegistryHost(host string) string
- func UserHomeConfigPath() (string, error)
- type AuthConfig
- type Config
- type KubernetesConfig
- type ProxyConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrCredentialsNotFound = errors.New("credentials not found in native keychain") ErrCredentialsMissingServerURL = errors.New("no credentials server URL") )
Errors from credential helpers.
Functions ¶
func ConfigPath ¶
ConfigPath returns the path to the docker cli config.
It will either use the DOCKER_CONFIG env var if set, or the value from UserHomeConfigPath DOCKER_CONFIG would be the dir path where `config.json` is stored, this returns the path to config.json.
func DecodeBase64Auth ¶ added in v0.2.0
func DecodeBase64Auth(auth AuthConfig) (string, string, error)
DecodeBase64Auth decodes the legacy file-based auth storage from the docker CLI. It takes the "Auth" filed from AuthConfig and decodes that into a username and password.
If "Auth" is empty, an empty user/pass will be returned, but not an error.
func GetCredentialsFromHelper ¶
GetCredentialsFromHelper attempts to lookup credentials from the passed in docker credential helper.
The credential helper should just be the suffix name (no "docker-credential-"). If the passed in helper program is empty this will look up the default helper for the platform.
If the credentials are not found, no error is returned, only empty credentials.
Hostnames should already be resolved using ResolveRegistryHost
If the username string is empty, the password string is an identity token.
func GetRegistryCredentials ¶
GetRegistryCredentials gets registry credentials for the passed in registry host.
This will use LoadDefaultConfig to read registry auth details from the config. If the config doesn't exist, it will attempt to load registry credentials using the default credential helper for the platform.
func ResolveRegistryHost ¶
ResolveRegistryHost can be used to transform a docker registry host name into what is used for the docker config/cred helpers
This is useful for using with containerd authorizers. Naturally this only transforms docker hub URLs.
func UserHomeConfigPath ¶
UserHomeConfigPath returns the path to the docker config in the current user's home dir.
Types ¶
type AuthConfig ¶
type AuthConfig struct { Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` Auth string `json:"auth,omitempty"` // Email is an optional value associated with the username. // This field is deprecated and will be removed in a later // version of docker. Email string `json:"email,omitempty"` ServerAddress string `json:"serveraddress,omitempty"` // IdentityToken is used to authenticate the user and get // an access token for the registry. IdentityToken string `json:"identitytoken,omitempty"` // RegistryToken is a bearer token to be sent to a registry. RegistryToken string `json:"registrytoken,omitempty"` }
AuthConfig contains authorization information for connecting to a Registry.
type Config ¶
type Config struct { AuthConfigs map[string]AuthConfig `json:"auths"` HTTPHeaders map[string]string `json:"HttpHeaders,omitempty"` PsFormat string `json:"psFormat,omitempty"` ImagesFormat string `json:"imagesFormat,omitempty"` NetworksFormat string `json:"networksFormat,omitempty"` PluginsFormat string `json:"pluginsFormat,omitempty"` VolumesFormat string `json:"volumesFormat,omitempty"` StatsFormat string `json:"statsFormat,omitempty"` DetachKeys string `json:"detachKeys,omitempty"` CredentialsStore string `json:"credsStore,omitempty"` CredentialHelpers map[string]string `json:"credHelpers,omitempty"` Filename string `json:"-"` // Note: for internal use only. ServiceInspectFormat string `json:"serviceInspectFormat,omitempty"` ServicesFormat string `json:"servicesFormat,omitempty"` TasksFormat string `json:"tasksFormat,omitempty"` SecretFormat string `json:"secretFormat,omitempty"` ConfigFormat string `json:"configFormat,omitempty"` NodesFormat string `json:"nodesFormat,omitempty"` PruneFilters []string `json:"pruneFilters,omitempty"` Proxies map[string]ProxyConfig `json:"proxies,omitempty"` Experimental string `json:"experimental,omitempty"` StackOrchestrator string `json:"stackOrchestrator,omitempty"` Kubernetes *KubernetesConfig `json:"kubernetes,omitempty"` CurrentContext string `json:"currentContext,omitempty"` CLIPluginsExtraDirs []string `json:"cliPluginsExtraDirs,omitempty"` Aliases map[string]string `json:"aliases,omitempty"` }
Config represents the on disk format of the docker CLI's config file.
func LoadDefaultConfig ¶
LoadDefaultConfig loads the docker cli config from the path returned from ConfigPath.
func (*Config) GetRegistryCredentials ¶
GetRegistryCredentials gets credentials, if any, for the provided hostname.
Hostnames should already be resolved using ResolveRegistryHost.
If the returned username string is empty, the password is an identity token.
type KubernetesConfig ¶
type KubernetesConfig struct {
AllNamespaces string `json:"allNamespaces,omitempty"`
}
KubernetesConfig contains Kubernetes orchestrator settings.