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

Function cleanOldEnvbuilders

integration/integration_test.go:2644–2667  ·  view source on GitHub ↗

cleanOldEnvbuilders removes any old envbuilder containers.

()

Source from the content-addressed store, hash-verified

2642
2643// cleanOldEnvbuilders removes any old envbuilder containers.
2644func cleanOldEnvbuilders() {
2645 ctx := context.Background()
2646 cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
2647 if err != nil {
2648 panic(err)
2649 }
2650 defer cli.Close()
2651 ctrs, err := cli.ContainerList(ctx, container.ListOptions{
2652 Filters: filters.NewArgs(filters.KeyValuePair{
2653 Key: "label",
2654 Value: testContainerLabel,
2655 }),
2656 })
2657 if err != nil {
2658 panic(err)
2659 }
2660 for _, ctr := range ctrs {
2661 if err := cli.ContainerRemove(ctx, ctr.ID, container.RemoveOptions{
2662 Force: true,
2663 }); err != nil {
2664 _, _ = fmt.Fprintf(os.Stderr, "failed to remove old test container: %s\n", err.Error())
2665 }
2666 }
2667}
2668
2669func pushImage(t *testing.T, ref name.Reference, remoteOpt remote.Option, env ...string) v1.Image {
2670 t.Helper()

Callers 1

TestMainFunction · 0.85

Calls 2

CloseMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected