Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1340 parameter substitution bug #1345

Merged
merged 1 commit into from
May 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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