diff --git a/cli/pkg/kctrl/cmd/app/release/app_spec_builder.go b/cli/pkg/kctrl/cmd/app/release/app_spec_builder.go index f5e97b371..8d4ab68f5 100644 --- a/cli/pkg/kctrl/cmd/app/release/app_spec_builder.go +++ b/cli/pkg/kctrl/cmd/app/release/app_spec_builder.go @@ -65,7 +65,7 @@ func (b *AppSpecBuilder) Build() (kcv1alpha1.AppSpec, error) { Git: &kcv1alpha1.AppFetchGit{}, }, }, - Template: b.opts.BuildTemplate, + Template: b.deepCopyAppTemplateList(b.opts.BuildTemplate), Deploy: b.opts.BuildDeploy, }, } @@ -169,3 +169,12 @@ func (b *AppSpecBuilder) checkForErrorsAfterReconciliation(app kcv1alpha1.App, f } return nil } + +func (b *AppSpecBuilder) deepCopyAppTemplateList(src []kcv1alpha1.AppTemplate) []kcv1alpha1.AppTemplate { + copy := []kcv1alpha1.AppTemplate{} + for _, templateStep := range src { + templateStepCopy := templateStep.DeepCopy() + copy = append(copy, *templateStepCopy) + } + return copy +}