Skip to content
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
15 changes: 14 additions & 1 deletion pkg/workflow_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateID uint64, wor
if opts == nil {
opts = &WorkflowExecutionOptions{}
}

if opts.Name != "" {
wf.ObjectMeta.Name = opts.Name
}
Expand Down Expand Up @@ -460,6 +459,20 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateID uint64, wor
wf.ObjectMeta.Labels = opts.Labels
}

newParameters := make([]wfv1.Parameter, 0)
for i := range wf.Spec.Arguments.Parameters {
param := wf.Spec.Arguments.Parameters[i]
if param.Value != nil {
// Strip out whitespace from parameter value
formattedValue := strings.Replace(*param.Value, " ", "", -1)
*param.Value = strings.Replace(formattedValue, "{{workflow.namespace}}", namespace, -1)
*param.Value = strings.Replace(*param.Value, "{{workspace.namespace}}", namespace, -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this use formattedValue too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushtehrani Do you mean the 3rd line there?

*param.Value = strings.Replace(*param.Value, "{{workspace.namespace}}", namespace, -1)

If so, no. It is correct because we replace workflow.namespace above. If we set it to formattedValue we would clear out those changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah got it. Minor: might be cleaner to use ReplaceAll - it calls Replace with -1 internally.

}

newParameters = append(newParameters, param)
}
wf.Spec.Arguments.Parameters = newParameters

if err = injectWorkflowExecutionStatusCaller(wf, wfv1.NodeRunning); err != nil {
return nil, err
}
Expand Down