From f957e894e6c102168bc4d0ff409592d371f55152 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Mon, 10 Oct 2016 20:23:14 +0200 Subject: [PATCH] vendor containers/image for DockerAuthConfig Signed-off-by: Antonio Murdaca --- .../github.com/containers/image/docker/docker_client.go | 7 +++++-- vendor/github.com/containers/image/types/types.go | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/vendor/github.com/containers/image/docker/docker_client.go b/vendor/github.com/containers/image/docker/docker_client.go index ae986de4..481fa43d 100644 --- a/vendor/github.com/containers/image/docker/docker_client.go +++ b/vendor/github.com/containers/image/docker/docker_client.go @@ -52,7 +52,7 @@ func newDockerClient(ctx *types.SystemContext, ref dockerReference, write bool) if registry == dockerHostname { registry = dockerRegistry } - username, password, err := getAuth(ref.ref.Hostname()) + username, password, err := getAuth(ctx, ref.ref.Hostname()) if err != nil { return nil, err } @@ -243,7 +243,10 @@ func (c *dockerClient) getBearerToken(realm, service, scope string) (string, err 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 //if username != "" && password != "" { //return username, password, nil diff --git a/vendor/github.com/containers/image/types/types.go b/vendor/github.com/containers/image/types/types.go index c4a15b3b..ab185a6f 100644 --- a/vendor/github.com/containers/image/types/types.go +++ b/vendor/github.com/containers/image/types/types.go @@ -205,6 +205,12 @@ type ImageInspectInfo struct { 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, // 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 @@ -228,4 +234,6 @@ type SystemContext struct { // === docker.Transport overrides === 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. + // if nil, the library tries to parse ~/.docker/config.json to retrieve credentials + DockerAuthConfig *DockerAuthConfig }