Skip to content

Commit

Permalink
Merge pull request #834 from rushtehrani/fix/params
Browse files Browse the repository at this point in the history
fix: Only remove whitespaces in var references
  • Loading branch information
rushtehrani authored Jan 12, 2021
2 parents 2c187ad + 1d0c898 commit 709871d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/workflow_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/watch"
"net/http"
"regexp"
yaml2 "sigs.k8s.io/yaml"
"strconv"
"strings"
Expand Down Expand Up @@ -463,11 +464,12 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateID uint64, wor
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.ReplaceAll(*param.Value, " ", "")
param.Value = &formattedValue
*param.Value = strings.ReplaceAll(*param.Value, "{{workflow.namespace}}", namespace)
*param.Value = strings.ReplaceAll(*param.Value, "{{workspace.namespace}}", namespace)
re, reErr := regexp.Compile(`{{\s*workflow.namespace\s*}}|{{\s*workspace.namespace\s*}}`)
if reErr != nil {
return nil, reErr
}
value := re.ReplaceAllString(*param.Value, namespace)
param.Value = &value
}

newParameters = append(newParameters, param)
Expand Down

0 comments on commit 709871d

Please sign in to comment.