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 and alexec committed Jan 27, 2022
1 parent db58583 commit 74ed83a
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 @@ -523,9 +523,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 @@ -535,7 +536,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()
}
}
for k, v := range woc.wf.ObjectMeta.Annotations {
Expand Down

0 comments on commit 74ed83a

Please sign in to comment.