Skip to content

Commit 9ad9628

Browse files
authored
fix(helm/provisioner): run helm dependency update (#10982)
1 parent 7f62085 commit 9ad9628

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

helm/provisioner/tests/chart_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ func TestRenderChart(t *testing.T) {
8585

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

149+
// updateHelmDependencies runs `helm dependency update .` on the given chartDir.
150+
func updateHelmDependencies(t testing.TB, helmPath, chartDir string) error {
151+
// Remove charts/ from chartDir if it exists.
152+
err := os.RemoveAll(filepath.Join(chartDir, "charts"))
153+
if err != nil {
154+
return xerrors.Errorf("failed to remove charts/ directory: %w", err)
155+
}
156+
157+
// Regenerate the chart dependencies.
158+
cmd := exec.Command(helmPath, "dependency", "update", "--skip-refresh", ".")
159+
cmd.Dir = chartDir
160+
t.Logf("exec command: %v", cmd.Args)
161+
out, err := cmd.CombinedOutput()
162+
if err != nil {
163+
return xerrors.Errorf("failed to run `helm dependency build`: %w\noutput: %s", err, out)
164+
}
165+
166+
return nil
167+
}
168+
147169
// runHelmTemplate runs helm template on the given chart with the given values and
148170
// returns the raw output.
149171
func runHelmTemplate(t testing.TB, helmPath, chartDir, valuesFilePath string) (string, error) {

0 commit comments

Comments
 (0)