summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2021-09-11 23:00:02 +0200
committerMiloslav Trmač <mitr@redhat.com>2021-12-10 18:16:22 +0100
commit8155fb5658a3a282550b39b2c3a6cd80bc9653d1 (patch)
treef8fae601b631e36fbf45d59519ef0636555bbbb4
parent29f40887132709b0d2097bdfe7b45ff90c3f7b47 (diff)
downloadpodman-8155fb5658a3a282550b39b2c3a6cd80bc9653d1.tar.gz
podman-8155fb5658a3a282550b39b2c3a6cd80bc9653d1.tar.bz2
podman-8155fb5658a3a282550b39b2c3a6cd80bc9653d1.zip
Turn headerConfig into MakeXRegistryConfigHeader
... which can be called independently. For now, there are no new callers, to test that the behavior has not changed. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-rw-r--r--pkg/auth/auth.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go
index a17297c7d..d4f356f3d 100644
--- a/pkg/auth/auth.go
+++ b/pkg/auth/auth.go
@@ -153,7 +153,7 @@ func Header(sys *types.SystemContext, headerName HeaderAuthName, authfile, usern
case XRegistryAuthHeader:
content, err = headerAuth(sys, authfile, username, password)
case XRegistryConfigHeader:
- content, err = headerConfig(sys, authfile, username, password)
+ return MakeXRegistryConfigHeader(sys, authfile, username, password)
default:
err = fmt.Errorf("unsupported authentication header: %q", headerName)
}
@@ -167,9 +167,9 @@ func Header(sys *types.SystemContext, headerName HeaderAuthName, authfile, usern
return nil, nil
}
-// headerConfig returns a map with the XRegistryConfigHeader set which can
+// MakeXRegistryConfigHeader returns a map with the XRegistryConfigHeader set which can
// conveniently be used in the http stack.
-func headerConfig(sys *types.SystemContext, authfile, username, password string) (string, error) {
+func MakeXRegistryConfigHeader(sys *types.SystemContext, authfile, username, password string) (map[string]string, error) {
if sys == nil {
sys = &types.SystemContext{}
}
@@ -178,7 +178,7 @@ func headerConfig(sys *types.SystemContext, authfile, username, password string)
}
authConfigs, err := imageAuth.GetAllCredentials(sys)
if err != nil {
- return "", err
+ return nil, err
}
if username != "" {
@@ -189,9 +189,13 @@ func headerConfig(sys *types.SystemContext, authfile, username, password string)
}
if len(authConfigs) == 0 {
- return "", nil
+ return nil, nil
}
- return encodeMultiAuthConfigs(authConfigs)
+ content, err := encodeMultiAuthConfigs(authConfigs)
+ if err != nil {
+ return nil, err
+ }
+ return map[string]string{XRegistryConfigHeader.String(): content}, nil
}
// headerAuth returns a base64 encoded map with the XRegistryAuthHeader set which can