vendor containers/image for DockerAuthConfig

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-10-10 20:23:14 +02:00
parent 0eb841ec8b
commit f957e894e6
No known key found for this signature in database
GPG Key ID: B2BEAD150DE936B9
2 changed files with 13 additions and 2 deletions

View File

@ -52,7 +52,7 @@ func newDockerClient(ctx *types.SystemContext, ref dockerReference, write bool)
if registry == dockerHostname { if registry == dockerHostname {
registry = dockerRegistry registry = dockerRegistry
} }
username, password, err := getAuth(ref.ref.Hostname()) username, password, err := getAuth(ctx, ref.ref.Hostname())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -243,7 +243,10 @@ func (c *dockerClient) getBearerToken(realm, service, scope string) (string, err
return tokenStruct.Token, nil return tokenStruct.Token, nil
} }
func getAuth(registry string) (string, string, error) { func getAuth(ctx *types.SystemContext, registry string) (string, string, error) {
if ctx != nil && ctx.DockerAuthConfig != nil {
return ctx.DockerAuthConfig.Username, ctx.DockerAuthConfig.Password, nil
}
// TODO(runcom): get this from *cli.Context somehow // TODO(runcom): get this from *cli.Context somehow
//if username != "" && password != "" { //if username != "" && password != "" {
//return username, password, nil //return username, password, nil

View File

@ -205,6 +205,12 @@ type ImageInspectInfo struct {
Layers []string Layers []string
} }
// DockerAuthConfig contains authorization information for connecting to a registry.
type DockerAuthConfig struct {
Username string
Password string
}
// SystemContext allows parametrizing access to implicitly-accessed resources, // SystemContext allows parametrizing access to implicitly-accessed resources,
// like configuration files in /etc and users' login state in their home directory. // like configuration files in /etc and users' login state in their home directory.
// Various components can share the same field only if their semantics is exactly // Various components can share the same field only if their semantics is exactly
@ -228,4 +234,6 @@ type SystemContext struct {
// === docker.Transport overrides === // === docker.Transport overrides ===
DockerCertPath string // If not "", a directory containing "cert.pem" and "key.pem" used when talking to a Docker Registry DockerCertPath string // If not "", a directory containing "cert.pem" and "key.pem" used when talking to a Docker Registry
DockerInsecureSkipTLSVerify bool // Allow contacting docker registries over HTTP, or HTTPS with failed TLS verification. Note that this does not affect other TLS connections. DockerInsecureSkipTLSVerify bool // Allow contacting docker registries over HTTP, or HTTPS with failed TLS verification. Note that this does not affect other TLS connections.
// if nil, the library tries to parse ~/.docker/config.json to retrieve credentials
DockerAuthConfig *DockerAuthConfig
} }