From 9dbec13362b2311271344e97c1451805a0ec5d0e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 7 Oct 2021 16:26:39 +0200 Subject: [PATCH] registry: EndPointV1.Ping() remove redundant "Standalone" and cleanup logs Standalone is a boolean, so false by default; also cleanup some debug logs (probably more logs can be removed) Signed-off-by: Sebastiaan van Stijn --- registry/endpoint_v1.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/registry/endpoint_v1.go b/registry/endpoint_v1.go index 6f38753f90..684c330dc3 100644 --- a/registry/endpoint_v1.go +++ b/registry/endpoint_v1.go @@ -131,29 +131,28 @@ func (e *V1Endpoint) Path(path string) string { // Ping returns a PingResult which indicates whether the registry is standalone or not. func (e *V1Endpoint) Ping() (PingResult, error) { - logrus.Debugf("attempting v1 ping for registry endpoint %s", e) - if e.String() == IndexServer { // Skip the check, we know this one is valid // (and we never want to fallback to http in case of error) - return PingResult{Standalone: false}, nil + return PingResult{}, nil } + logrus.Debugf("attempting v1 ping for registry endpoint %s", e) req, err := http.NewRequest(http.MethodGet, e.Path("_ping"), nil) if err != nil { - return PingResult{Standalone: false}, err + return PingResult{}, err } resp, err := e.client.Do(req) if err != nil { - return PingResult{Standalone: false}, err + return PingResult{}, err } defer resp.Body.Close() jsonString, err := io.ReadAll(resp.Body) if err != nil { - return PingResult{Standalone: false}, fmt.Errorf("error while reading the http response: %s", err) + return PingResult{}, fmt.Errorf("error while reading the http response: %s", err) } // If the header is absent, we assume true for compatibility with earlier @@ -166,13 +165,12 @@ func (e *V1Endpoint) Ping() (PingResult, error) { // don't stop here. Just assume sane defaults } if hdr := resp.Header.Get("X-Docker-Registry-Version"); hdr != "" { - logrus.Debugf("Registry version header: '%s'", hdr) info.Version = hdr } logrus.Debugf("PingResult.Version: %q", info.Version) standalone := resp.Header.Get("X-Docker-Registry-Standalone") - logrus.Debugf("Registry standalone header: '%s'", standalone) + // Accepted values are "true" (case-insensitive) and "1". if strings.EqualFold(standalone, "true") || standalone == "1" { info.Standalone = true