Documentation
¶
Index ¶
- func HelperManagedNotice(err error) (string, bool)
- type ConfigManager
- func (m *ConfigManager) GetAuthenticatedRegistries() ([]string, error)
- func (m *ConfigManager) GetConfigDir() string
- func (m *ConfigManager) GetConfigPath() string
- func (m *ConfigManager) RemoveAuth(registries ...string) error
- func (m *ConfigManager) WriteAuth(registry, username, password string) error
- type CredentialHelper
- type HelperCredential
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HelperManagedNotice ¶
HelperManagedNotice reports whether err, returned by WriteAuth, means the registry is managed by a credential helper that gets credentials itself. It then returns the message to show instead of failing the login. Any other error, including a helper whose store genuinely fails, returns "" and false.
Types ¶
type ConfigManager ¶
type ConfigManager struct {
// contains filtered or unexported fields
}
ConfigManager manages Docker config.json for ECR authentication. It uses file locking to prevent concurrent modification.
The file is round-tripped losslessly: only the target registry's auths entry changes, and every other key (credsStore, credHelpers, currentContext, plugins, proxies, per-registry identitytoken, unknown keys) is preserved. When Docker would read the registry's credentials from a credential helper (credHelpers[registry] or credsStore), the credentials are stored in that helper, as `docker login` does, because Docker ignores inline auths then.
func NewConfigManager ¶
func NewConfigManager() (*ConfigManager, error)
NewConfigManager creates a new Docker config manager using the default Docker config path. The config is stored in ~/.docker/config.json by default (or $DOCKER_CONFIG/config.json if DOCKER_CONFIG is set). This ensures compatibility with Docker CLI without requiring additional environment variable configuration.
func (*ConfigManager) GetAuthenticatedRegistries ¶
func (m *ConfigManager) GetAuthenticatedRegistries() ([]string, error)
GetAuthenticatedRegistries returns list of authenticated ECR registries.
func (*ConfigManager) GetConfigDir ¶
func (m *ConfigManager) GetConfigDir() string
GetConfigDir returns the directory containing the Docker config.
func (*ConfigManager) GetConfigPath ¶
func (m *ConfigManager) GetConfigPath() string
GetConfigPath returns the full path to the Docker config file.
func (*ConfigManager) RemoveAuth ¶
func (m *ConfigManager) RemoveAuth(registries ...string) error
RemoveAuth removes ECR authorization from Docker config. It reverses WriteAuth: the registry's auths entry is deleted and, when Docker resolves the registry through a credential helper, the credentials are erased from that helper. Registries without an auths entry are left alone, so the helper is never asked to erase credentials Atmos (or `docker login`) did not record. If a helper erase fails, that registry's entry is kept so the logout can be retried, and the error is returned. Like `docker logout`, a registry is normalized to its hostname and every auths key Docker reads for that host is removed, including legacy "https://host" or "host/v2/" keys; each key is erased from the helper Docker resolves for that exact key.
func (*ConfigManager) WriteAuth ¶
func (m *ConfigManager) WriteAuth(registry, username, password string) error
WriteAuth writes ECR authorization to Docker config. The auth entry is stored as base64(username:password). When Docker resolves the registry through a credential helper (credHelpers[registry] or credsStore), the credentials are stored in that helper instead and only an empty placeholder entry is written to auths, matching `docker login`. A helper failure is returned as ErrDockerCredentialHelper and leaves config.json unchanged; when the helper does not implement store (it gets credentials itself, like docker-credential-ecr-login), the error also matches ErrDockerCredentialHelperStoreUnsupported and HelperManagedNotice returns the message callers show instead of failing. If config.json cannot be saved after a successful helper store, the stored credential is erased again so it is not orphaned in the helper. After a successful write it warns (without failing) when DOCKER_AUTH_CONFIG is set, because Docker reads credentials from that variable before config.json.
type CredentialHelper ¶
type CredentialHelper interface {
// Store saves username/secret for serverURL in the named helper.
Store(helper, serverURL, username, secret string) error
// Get returns the credential stored for serverURL in the named helper. The
// credential is nil, with a nil error, when the helper holds none for serverURL.
Get(helper, serverURL string) (*HelperCredential, error)
// Erase removes the credentials for serverURL from the named helper.
// A missing credential is not an error.
Erase(helper, serverURL string) error
}
CredentialHelper stores and erases registry credentials through a Docker credential helper (the docker-credential-<name> programs referenced by the credsStore and credHelpers keys of config.json).
type HelperCredential ¶
HelperCredential is a username and secret held by a credential helper.