mirror of
https://github.com/containers/podman
synced 2024-10-21 01:34:37 +00:00
Remove the authfile parameter of MakeXRegistryConfigHeader
Having a parameter that modifies the provides types.SystemContext seems rather unexpected and risky to have around - and the only user of that is actually a no-op; so, remove that option and simplify. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
935dcbb008
commit
f9be326274
|
@ -144,13 +144,10 @@ func getAuthCredentials(headers []string) (*types.DockerAuthConfig, map[string]t
|
|||
|
||||
// MakeXRegistryConfigHeader returns a map with the XRegistryConfigHeader set which can
|
||||
// conveniently be used in the http stack.
|
||||
func MakeXRegistryConfigHeader(sys *types.SystemContext, authfile, username, password string) (map[string]string, error) {
|
||||
func MakeXRegistryConfigHeader(sys *types.SystemContext, username, password string) (map[string]string, error) {
|
||||
if sys == nil {
|
||||
sys = &types.SystemContext{}
|
||||
}
|
||||
if authfile != "" {
|
||||
sys.AuthFilePath = authfile
|
||||
}
|
||||
authConfigs, err := imageAuth.GetAllCredentials(sys)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -81,7 +81,7 @@ func TestMakeXRegistryConfigHeaderGetCredentialsRoundtrip(t *testing.T) {
|
|||
} {
|
||||
inputAuthFile, cleanup := tempAuthFilePath(t, tc.fileContents)
|
||||
defer cleanup()
|
||||
headers, err := MakeXRegistryConfigHeader(nil, inputAuthFile, tc.username, tc.password)
|
||||
headers, err := MakeXRegistryConfigHeader(&types.SystemContext{AuthFilePath: inputAuthFile}, tc.username, tc.password)
|
||||
require.NoError(t, err)
|
||||
req, err := http.NewRequest(http.MethodPost, "/", nil)
|
||||
require.NoError(t, err, tc.name)
|
||||
|
@ -208,7 +208,7 @@ func TestMakeXRegistryConfigHeader(t *testing.T) {
|
|||
} {
|
||||
authFile, cleanup := tempAuthFilePath(t, tc.fileContents)
|
||||
defer cleanup()
|
||||
res, err := MakeXRegistryConfigHeader(nil, authFile, tc.username, tc.password)
|
||||
res, err := MakeXRegistryConfigHeader(&types.SystemContext{AuthFilePath: authFile}, tc.username, tc.password)
|
||||
if tc.shouldErr {
|
||||
assert.Error(t, err, tc.name)
|
||||
} else {
|
||||
|
|
|
@ -294,12 +294,12 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
|||
err error
|
||||
)
|
||||
if options.SystemContext == nil {
|
||||
headers, err = auth.MakeXRegistryConfigHeader(options.SystemContext, "", "", "")
|
||||
headers, err = auth.MakeXRegistryConfigHeader(options.SystemContext, "", "")
|
||||
} else {
|
||||
if options.SystemContext.DockerAuthConfig != nil {
|
||||
headers, err = auth.MakeXRegistryAuthHeader(options.SystemContext, options.SystemContext.AuthFilePath, options.SystemContext.DockerAuthConfig.Username, options.SystemContext.DockerAuthConfig.Password)
|
||||
} else {
|
||||
headers, err = auth.MakeXRegistryConfigHeader(options.SystemContext, options.SystemContext.AuthFilePath, "", "")
|
||||
headers, err = auth.MakeXRegistryConfigHeader(options.SystemContext, "", "")
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue