MCPcopy Index your code
hub / github.com/coder/envbox / waitForRegistry

Function waitForRegistry

integration/integrationtest/docker.go:485–519  ·  view source on GitHub ↗
(t testing.TB, pool *dockertest.Pool, resource *dockertest.Resource, url string)

Source from the content-addressed store, hash-verified

483}
484
485func waitForRegistry(t testing.TB, pool *dockertest.Pool, resource *dockertest.Resource, url string) {
486 t.Helper()
487
488 //nolint:forcetypeassert
489 transport := http.DefaultTransport.(*http.Transport).Clone()
490 transport.TLSClientConfig = &tls.Config{
491 // We're not interested in asserting the validity
492 // of the certificate when pushing the image
493 // since this is setup.
494 //nolint:gosec
495 InsecureSkipVerify: true,
496 }
497 client := &http.Client{
498 Transport: transport,
499 }
500
501 ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
502 defer cancel()
503 for r := retry.New(time.Second, time.Second); r.Wait(ctx); {
504 container, err := pool.Client.InspectContainer(resource.Container.ID)
505 require.NoError(t, err)
506 require.True(t, container.State.Running, "%v unexpectedly exited", container.ID)
507
508 //nolint:noctx
509 res, err := client.Get(url)
510 if err != nil {
511 continue
512 }
513 _ = res.Body.Close()
514 if res.StatusCode == http.StatusOK || res.StatusCode == http.StatusUnauthorized {
515 return
516 }
517 }
518 require.NoError(t, ctx.Err())
519}
520
521type pushOptions struct {
522 Host string

Callers 1

RunLocalDockerRegistryFunction · 0.85

Calls 2

CloseMethod · 0.65
WaitMethod · 0.45

Tested by

no test coverage detected