summaryrefslogtreecommitdiff
path: root/pkg/bindings/images/build.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-09-23 08:19:05 -0700
committerJhon Honce <jhonce@redhat.com>2020-09-29 08:46:44 -0700
commit5aead1509c681de533b8966e781e15327fe35ab6 (patch)
tree8ba86faa76299b04e902b3bf11c5b7ce9872192a /pkg/bindings/images/build.go
parent2ee415be90b8d6ab75f9fe579fc1b8690e023d3c (diff)
downloadpodman-5aead1509c681de533b8966e781e15327fe35ab6.tar.gz
podman-5aead1509c681de533b8966e781e15327fe35ab6.tar.bz2
podman-5aead1509c681de533b8966e781e15327fe35ab6.zip
Add X-Registry-Config support
* Refactor auth pkg to support X-Registry-Config * Refactor build endpoint to support X-Registry-Config. Supports: * --creds * --authfile * Added X-Reference-Id Header to http.Request to support log event correlation * Log headers from http.Request Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/bindings/images/build.go')
-rw-r--r--pkg/bindings/images/build.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go
index 9082670a7..f52ba4e72 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"
@@ -93,6 +94,23 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
params.Set("labels", l)
}
+ 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
@@ -125,7 +143,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
}