From 89e0834e5fe8c00738e23374057fdbcdac7b19cc Mon Sep 17 00:00:00 2001 From: Atanas Dinov Date: Tue, 9 Apr 2024 19:24:40 +0300 Subject: [PATCH] Fix locating downloaded Helm charts (#366) * Download each Helm chart in separate subdirectory Signed-off-by: Atanas Dinov * Update release notes Signed-off-by: Atanas Dinov --------- Signed-off-by: Atanas Dinov --- RELEASE_NOTES.md | 1 + pkg/helm/helm.go | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 0528cd3f..c509d59a 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -18,6 +18,7 @@ * [#355](https://github.com/suse-edge/edge-image-builder/issues/355) - Helm fails getting charts stored in unauthenticated OCI registries * [#359](https://github.com/suse-edge/edge-image-builder/issues/359) - Helm validation does not check if a chart uses an undefined repository * [#362](https://github.com/suse-edge/edge-image-builder/issues/362) - Helm templating failure +* [#365](https://github.com/suse-edge/edge-image-builder/issues/365) - Unable to locate downloaded Helm charts --- diff --git a/pkg/helm/helm.go b/pkg/helm/helm.go index 2c623c09..d939856e 100644 --- a/pkg/helm/helm.go +++ b/pkg/helm/helm.go @@ -150,7 +150,12 @@ func (h *Helm) Pull(chart string, repo *image.HelmRepository, version, destDir s } }() - cmd := pullCommand(chart, repo, version, destDir, h.certsDir, file) + chartDir := filepath.Join(destDir, chart) + if err = os.MkdirAll(chartDir, os.ModePerm); err != nil { + return "", fmt.Errorf("creating chart dir %q: %w", chartDir, err) + } + + cmd := pullCommand(chart, repo, version, chartDir, h.certsDir, file) if _, err = fmt.Fprintf(file, "command: %s\n", cmd); err != nil { return "", fmt.Errorf("writing command prefix to log file: %w", err) @@ -160,7 +165,7 @@ func (h *Helm) Pull(chart string, repo *image.HelmRepository, version, destDir s return "", fmt.Errorf("executing command: %w", err) } - chartPathPattern := fmt.Sprintf("%s-*.tgz", filepath.Join(destDir, chart)) + chartPathPattern := fmt.Sprintf("%s/%s-*.tgz", chartDir, chart) matches, err := filepath.Glob(chartPathPattern) if err != nil {