vendor: github.com/moby/buildkit 25bec7145b39 (v0.14.0-dev)

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2024-03-28 17:43:43 +01:00
parent 8abef59087
commit de5efcb03b
31 changed files with 402 additions and 232 deletions

View File

@ -25,7 +25,7 @@ func (nopLog) Logf(string, ...interface{}) {}
const (
shortLen = 12
defaultDockerdBinary = "dockerd"
DefaultDockerdBinary = "dockerd"
)
type Option func(*Daemon)
@ -43,6 +43,7 @@ type Daemon struct {
pidFile string
sockPath string
args []string
envs []string
}
var sockRoot = filepath.Join(os.TempDir(), "docker-integration")
@ -69,9 +70,10 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
storageDriver: os.Getenv("DOCKER_GRAPHDRIVER"),
// dxr stands for docker-execroot (shortened for avoiding unix(7) path length limitation)
execRoot: filepath.Join(os.TempDir(), "dxr", id),
dockerdBinary: defaultDockerdBinary,
dockerdBinary: DefaultDockerdBinary,
Log: nopLog{},
sockPath: filepath.Join(sockRoot, id+".sock"),
envs: append([]string{}, os.Environ()...),
}
for _, op := range ops {
@ -81,6 +83,18 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
return d, nil
}
func WithBinary(bin string) Option {
return func(d *Daemon) {
d.dockerdBinary = bin
}
}
func WithExtraEnv(envs []string) Option {
return func(d *Daemon) {
d.envs = append(d.envs, envs...)
}
}
func (d *Daemon) Sock() string {
return "unix://" + d.sockPath
}
@ -88,7 +102,7 @@ func (d *Daemon) Sock() string {
func (d *Daemon) StartWithError(daemonLogs map[string]*bytes.Buffer, providedArgs ...string) error {
dockerdBinary, err := exec.LookPath(d.dockerdBinary)
if err != nil {
return errors.Wrapf(err, "[%s] could not find docker binary in $PATH", d.id)
return errors.Wrapf(err, "[%s] could not find dockerd binary %q in $PATH", d.id, d.dockerdBinary)
}
if d.pidFile == "" {
@ -127,7 +141,7 @@ func (d *Daemon) StartWithError(daemonLogs map[string]*bytes.Buffer, providedArg
d.args = append(d.args, providedArgs...)
d.cmd = exec.Command(dockerdBinary, d.args...)
d.cmd.Env = append(os.Environ(), "DOCKER_SERVICE_PREFER_OFFLINE_IMAGE=1", "BUILDKIT_DEBUG_EXEC_OUTPUT=1", "BUILDKIT_DEBUG_PANIC_ON_ERROR=1")
d.cmd.Env = append(d.envs, "DOCKER_SERVICE_PREFER_OFFLINE_IMAGE=1", "BUILDKIT_DEBUG_EXEC_OUTPUT=1", "BUILDKIT_DEBUG_PANIC_ON_ERROR=1")
if daemonLogs != nil {
b := new(bytes.Buffer)