瀏覽代碼

builder-next: make stub executor generic

The current executor is only tested on Linux, so let's be honest about
that. Stubbing this correctly helps avoid incorrectly trying to call
into Linux-only code in e.g. libnetwork.

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Bjorn Neergaard 2 年之前
父節點
當前提交
79a4cbbec9

+ 0 - 2
builder/builder-next/executor_unix.go → builder/builder-next/executor_linux.go

@@ -1,5 +1,3 @@
-//go:build !windows
-
 package buildkit
 
 import (

+ 33 - 0
builder/builder-next/executor_nolinux.go

@@ -0,0 +1,33 @@
+//go:build !linux
+
+package buildkit
+
+import (
+	"context"
+	"errors"
+	"runtime"
+
+	"github.com/docker/docker/daemon/config"
+	"github.com/docker/docker/libnetwork"
+	"github.com/docker/docker/pkg/idtools"
+	"github.com/moby/buildkit/executor"
+	"github.com/moby/buildkit/executor/oci"
+)
+
+func newExecutor(_, _ string, _ *libnetwork.Controller, _ *oci.DNSConfig, _ bool, _ idtools.IdentityMapping, _ string) (executor.Executor, error) {
+	return &stubExecutor{}, nil
+}
+
+type stubExecutor struct{}
+
+func (w *stubExecutor) Run(ctx context.Context, id string, root executor.Mount, mounts []executor.Mount, process executor.ProcessInfo, started chan<- struct{}) (err error) {
+	return errors.New("buildkit executor not implemented for "+runtime.GOOS)
+}
+
+func (w *stubExecutor) Exec(ctx context.Context, id string, process executor.ProcessInfo) error {
+	return errors.New("buildkit executor not implemented for "+runtime.GOOS)
+}
+
+func getDNSConfig(config.DNSConfig) *oci.DNSConfig {
+	return nil
+}

+ 0 - 30
builder/builder-next/executor_windows.go

@@ -1,30 +0,0 @@
-package buildkit
-
-import (
-	"context"
-	"errors"
-
-	"github.com/docker/docker/daemon/config"
-	"github.com/docker/docker/libnetwork"
-	"github.com/docker/docker/pkg/idtools"
-	"github.com/moby/buildkit/executor"
-	"github.com/moby/buildkit/executor/oci"
-)
-
-func newExecutor(_, _ string, _ *libnetwork.Controller, _ *oci.DNSConfig, _ bool, _ idtools.IdentityMapping, _ string) (executor.Executor, error) {
-	return &winExecutor{}, nil
-}
-
-type winExecutor struct{}
-
-func (w *winExecutor) Run(ctx context.Context, id string, root executor.Mount, mounts []executor.Mount, process executor.ProcessInfo, started chan<- struct{}) (err error) {
-	return errors.New("buildkit executor not implemented for windows")
-}
-
-func (w *winExecutor) Exec(ctx context.Context, id string, process executor.ProcessInfo) error {
-	return errors.New("buildkit executor not implemented for windows")
-}
-
-func getDNSConfig(config.DNSConfig) *oci.DNSConfig {
-	return nil
-}