Skip to content
This repository was archived by the owner on Jul 16, 2021. It is now read-only.

Commit a8edd7b

Browse files
jessehuAndres Martinez Gotor
authored andcommitted
[chart-repo] Support case insensitive readme file in charts (#639)
Fix #638. Sometimes the chart creator uses the name 'README.md', 'readme.md' or 'Readme.md' in the chart tarball. This patch adds support for case insensitive filenames in the chart tarball. We assume any files in the same folder in the chart tarball won't have the same file name when case ignored, and it should be true. Signed-off-by: Jesse Hu <seizethetime@163.com>
1 parent 52df591 commit a8edd7b

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

cmd/chart-repo/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ func extractFilesFromTarball(filenames []string, tarf *tar.Reader) (map[string]s
468468
}
469469

470470
for _, f := range filenames {
471-
if header.Name == f {
471+
if strings.EqualFold(header.Name, f) {
472472
var b bytes.Buffer
473473
io.Copy(&b, tarf)
474474
ret[f] = string(b.Bytes())

cmd/chart-repo/utils_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ func Test_extractFilesFromTarball(t *testing.T) {
479479
{"file", []tarballFile{{"file.txt", "best file ever"}}, "file.txt", "best file ever"},
480480
{"multiple file tarball", []tarballFile{{"file.txt", "best file ever"}, {"file2.txt", "worst file ever"}}, "file2.txt", "worst file ever"},
481481
{"file in dir", []tarballFile{{"file.txt", "best file ever"}, {"test/file2.txt", "worst file ever"}}, "test/file2.txt", "worst file ever"},
482+
{"filename ignore case", []tarballFile{{"Readme.md", "# readme for chart"}, {"values.yaml", "key: value"}}, "README.md", "# readme for chart"},
482483
}
483484

484485
for _, tt := range tests {

0 commit comments

Comments
 (0)