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)
| 190 | // |
| 191 | // [RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5 |
| 192 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…