Beautify GetCredentials.has a bit

Use separate lines, and use the provided .String() API.

Should not change behaivor.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač
2021-09-11 22:37:23 +02:00
parent 1ecc6ba728
commit 2946e83493

View File

@ -33,7 +33,10 @@ const XRegistryConfigHeader HeaderAuthName = "X-Registry-Config"
// GetCredentials queries the http.Request for X-Registry-.* headers and extracts // GetCredentials queries the http.Request for X-Registry-.* headers and extracts
// the necessary authentication information for libpod operations // the necessary authentication information for libpod operations
func GetCredentials(r *http.Request) (*types.DockerAuthConfig, string, error) { func GetCredentials(r *http.Request) (*types.DockerAuthConfig, string, error) {
has := func(key HeaderAuthName) bool { hdr, found := r.Header[string(key)]; return found && len(hdr) > 0 } has := func(key HeaderAuthName) bool {
hdr, found := r.Header[key.String()]
return found && len(hdr) > 0
}
switch { switch {
case has(XRegistryConfigHeader): case has(XRegistryConfigHeader):
c, f, err := getConfigCredentials(r) c, f, err := getConfigCredentials(r)