diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-10-02 06:13:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-02 06:13:25 -0400 |
commit | 00c7b493a0565205aa054be7708281874163c85d (patch) | |
tree | ef43b932450ef34f26ae3b8d1dda53aab752c760 /pkg/bindings | |
parent | 0b7b22243798650841cd9b790809a0a482f4cbcb (diff) | |
parent | 5aead1509c681de533b8966e781e15327fe35ab6 (diff) | |
download | podman-00c7b493a0565205aa054be7708281874163c85d.tar.gz podman-00c7b493a0565205aa054be7708281874163c85d.tar.bz2 podman-00c7b493a0565205aa054be7708281874163c85d.zip |
Merge pull request #7815 from jwhonce/wip/creds_remote
Add X-Registry-Config support
Diffstat (limited to 'pkg/bindings')
-rw-r--r-- | pkg/bindings/images/build.go | 20 | ||||
-rw-r--r-- | pkg/bindings/images/images.go | 4 | ||||
-rw-r--r-- | pkg/bindings/images/pull.go | 2 | ||||
-rw-r--r-- | pkg/bindings/play/play.go | 2 |
4 files changed, 23 insertions, 5 deletions
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index e65a04f7b..60ffea548 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -15,6 +15,7 @@ import ( "strings" "github.com/containers/buildah" + "github.com/containers/podman/v2/pkg/auth" "github.com/containers/podman/v2/pkg/bindings" "github.com/containers/podman/v2/pkg/domain/entities" "github.com/docker/go-units" @@ -96,6 +97,23 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO params.Set("httpproxy", "1") } + var ( + headers map[string]string + err error + ) + if options.SystemContext == nil { + headers, err = auth.Header(options.SystemContext, auth.XRegistryConfigHeader, "", "", "") + } else { + if options.SystemContext.DockerAuthConfig != nil { + headers, err = auth.Header(options.SystemContext, auth.XRegistryAuthHeader, options.SystemContext.AuthFilePath, options.SystemContext.DockerAuthConfig.Username, options.SystemContext.DockerAuthConfig.Password) + } else { + headers, err = auth.Header(options.SystemContext, auth.XRegistryConfigHeader, options.SystemContext.AuthFilePath, "", "") + } + } + if err != nil { + return nil, err + } + stdout := io.Writer(os.Stdout) if options.Out != nil { stdout = options.Out @@ -128,7 +146,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO if err != nil { return nil, err } - response, err := conn.DoRequest(tarfile, http.MethodPost, "/build", params, nil) + response, err := conn.DoRequest(tarfile, http.MethodPost, "/build", params, headers) if err != nil { return nil, err } diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go index 596491044..a78e7f4c6 100644 --- a/pkg/bindings/images/images.go +++ b/pkg/bindings/images/images.go @@ -282,7 +282,7 @@ func Push(ctx context.Context, source string, destination string, options entiti } // TODO: have a global system context we can pass around (1st argument) - header, err := auth.Header(nil, options.Authfile, options.Username, options.Password) + header, err := auth.Header(nil, auth.XRegistryAuthHeader, options.Authfile, options.Username, options.Password) if err != nil { return err } @@ -325,7 +325,7 @@ func Search(ctx context.Context, term string, opts entities.ImageSearchOptions) } // TODO: have a global system context we can pass around (1st argument) - header, err := auth.Header(nil, opts.Authfile, "", "") + header, err := auth.Header(nil, auth.XRegistryAuthHeader, opts.Authfile, "", "") if err != nil { return nil, err } diff --git a/pkg/bindings/images/pull.go b/pkg/bindings/images/pull.go index 2bfbbb2ac..c827b3283 100644 --- a/pkg/bindings/images/pull.go +++ b/pkg/bindings/images/pull.go @@ -42,7 +42,7 @@ func Pull(ctx context.Context, rawImage string, options entities.ImagePullOption params.Set("allTags", strconv.FormatBool(options.AllTags)) // TODO: have a global system context we can pass around (1st argument) - header, err := auth.Header(nil, options.Authfile, options.Username, options.Password) + header, err := auth.Header(nil, auth.XRegistryAuthHeader, options.Authfile, options.Username, options.Password) if err != nil { return nil, err } diff --git a/pkg/bindings/play/play.go b/pkg/bindings/play/play.go index 32f9bb4a9..ffaee3208 100644 --- a/pkg/bindings/play/play.go +++ b/pkg/bindings/play/play.go @@ -33,7 +33,7 @@ func Kube(ctx context.Context, path string, options entities.PlayKubeOptions) (* } // TODO: have a global system context we can pass around (1st argument) - header, err := auth.Header(nil, options.Authfile, options.Username, options.Password) + header, err := auth.Header(nil, auth.XRegistryAuthHeader, options.Authfile, options.Username, options.Password) if err != nil { return nil, err } |