Skip to content

Commit

Permalink
Fix #1340 parameter substitution bug (#1345)
Browse files Browse the repository at this point in the history
Also create podParams map in substitutePodParams

Signed-off-by: Ilias Katsakioris <[email protected]>
  • Loading branch information
elikatsis authored and jessesuen committed May 7, 2019
1 parent 60b6519 commit ee788a8
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions workflow/controller/workflowpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,7 @@ func (woc *wfOperationCtx) createWorkflowPod(nodeName string, mainCtr apiv1.Cont
// Perform one last variable substitution here. Some variables come from the from workflow
// configmap (e.g. archive location) or volumes attribute, and were not substituted
// in executeTemplate.
podParams := woc.globalParams
for _, inParam := range tmpl.Inputs.Parameters {
podParams["inputs.parameters."+inParam.Name] = *inParam.Value
}
pod, err = substitutePodParams(pod, podParams)
pod, err = substitutePodParams(pod, woc.globalParams, tmpl)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -226,13 +222,15 @@ func (woc *wfOperationCtx) createWorkflowPod(nodeName string, mainCtr apiv1.Cont
}

// substitutePodParams returns a pod spec with parameter references substituted as well as pod.name
func substitutePodParams(pod *apiv1.Pod, podParams map[string]string) (*apiv1.Pod, error) {
newPodParams := make(map[string]string)
for k, v := range podParams {
newPodParams[k] = v
func substitutePodParams(pod *apiv1.Pod, globalParams map[string]string, tmpl *wfv1.Template) (*apiv1.Pod, error) {
podParams := make(map[string]string)
for k, v := range globalParams {
podParams[k] = v
}
for _, inParam := range tmpl.Inputs.Parameters {
podParams["inputs.parameters."+inParam.Name] = *inParam.Value
}
newPodParams[common.LocalVarPodName] = pod.Name
podParams = newPodParams
podParams[common.LocalVarPodName] = pod.Name
specBytes, err := json.Marshal(pod)
if err != nil {
return nil, err
Expand Down

0 comments on commit ee788a8

Please sign in to comment.