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

Method iterateEndpoints

internal/registryclient/fetcher.go:218–275  ·  view source on GitHub ↗
(ctx context.Context, namedRef reference.Named, each func(context.Context, distribution.Repository, reference.Named) (bool, error))

Source from the content-addressed store, hash-verified

216}
217
218func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named, each func(context.Context, distribution.Repository, reference.Named) (bool, error)) error {
219 endpoints, err := allEndpoints(ctx, namedRef, c.insecureRegistry)
220 if err != nil {
221 return err
222 }
223
224 repoName := reference.Path(reference.TrimNamed(namedRef))
225 indexInfo := registry.NewIndexInfo(namedRef)
226
227 confirmedTLSRegistries := make(map[string]bool)
228 for _, endpoint := range endpoints {
229 if endpoint.URL.Scheme != "https" {
230 if _, confirmedTLS := confirmedTLSRegistries[endpoint.URL.Host]; confirmedTLS {
231 logrus.Debugf("skipping non-TLS endpoint %s for host/port that appears to use TLS", endpoint.URL)
232 continue
233 }
234 }
235
236 if c.insecureRegistry {
237 endpoint.TLSConfig.InsecureSkipVerify = true
238 }
239 repoEndpoint := repositoryEndpoint{
240 repoName: repoName,
241 indexInfo: indexInfo,
242 endpoint: endpoint,
243 }
244 repo, err := c.getRepositoryForReference(ctx, namedRef, repoEndpoint)
245 if err != nil {
246 logrus.Debugf("error %s with repo endpoint %+v", err, repoEndpoint)
247 var protoErr httpProtoError
248 if errors.As(err, &protoErr) {
249 continue
250 }
251 return err
252 }
253
254 if endpoint.URL.Scheme == "http" && !c.insecureRegistry {
255 logrus.Debugf("skipping non-tls registry endpoint: %s", endpoint.URL)
256 continue
257 }
258 done, err := each(ctx, repo, namedRef)
259 if err != nil {
260 if continueOnError(err) {
261 if endpoint.URL.Scheme == "https" {
262 confirmedTLSRegistries[endpoint.URL.Host] = true
263 }
264 logrus.Debugf("continuing on error (%T) %s", err, err)
265 continue
266 }
267 logrus.Debugf("not continuing on error (%T) %s", err, err)
268 return err
269 }
270 if done {
271 return nil
272 }
273 }
274 return notFoundError{errors.New("no such manifest: " + namedRef.String())}
275}

Callers 2

GetManifestMethod · 0.95
GetManifestListMethod · 0.95

Calls 5

allEndpointsFunction · 0.85
continueOnErrorFunction · 0.85
PathMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected