mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-06 16:22:25 +00:00
Move constrain to only have a single command in backend to run to dedicated backends (#1032)
at the moment we compile a script that we can pipe in as single command this is because of the constrains the docker backend gives us. so we move it into the docker backend and eventually get rid of it altogether
This commit is contained in:
@@ -3,6 +3,7 @@ package kubernetes
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/backend/common"
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
@@ -10,8 +11,13 @@ import (
|
||||
)
|
||||
|
||||
func Pod(namespace string, step *types.Step) *v1.Pod {
|
||||
var vols []v1.Volume
|
||||
var volMounts []v1.VolumeMount
|
||||
var (
|
||||
vols []v1.Volume
|
||||
volMounts []v1.VolumeMount
|
||||
entrypoint []string
|
||||
args []string
|
||||
)
|
||||
|
||||
if step.WorkingDir != "" {
|
||||
for _, vol := range step.Volumes {
|
||||
vols = append(vols, v1.Volume{
|
||||
@@ -36,13 +42,13 @@ func Pod(namespace string, step *types.Step) *v1.Pod {
|
||||
pullPolicy = v1.PullAlways
|
||||
}
|
||||
|
||||
command := step.Entrypoint
|
||||
args := step.Command
|
||||
envs := mapToEnvVars(step.Environment)
|
||||
|
||||
if _, hasScript := step.Environment["CI_SCRIPT"]; !strings.HasSuffix(step.Name, "_clone") && hasScript {
|
||||
command = []string{"/bin/sh", "-c"}
|
||||
args = []string{"echo $CI_SCRIPT | base64 -d | /bin/sh -e"}
|
||||
if len(step.Commands) != 0 {
|
||||
scriptEnv, entry, cmds := common.GenerateContainerConf(step.Commands)
|
||||
for k, v := range scriptEnv {
|
||||
step.Environment[k] = v
|
||||
}
|
||||
entrypoint = entry
|
||||
args = cmds
|
||||
}
|
||||
|
||||
hostAliases := []v1.HostAlias{}
|
||||
@@ -97,10 +103,10 @@ func Pod(namespace string, step *types.Step) *v1.Pod {
|
||||
Name: podName(step),
|
||||
Image: step.Image,
|
||||
ImagePullPolicy: pullPolicy,
|
||||
Command: command,
|
||||
Command: entrypoint,
|
||||
Args: args,
|
||||
WorkingDir: step.WorkingDir,
|
||||
Env: envs,
|
||||
Env: mapToEnvVars(step.Environment),
|
||||
VolumeMounts: volMounts,
|
||||
Resources: resources,
|
||||
SecurityContext: &v1.SecurityContext{
|
||||
|
Reference in New Issue
Block a user