Skip to content

Commit

Permalink
Merge pull request #1310 from 100mik/kctrl-build-values-fix
Browse files Browse the repository at this point in the history
Ensure that `--build-values` does not affect package output
  • Loading branch information
100mik committed Aug 24, 2023
2 parents 60a80de + 4a58d51 commit 2165849
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cli/pkg/kctrl/cmd/app/release/app_spec_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand Down Expand Up @@ -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
}
14 changes: 14 additions & 0 deletions cli/test/e2e/build_values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ namespace: test

// Verify that validation checks are not performed while running ytt to build packages
kappCtrl.RunWithOpts([]string{"package", "release", "--chdir", workingDir, "--build-values", "build-values.yml"}, RunOpts{NoNamespace: true})

// Ensure that flag does not affect package output
packageFile, err := os.ReadFile(path.Join(workingDir, "carvel-artifacts", "packages", "samplepackage.corp.com", "package.yml"))
if err != nil {
t.Fatal(err)
}
require.NotContains(t, string(packageFile), "valuesFrom")
})
}

Expand Down Expand Up @@ -313,5 +320,12 @@ fooVal: bar
t.Fatal(err)
}
kappCtrl.RunWithOpts([]string{"package", "release", "--chdir", workingDir, "--build-values", "build-values.yml"}, RunOpts{NoNamespace: true})

// Ensure that flag does not affect package output
packageFile, err := os.ReadFile(path.Join(workingDir, "carvel-artifacts", "packages", "samplepackage.corp.com", "package.yml"))
if err != nil {
t.Fatal(err)
}
require.NotContains(t, string(packageFile), "valuesFrom")
})
}

0 comments on commit 2165849

Please sign in to comment.