Skip to content

Commit 64882c0

Browse files
Merge pull request #20710 from deads2k/template-02-process
allow substitution of legacy api kinds in templates
2 parents dc57952 + cefdd09 commit 64882c0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/template/templateprocessing/template.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,17 @@ func (p *Processor) Process(template *templateapi.Template) field.ErrorList {
8686
// referenced namespace.
8787
stripNamespace(item)
8888

89+
newItem, err := p.SubstituteParameters(paramMap, item)
90+
if err != nil {
91+
templateErrors = append(templateErrors, field.Invalid(idxPath.Child("parameters"), template.Parameters, err.Error()))
92+
}
93+
8994
// this changes oapi GVKs to groupified GVKs so they can be submitted to modern, aggregated servers
95+
// It is done after substitution in case someone substitutes a kind.
9096
gvk := item.GetObjectKind().GroupVersionKind()
9197
legacygroupification.OAPIToGroupifiedGVK(&gvk)
9298
item.GetObjectKind().SetGroupVersionKind(gvk)
9399

94-
newItem, err := p.SubstituteParameters(paramMap, item)
95-
if err != nil {
96-
templateErrors = append(templateErrors, field.Invalid(idxPath.Child("parameters"), template.Parameters, err.Error()))
97-
}
98100
if err := util.AddObjectLabels(newItem, template.ObjectLabels); err != nil {
99101
templateErrors = append(templateErrors, field.Invalid(idxPath.Child("labels"),
100102
template.ObjectLabels, fmt.Sprintf("label could not be applied: %v", err)))

0 commit comments

Comments
 (0)