From daa8e102da1f3f838f574dcf18440e80e3402dfe Mon Sep 17 00:00:00 2001 From: Christoph Barbian Date: Thu, 1 May 2025 13:18:32 +0200 Subject: [PATCH] HelmGenerator: fix path handling in .Files builtin --- internal/helm/chart.go | 9 +++++++-- internal/helm/files.go | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/helm/chart.go b/internal/helm/chart.go index 3bdd3c37..397f2b9e 100644 --- a/internal/helm/chart.go +++ b/internal/helm/chart.go @@ -125,7 +125,7 @@ func ParseChart(fsys fs.FS, chartPath string, parent *Chart) (*Chart, error) { } chart.files = Files{} - files, err := fileutils.Find(fsys, "", "", fileutils.FileTypeRegular|fileutils.FileTypeSymlink, 0) + files, err := fileutils.Find(fsys, filepath.Clean(chartPath), "", fileutils.FileTypeRegular|fileutils.FileTypeSymlink, 0) if err != nil { return nil, err } @@ -134,7 +134,12 @@ func ParseChart(fsys fs.FS, chartPath string, parent *Chart) (*Chart, error) { if err != nil { return nil, err } - chart.files.add(file, raw) + name, err := filepath.Rel(chartPath, file) + if err != nil { + // TODO: is it ok to panic here in case of error ? + panic("this cannot happen") + } + chart.files.add(name, raw) } valuesRaw, err := fs.ReadFile(fsys, filepath.Clean(chartPath+"/values.yaml")) diff --git a/internal/helm/files.go b/internal/helm/files.go index 23922eae..fbbde14f 100644 --- a/internal/helm/files.go +++ b/internal/helm/files.go @@ -88,6 +88,7 @@ func (f Files) AsSecrets() string { func isIgnored(name string) bool { return name == "Chart.yaml" || + name == "Chart.lock" || name == "LICENSE" || name == "README.md" || name == "values.yaml" ||