Skip to content

Commit

Permalink
no logical change
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Oct 29, 2022
1 parent 7fed813 commit 30f113f
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions pipeline/backend/kubernetes/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ 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"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

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{
Expand All @@ -36,6 +42,15 @@ func Pod(namespace string, step *types.Step) *v1.Pod {
pullPolicy = v1.PullAlways
}

if len(step.Commands) != 0 {
scriptEnv, entry, cmds := common.GenerateDockerConf(step.Commands)
for k, v := range scriptEnv {
step.Environment[k] = v
}
entrypoint = entry
args = cmds
}

hostAliases := []v1.HostAlias{}
for _, extraHost := range step.ExtraHosts {
host := strings.Split(extraHost, ":")
Expand Down Expand Up @@ -88,8 +103,8 @@ func Pod(namespace string, step *types.Step) *v1.Pod {
Name: podName(step),
Image: step.Image,
ImagePullPolicy: pullPolicy,
Command: step.Entrypoint,
Args: step.Commands,
Command: entrypoint,
Args: args,
WorkingDir: step.WorkingDir,
Env: mapToEnvVars(step.Environment),
VolumeMounts: volMounts,
Expand Down

0 comments on commit 30f113f

Please sign in to comment.