MCPcopy Create free account
hub / github.com/docker/cli / RetrieveAuthTokenFromImage

Function RetrieveAuthTokenFromImage

cli/command/registry.go:192–212  ·  view source on GitHub ↗

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. [RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#s

(cfg *configfile.ConfigFile, image string)

Source from the content-addressed store, hash-verified

190//
191// [RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5
192func RetrieveAuthTokenFromImage(cfg *configfile.ConfigFile, image string) (string, error) {
193 registryRef, err := reference.ParseNormalizedNamed(image)
194 if err != nil {
195 return "", err
196 }
197 authConfig, err := cfg.GetAuthConfig(reference.Domain(registryRef))
198 if err != nil {
199 return "", err
200 }
201
202 return authconfig.Encode(registrytypes.AuthConfig{
203 Username: authConfig.Username,
204 Password: authConfig.Password,
205 ServerAddress: authConfig.ServerAddress,
206
207 // TODO(thaJeztah): Are these expected to be included?
208 Auth: authConfig.Auth,
209 IdentityToken: authConfig.IdentityToken,
210 RegistryToken: authConfig.RegistryToken,
211 })
212}

Callers

nothing calls this directly

Calls 1

GetAuthConfigMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…