Skip to content

Commit

Permalink
fix: Global param value incorrectly overridden when loading from conf…
Browse files Browse the repository at this point in the history
…igmaps (#7515)

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
  • Loading branch information
terrytangyuan authored Jan 6, 2022
1 parent 0f206d6 commit 4b006d5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,10 @@ func (woc *wfOperationCtx) setGlobalParameters(executionParameters wfv1.Argument
woc.globalParams[common.GlobalVarWorkflowParameters] = string(workflowParameters)
}
for _, param := range executionParameters.Parameters {
if param.Value != nil {
woc.globalParams["workflow.parameters."+param.Name] = param.Value.String()
} else if param.ValueFrom != nil {
if param.Value == nil && param.ValueFrom == nil {
return fmt.Errorf("either value or valueFrom must be specified in order to set global parameter %s", param.Name)
}
if param.ValueFrom != nil {
if param.ValueFrom.ConfigMapKeyRef != nil {
cmValue, err := common.GetConfigMapValue(woc.controller.configMapInformer, woc.wf.ObjectMeta.Namespace, param.ValueFrom.ConfigMapKeyRef.Name, param.ValueFrom.ConfigMapKeyRef.Key)
if err != nil {
Expand All @@ -536,7 +537,7 @@ func (woc *wfOperationCtx) setGlobalParameters(executionParameters wfv1.Argument
woc.globalParams["workflow.parameters."+param.Name] = cmValue
}
} else {
return fmt.Errorf("either value or valueFrom must be specified in order to set global parameter %s", param.Name)
woc.globalParams["workflow.parameters."+param.Name] = param.Value.String()
}
}
if workflowAnnotations, err := json.Marshal(woc.wf.ObjectMeta.Annotations); err == nil {
Expand Down

0 comments on commit 4b006d5

Please sign in to comment.