Skip to content

Commit

Permalink
Merge pull request #1268 from aFlyBird0/fix-options-nil-pointer
Browse files Browse the repository at this point in the history
fix: options nil pointer error
  • Loading branch information
daniel-hutao authored Nov 29, 2022
2 parents 19e1a31 + 4906a0c commit 520d7e8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/pkg/configmanager/pipelinetemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func (p *pipelineRaw) getPipelineTemplate(templateMap map[string]string, globalV
t *pipelineTemplate
err error
)
if p.Options == nil {
p.Options = make(RawOptions)
}
switch p.Type {
case "template":
t, err = p.newPipelineFromTemplate(templateMap, globalVars)
Expand Down Expand Up @@ -66,6 +69,10 @@ func (p *pipelineRaw) newPipelineFromTemplate(templateMap map[string]string, glo
return nil, fmt.Errorf("%s parse pipelineTemplate yaml failed: %+w", p.TemplateName, err)
}

if t.Options == nil {
t.Options = make(RawOptions)
}

if err := mergo.Merge(&t.Options, p.Options, mergo.WithOverride); err != nil {
return nil, fmt.Errorf("%s merge template options faield: %+v", p.TemplateName, err)
}
Expand Down

0 comments on commit 520d7e8

Please sign in to comment.