mirror of
https://github.com/containers/podman.git
synced 2025-10-19 12:12:36 +08:00
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>
This commit is contained in:
@ -153,7 +153,7 @@ func Header(sys *types.SystemContext, headerName HeaderAuthName, authfile, usern
|
|||||||
case XRegistryAuthHeader:
|
case XRegistryAuthHeader:
|
||||||
content, err = headerAuth(sys, authfile, username, password)
|
content, err = headerAuth(sys, authfile, username, password)
|
||||||
case XRegistryConfigHeader:
|
case XRegistryConfigHeader:
|
||||||
content, err = headerConfig(sys, authfile, username, password)
|
return MakeXRegistryConfigHeader(sys, authfile, username, password)
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("unsupported authentication header: %q", headerName)
|
err = fmt.Errorf("unsupported authentication header: %q", headerName)
|
||||||
}
|
}
|
||||||
@ -167,9 +167,9 @@ func Header(sys *types.SystemContext, headerName HeaderAuthName, authfile, usern
|
|||||||
return nil, nil
|
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.
|
// 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 {
|
if sys == nil {
|
||||||
sys = &types.SystemContext{}
|
sys = &types.SystemContext{}
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ func headerConfig(sys *types.SystemContext, authfile, username, password string)
|
|||||||
}
|
}
|
||||||
authConfigs, err := imageAuth.GetAllCredentials(sys)
|
authConfigs, err := imageAuth.GetAllCredentials(sys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if username != "" {
|
if username != "" {
|
||||||
@ -189,9 +189,13 @@ func headerConfig(sys *types.SystemContext, authfile, username, password string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(authConfigs) == 0 {
|
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
|
// headerAuth returns a base64 encoded map with the XRegistryAuthHeader set which can
|
||||||
|
Reference in New Issue
Block a user