build: prefer local image resolution for docker driver

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2023-06-21 00:13:44 +02:00
parent b3a4f95110
commit c2500ea2d8
3 changed files with 70 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package tests
import (
"os"
"os/exec"
"strings"
"testing"
"github.com/containerd/continuity/fs/fstest"
@ -55,3 +56,20 @@ func buildxCmd(sb integration.Sandbox, opts ...cmdOpt) *exec.Cmd {
return cmd
}
func dockerCmd(sb integration.Sandbox, opts ...cmdOpt) *exec.Cmd {
cmd := exec.Command("docker")
cmd.Env = append([]string{}, os.Environ()...)
for _, opt := range opts {
opt(cmd)
}
if context := sb.DockerAddress(); context != "" {
cmd.Env = append(cmd.Env, "DOCKER_CONTEXT="+context)
}
return cmd
}
func isDockerWorker(sb integration.Sandbox) bool {
sbDriver, _, _ := strings.Cut(sb.Name(), "+")
return sbDriver == "docker"
}