MCPcopy Create free account
hub / github.com/coder/envbuilder / getCachedImage

Function getCachedImage

integration/integration_test.go:2704–2723  ·  view source on GitHub ↗
(ctx context.Context, t *testing.T, cli *client.Client, env ...string)

Source from the content-addressed store, hash-verified

2702}
2703
2704func getCachedImage(ctx context.Context, t *testing.T, cli *client.Client, env ...string) name.Reference {
2705 ctrID, err := runEnvbuilder(t, runOpts{env: append(env, envbuilderEnv("GET_CACHED_IMAGE", "1"))})
2706 require.NoError(t, err)
2707
2708 logs, err := cli.ContainerLogs(ctx, ctrID, container.LogsOptions{
2709 ShowStdout: true,
2710 ShowStderr: true,
2711 })
2712 require.NoError(t, err)
2713 defer logs.Close()
2714 logBytes, err := io.ReadAll(logs)
2715 require.NoError(t, err)
2716
2717 re := regexp.MustCompile(`ENVBUILDER_CACHED_IMAGE=(\S+)`)
2718 matches := re.FindStringSubmatch(string(logBytes))
2719 require.Len(t, matches, 2, "envbuilder cached image not found")
2720 ref, err := name.ParseReference(matches[1])
2721 require.NoError(t, err, "failed to parse cached image reference")
2722 return ref
2723}
2724
2725func startContainerFromRef(ctx context.Context, t *testing.T, cli *client.Client, ref name.Reference) container.CreateResponse {
2726 t.Helper()

Callers 1

TestPushImageFunction · 0.85

Calls 3

runEnvbuilderFunction · 0.85
envbuilderEnvFunction · 0.85
CloseMethod · 0.80

Tested by

no test coverage detected