Skip to content

Commit

Permalink
When patching the {{}} placeholder in parameter, check for possible n…
Browse files Browse the repository at this point in the history
…il pointer (#3714)

* check nil for a pointer before using it

* if parameter's value is nil pointer, use parameter's default
  • Loading branch information
jingzhang36 authored May 9, 2020
1 parent fe01908 commit d2c784a
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions backend/src/apiserver/resource/resource_manager_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,25 @@ func OverrideParameterWithSystemDefault(workflow util.Workflow, apiRun *api.Run)
if servercommon.GetBoolConfigWithDefault(HasDefaultBucketEnvVar, false) {
patchedSlice := make([]wfv1.Parameter, 0)
for _, currentParam := range workflow.Spec.Arguments.Parameters {
desiredValue, err := PatchPipelineDefaultParameter(*currentParam.Value)
if err != nil {
return fmt.Errorf("failed to patch default value to pipeline. Error: %v", err)
if currentParam.Value != nil {
desiredValue, err := PatchPipelineDefaultParameter(*currentParam.Value)
if err != nil {
return fmt.Errorf("failed to patch default value to pipeline. Error: %v", err)
}
patchedSlice = append(patchedSlice, wfv1.Parameter{
Name: currentParam.Name,
Value: util.StringPointer(desiredValue),
})
} else if currentParam.Default != nil {
desiredValue, err := PatchPipelineDefaultParameter(*currentParam.Default)
if err != nil {
return fmt.Errorf("failed to patch default value to pipeline. Error: %v", err)
}
patchedSlice = append(patchedSlice, wfv1.Parameter{
Name: currentParam.Name,
Value: util.StringPointer(desiredValue),
})
}
patchedSlice = append(patchedSlice, wfv1.Parameter{
Name: currentParam.Name,
Value: util.StringPointer(desiredValue),
})
}
workflow.Spec.Arguments.Parameters = patchedSlice

Expand Down

0 comments on commit d2c784a

Please sign in to comment.