mirror of https://github.com/coder/coder.git
fix(helm/provisioner): run helm dependency update (#10982)
This commit is contained in:
parent
7f62085a02
commit
9ad96288b2
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue