mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
fix(chart): normalize CRD filenames to use forward slashes on all platforms
Fixes https://github.com/helm/helm/issues/31585 by normalizing CRD Filename values with filepath.ToSlash so Windows no longer emits backslashes. This ensures TestCRDObjects passes cross-platform and CRD paths remain consistent. Added test TestCRDObjectsWithSubchart to verify forward slash normalization for both parent and subchart CRDs. Signed-off-by: Insaf Hashem <hasheminsafo@gmail.com> Signed-off-by: Helm Contributor <contributor@helm.sh>
This commit is contained in:
parent
5d2ab10caa
commit
2d5cb11d78
2 changed files with 51 additions and 1 deletions
|
|
@ -162,7 +162,7 @@ func (ch *Chart) CRDObjects() []CRD {
|
|||
// Find all resources in the crds/ directory
|
||||
for _, f := range ch.Files {
|
||||
if strings.HasPrefix(f.Name, "crds/") && hasManifestExtension(f.Name) {
|
||||
mycrd := CRD{Name: f.Name, Filename: filepath.Join(ch.ChartFullPath(), f.Name), File: f}
|
||||
mycrd := CRD{Name: f.Name, Filename: filepath.ToSlash(filepath.Join(ch.ChartFullPath(), f.Name)), File: f}
|
||||
crds = append(crds, mycrd)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,3 +227,53 @@ func TestCRDObjects(t *testing.T) {
|
|||
crds := chrt.CRDObjects()
|
||||
is.Equal(expected, crds)
|
||||
}
|
||||
|
||||
func TestCRDObjectsWithSubchart(t *testing.T) {
|
||||
modTime := time.Now()
|
||||
|
||||
// Create a subchart
|
||||
subchart := &Chart{
|
||||
Metadata: &Metadata{
|
||||
Name: "subchart",
|
||||
},
|
||||
Files: []*common.File{
|
||||
{
|
||||
Name: "crds/subchartcrd.yaml",
|
||||
ModTime: modTime,
|
||||
Data: []byte("subchart crd"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Create a parent chart with a dependency
|
||||
parentChart := &Chart{
|
||||
Metadata: &Metadata{
|
||||
Name: "parent",
|
||||
},
|
||||
Files: []*common.File{
|
||||
{
|
||||
Name: "crds/parentcrd.yaml",
|
||||
ModTime: modTime,
|
||||
Data: []byte("parent crd"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
parentChart.AddDependency(subchart)
|
||||
|
||||
is := assert.New(t)
|
||||
crds := parentChart.CRDObjects()
|
||||
|
||||
// Verify we have CRDs from both parent and subchart
|
||||
is.Equal(2, len(crds))
|
||||
|
||||
// Verify parent CRD has forward slashes (not backslashes)
|
||||
is.Equal("crds/parentcrd.yaml", crds[0].Name)
|
||||
is.Equal("parent/crds/parentcrd.yaml", crds[0].Filename)
|
||||
is.NotContains(crds[0].Filename, "\\", "CRD filename should use forward slashes, not backslashes")
|
||||
|
||||
// Verify subchart CRD has forward slashes (not backslashes)
|
||||
is.Equal("crds/subchartcrd.yaml", crds[1].Name)
|
||||
is.Equal("parent/charts/subchart/crds/subchartcrd.yaml", crds[1].Filename)
|
||||
is.NotContains(crds[1].Filename, "\\", "CRD filename should use forward slashes, not backslashes")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue