Support all backends for cli exec (#801)

This commit is contained in:
Anbraten 2022-02-26 03:02:42 +01:00 committed by GitHub
parent 52d8097290
commit 1cc8122ec8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View file

@ -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

View file

@ -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