MCPcopy Create free account
hub / github.com/docker/cli / PingV2Registry

Function PingV2Registry

internal/registry/auth.go:104–126  ·  view source on GitHub ↗

PingV2Registry attempts to ping a v2 registry and on success return a challenge manager for the supported authentication types. If a response is received but cannot be interpreted, a PingResponseError will be returned.

(endpoint *url.URL, authTransport http.RoundTripper)

Source from the content-addressed store, hash-verified

102// challenge manager for the supported authentication types.
103// If a response is received but cannot be interpreted, a PingResponseError will be returned.
104func PingV2Registry(endpoint *url.URL, authTransport http.RoundTripper) (challenge.Manager, error) {
105 endpointStr := strings.TrimRight(endpoint.String(), "/") + "/v2/"
106 req, err := http.NewRequest(http.MethodGet, endpointStr, http.NoBody)
107 if err != nil {
108 return nil, err
109 }
110 pingClient := &http.Client{
111 Transport: authTransport,
112 Timeout: 15 * time.Second,
113 }
114 resp, err := pingClient.Do(req)
115 if err != nil {
116 return nil, err
117 }
118 defer resp.Body.Close()
119
120 challengeManager := challenge.NewSimpleManager()
121 if err := challengeManager.AddResponse(resp); err != nil {
122 return nil, err
123 }
124
125 return challengeManager, nil
126}

Callers 1

v2AuthHTTPClientFunction · 0.85

Calls 2

StringMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…