From f9be3262740a2961f5c1a4db24265234a3fc6a5f Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Thu, 21 Oct 2021 21:27:25 +0200 Subject: Remove the authfile parameter of MakeXRegistryConfigHeader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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č --- pkg/auth/auth.go | 5 +---- pkg/auth/auth_test.go | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'pkg/auth') diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index b68109429..006572b09 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -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 diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go index ec5c1c9e7..a727a9d50 100644 --- a/pkg/auth/auth_test.go +++ b/pkg/auth/auth_test.go @@ -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 { -- cgit v1.2.3-54-g00ecf