mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-09 17:15:31 +00:00
Move value of default clone image into shared constant package (#873)
This commit is contained in:
parent
c3788d943f
commit
58303dd2a7
5 changed files with 35 additions and 23 deletions
|
@ -101,7 +101,7 @@ var flags = []cli.Flag{
|
||||||
EnvVars: []string{"WOODPECKER_DEFAULT_CLONE_IMAGE"},
|
EnvVars: []string{"WOODPECKER_DEFAULT_CLONE_IMAGE"},
|
||||||
Name: "default-clone-image",
|
Name: "default-clone-image",
|
||||||
Usage: "The default docker image to be used when cloning the repo",
|
Usage: "The default docker image to be used when cloning the repo",
|
||||||
Value: "woodpeckerci/plugin-git:latest",
|
Value: constant.DefaultCloneImage,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DOCS"},
|
EnvVars: []string{"WOODPECKER_DOCS"},
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
"github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
||||||
"github.com/woodpecker-ci/woodpecker/server"
|
"github.com/woodpecker-ci/woodpecker/shared/constant"
|
||||||
)
|
)
|
||||||
|
|
||||||
type local struct {
|
type local struct {
|
||||||
|
@ -56,13 +56,7 @@ func (e *local) Exec(ctx context.Context, proc *types.Step) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get default clone image
|
if proc.Image == constant.DefaultCloneImage {
|
||||||
defaultCloneImage := "docker.io/woodpeckerci/plugin-git:latest"
|
|
||||||
if len(server.Config.Pipeline.DefaultCloneImage) > 0 {
|
|
||||||
defaultCloneImage = server.Config.Pipeline.DefaultCloneImage
|
|
||||||
}
|
|
||||||
|
|
||||||
if proc.Image == defaultCloneImage {
|
|
||||||
// Default clone step
|
// Default clone step
|
||||||
Command = append(Command, "CI_WORKSPACE="+e.workingdir+"/"+proc.Environment["CI_REPO"])
|
Command = append(Command, "CI_WORKSPACE="+e.workingdir+"/"+proc.Environment["CI_REPO"])
|
||||||
Command = append(Command, "plugin-git")
|
Command = append(Command, "plugin-git")
|
||||||
|
@ -81,7 +75,7 @@ func (e *local) Exec(ctx context.Context, proc *types.Step) error {
|
||||||
e.cmd = exec.CommandContext(ctx, "/bin/env", Command...)
|
e.cmd = exec.CommandContext(ctx, "/bin/env", Command...)
|
||||||
|
|
||||||
// Prepare working directory
|
// Prepare working directory
|
||||||
if proc.Image == defaultCloneImage {
|
if proc.Image == constant.DefaultCloneImage {
|
||||||
e.cmd.Dir = e.workingdir + "/" + proc.Environment["CI_REPO_OWNER"]
|
e.cmd.Dir = e.workingdir + "/" + proc.Environment["CI_REPO_OWNER"]
|
||||||
} else {
|
} else {
|
||||||
e.cmd.Dir = e.workingdir + "/" + proc.Environment["CI_REPO"]
|
e.cmd.Dir = e.workingdir + "/" + proc.Environment["CI_REPO"]
|
||||||
|
@ -112,6 +106,6 @@ func (e *local) Tail(context.Context, *types.Step) (io.ReadCloser, error) {
|
||||||
|
|
||||||
// Destroy the pipeline environment.
|
// Destroy the pipeline environment.
|
||||||
func (e *local) Destroy(context.Context, *types.Config) error {
|
func (e *local) Destroy(context.Context, *types.Config) error {
|
||||||
os.RemoveAll(e.cmd.Dir)
|
_ = os.RemoveAll(e.cmd.Dir)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
backend "github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
backend "github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
||||||
"github.com/woodpecker-ci/woodpecker/pipeline/frontend"
|
"github.com/woodpecker-ci/woodpecker/pipeline/frontend"
|
||||||
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml"
|
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml"
|
||||||
|
"github.com/woodpecker-ci/woodpecker/shared/constant"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO(bradrydzewski) compiler should handle user-defined volumes from YAML
|
// TODO(bradrydzewski) compiler should handle user-defined volumes from YAML
|
||||||
|
@ -15,7 +16,6 @@ import (
|
||||||
const (
|
const (
|
||||||
windowsPrefix = "windows/"
|
windowsPrefix = "windows/"
|
||||||
|
|
||||||
defaultCloneImage = "woodpeckerci/plugin-git:latest"
|
|
||||||
defaultCloneName = "clone"
|
defaultCloneName = "clone"
|
||||||
|
|
||||||
networkDriverNAT = "nat"
|
networkDriverNAT = "nat"
|
||||||
|
@ -121,7 +121,7 @@ func (c *Compiler) Compile(conf *yaml.Config) *backend.Config {
|
||||||
|
|
||||||
// add default clone step
|
// add default clone step
|
||||||
if !c.local && len(conf.Clone.Containers) == 0 && !conf.SkipClone {
|
if !c.local && len(conf.Clone.Containers) == 0 && !conf.SkipClone {
|
||||||
cloneImage := defaultCloneImage
|
cloneImage := constant.DefaultCloneImage
|
||||||
if len(c.defaultCloneImage) > 0 {
|
if len(c.defaultCloneImage) > 0 {
|
||||||
cloneImage = c.defaultCloneImage
|
cloneImage = c.defaultCloneImage
|
||||||
}
|
}
|
||||||
|
|
27
shared/constant/constant.go
Normal file
27
shared/constant/constant.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright 2022 Woodpecker Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package constant
|
||||||
|
|
||||||
|
var PrivilegedPlugins = []string{
|
||||||
|
"plugins/docker",
|
||||||
|
"plugins/gcr",
|
||||||
|
"plugins/ecr",
|
||||||
|
"woodpeckerci/plugin-docker",
|
||||||
|
"woodpeckerci/plugin-docker-buildx",
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultCloneImage = "docker.io/woodpeckerci/plugin-git:latest"
|
||||||
|
)
|
|
@ -1,9 +0,0 @@
|
||||||
package constant
|
|
||||||
|
|
||||||
var PrivilegedPlugins = []string{
|
|
||||||
"plugins/docker",
|
|
||||||
"plugins/gcr",
|
|
||||||
"plugins/ecr",
|
|
||||||
"woodpeckerci/plugin-docker",
|
|
||||||
"woodpeckerci/plugin-docker-buildx",
|
|
||||||
}
|
|
Loading…
Reference in a new issue