cleanOldEnvbuilders removes any old envbuilder containers.
()
| 2642 | |
| 2643 | // cleanOldEnvbuilders removes any old envbuilder containers. |
| 2644 | func 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 | |
| 2669 | func pushImage(t *testing.T, ref name.Reference, remoteOpt remote.Option, env ...string) v1.Image { |
| 2670 | t.Helper() |