From 1cc8122ec8f7b3f9c5ea9f7e160c6d95d47d58c2 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Sat, 26 Feb 2022 03:02:42 +0100 Subject: [PATCH] Support all backends for cli exec (#801) --- cli/exec/exec.go | 13 +++++++++---- cli/exec/flags.go | 10 ++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cli/exec/exec.go b/cli/exec/exec.go index da569fb0b0..641ae5485e 100644 --- a/cli/exec/exec.go +++ b/cli/exec/exec.go @@ -16,8 +16,8 @@ import ( "github.com/woodpecker-ci/woodpecker/cli/common" "github.com/woodpecker-ci/woodpecker/pipeline" - "github.com/woodpecker-ci/woodpecker/pipeline/backend/docker" - backend "github.com/woodpecker-ci/woodpecker/pipeline/backend/types" + "github.com/woodpecker-ci/woodpecker/pipeline/backend" + backendTypes "github.com/woodpecker-ci/woodpecker/pipeline/backend/types" "github.com/woodpecker-ci/woodpecker/pipeline/frontend" "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml" "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/compiler" @@ -180,7 +180,12 @@ func execWithAxis(c *cli.Context, file, repoPath string, axis matrix.Axis) error compiler.WithSecret(secrets...), compiler.WithEnviron(droneEnv), ).Compile(conf) - engine := docker.New() + + engine, err := backend.FindEngine(c.String("backend-engine")) + if err != nil { + return err + } + if err = engine.Load(); err != nil { return err } @@ -273,7 +278,7 @@ func convertPathForWindows(path string) string { return filepath.ToSlash(path) } -var defaultLogger = pipeline.LogFunc(func(proc *backend.Step, rc multipart.Reader) error { +var defaultLogger = pipeline.LogFunc(func(proc *backendTypes.Step, rc multipart.Reader) error { part, err := rc.NextPart() if err != nil { return err diff --git a/cli/exec/flags.go b/cli/exec/flags.go index 68ff0cefcd..4122668675 100644 --- a/cli/exec/flags.go +++ b/cli/exec/flags.go @@ -46,10 +46,10 @@ var flags = []cli.Flag{ Usage: "external networks", }, &cli.StringFlag{ - EnvVars: []string{"WOODPECKER_DOCKER_PREFIX"}, + EnvVars: []string{"WOODPECKER_PREFIX"}, Name: "prefix", Value: "woodpecker", - Usage: "prefix containers created by woodpecker", + Usage: "prefix used for containers, volumes, networks, ... created by woodpecker", Hidden: true, }, &cli.StringSliceFlag{ @@ -57,6 +57,12 @@ var flags = []cli.Flag{ Usage: "privileged plugins", Value: cli.NewStringSlice(constant.PrivilegedPlugins...), }, + &cli.StringFlag{ + EnvVars: []string{"WOODPECKER_BACKEND"}, + Name: "backend-engine", + Usage: "backend engine to run pipelines on", + Value: "auto-detect", + }, // // Please note the below flags should match the flags from