Skip to content

Commit 2e47560

Browse files
authored
HelmGenerator: fix path handling in .Files builtin (#280)
1 parent 662b899 commit 2e47560

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

internal/helm/chart.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func ParseChart(fsys fs.FS, chartPath string, parent *Chart) (*Chart, error) {
125125
}
126126

127127
chart.files = Files{}
128-
files, err := fileutils.Find(fsys, "", "", fileutils.FileTypeRegular|fileutils.FileTypeSymlink, 0)
128+
files, err := fileutils.Find(fsys, filepath.Clean(chartPath), "", fileutils.FileTypeRegular|fileutils.FileTypeSymlink, 0)
129129
if err != nil {
130130
return nil, err
131131
}
@@ -134,7 +134,12 @@ func ParseChart(fsys fs.FS, chartPath string, parent *Chart) (*Chart, error) {
134134
if err != nil {
135135
return nil, err
136136
}
137-
chart.files.add(file, raw)
137+
name, err := filepath.Rel(chartPath, file)
138+
if err != nil {
139+
// TODO: is it ok to panic here in case of error ?
140+
panic("this cannot happen")
141+
}
142+
chart.files.add(name, raw)
138143
}
139144

140145
valuesRaw, err := fs.ReadFile(fsys, filepath.Clean(chartPath+"/values.yaml"))

internal/helm/files.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func (f Files) AsSecrets() string {
8888

8989
func isIgnored(name string) bool {
9090
return name == "Chart.yaml" ||
91+
name == "Chart.lock" ||
9192
name == "LICENSE" ||
9293
name == "README.md" ||
9394
name == "values.yaml" ||

0 commit comments

Comments
 (0)