Remove pkg/auth.Header

It is no longer used.

Split the existing tests into MakeXRegistryConfigHeader
and MakeXRegistryAuthHeader variants. For now we don't modify
the implementations at all, to make review simpler; cleanups
will follow.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač
2021-10-21 19:21:02 +02:00
parent 3725a34cbf
commit fe1230ef70
2 changed files with 115 additions and 51 deletions

View File

@ -3,7 +3,6 @@ package auth
import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
@ -143,18 +142,6 @@ func getAuthCredentials(headers []string) (*types.DockerAuthConfig, map[string]t
return &authConfig, nil, nil
}
// Header builds the requested Authentication Header
func Header(sys *types.SystemContext, headerName HeaderAuthName, authfile, username, password string) (map[string]string, error) {
switch headerName {
case XRegistryAuthHeader:
return MakeXRegistryAuthHeader(sys, authfile, username, password)
case XRegistryConfigHeader:
return MakeXRegistryConfigHeader(sys, authfile, username, password)
default:
return nil, fmt.Errorf("unsupported authentication header: %q", headerName)
}
}
// 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) {