Skip to content

fix(helm/provisioner): run helm dependency update #10982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions helm/provisioner/tests/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func TestRenderChart(t *testing.T) {

// Ensure that Helm is available in $PATH
helmPath := lookupHelm(t)
err := updateHelmDependencies(t, helmPath, "..")
require.NoError(t, err, "failed to build Helm dependencies")
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
Expand Down Expand Up @@ -144,6 +146,26 @@ func TestUpdateGoldenFiles(t *testing.T) {
t.Log("Golden files updated. Please review the changes and commit them.")
}

// updateHelmDependencies runs `helm dependency update .` on the given chartDir.
func updateHelmDependencies(t testing.TB, helmPath, chartDir string) error {
// Remove charts/ from chartDir if it exists.
err := os.RemoveAll(filepath.Join(chartDir, "charts"))
if err != nil {
return xerrors.Errorf("failed to remove charts/ directory: %w", err)
}

// Regenerate the chart dependencies.
cmd := exec.Command(helmPath, "dependency", "update", "--skip-refresh", ".")
cmd.Dir = chartDir
t.Logf("exec command: %v", cmd.Args)
out, err := cmd.CombinedOutput()
if err != nil {
return xerrors.Errorf("failed to run `helm dependency build`: %w\noutput: %s", err, out)
}

return nil
}

// runHelmTemplate runs helm template on the given chart with the given values and
// returns the raw output.
func runHelmTemplate(t testing.TB, helmPath, chartDir, valuesFilePath string) (string, error) {
Expand Down