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

Commit

Permalink
[chart-repo] Support case insensitive readme file in charts (#639)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jessehu authored and Andres Martinez Gotor committed Jul 17, 2019
1 parent 52df591 commit a8edd7b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/chart-repo/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func extractFilesFromTarball(filenames []string, tarf *tar.Reader) (map[string]s
}

for _, f := range filenames {
if header.Name == f {
if strings.EqualFold(header.Name, f) {
var b bytes.Buffer
io.Copy(&b, tarf)
ret[f] = string(b.Bytes())
Expand Down
1 change: 1 addition & 0 deletions cmd/chart-repo/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ func Test_extractFilesFromTarball(t *testing.T) {
{"file", []tarballFile{{"file.txt", "best file ever"}}, "file.txt", "best file ever"},
{"multiple file tarball", []tarballFile{{"file.txt", "best file ever"}, {"file2.txt", "worst file ever"}}, "file2.txt", "worst file ever"},
{"file in dir", []tarballFile{{"file.txt", "best file ever"}, {"test/file2.txt", "worst file ever"}}, "test/file2.txt", "worst file ever"},
{"filename ignore case", []tarballFile{{"Readme.md", "# readme for chart"}, {"values.yaml", "key: value"}}, "README.md", "# readme for chart"},
}

for _, tt := range tests {
Expand Down

0 comments on commit a8edd7b

Please sign in to comment.