mirror of
https://github.com/helm/helm.git
synced 2026-03-05 15:02:12 -05:00
Merge pull request #2187 from johnw188/sortIndexOnDownload
fix(helm): Don't assume index.yaml is sorted
This commit is contained in:
commit
b7af2e21e4
3 changed files with 55 additions and 2 deletions
|
|
@ -243,6 +243,7 @@ func loadIndex(data []byte) (*IndexFile, error) {
|
|||
if err := yaml.Unmarshal(data, i); err != nil {
|
||||
return i, err
|
||||
}
|
||||
i.SortEntries()
|
||||
if i.APIVersion == "" {
|
||||
// When we leave Beta, we should remove legacy support and just
|
||||
// return this error:
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
testfile = "testdata/local-index.yaml"
|
||||
testRepo = "test-repo"
|
||||
testfile = "testdata/local-index.yaml"
|
||||
unorderedTestfile = "testdata/local-index-unordered.yaml"
|
||||
testRepo = "test-repo"
|
||||
)
|
||||
|
||||
func TestIndexFile(t *testing.T) {
|
||||
|
|
@ -82,6 +83,18 @@ func TestLoadIndexFile(t *testing.T) {
|
|||
verifyLocalIndex(t, i)
|
||||
}
|
||||
|
||||
func TestLoadUnorderedIndex(t *testing.T) {
|
||||
b, err := ioutil.ReadFile(unorderedTestfile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
i, err := loadIndex(b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
verifyLocalIndex(t, i)
|
||||
}
|
||||
|
||||
func TestMerge(t *testing.T) {
|
||||
ind1 := NewIndexFile()
|
||||
ind1.Add(&chart.Metadata{
|
||||
|
|
|
|||
39
pkg/repo/testdata/local-index-unordered.yaml
vendored
Normal file
39
pkg/repo/testdata/local-index-unordered.yaml
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
apiVersion: v1
|
||||
entries:
|
||||
nginx:
|
||||
- urls:
|
||||
- https://kubernetes-charts.storage.googleapis.com/nginx-0.1.0.tgz
|
||||
name: nginx
|
||||
description: string
|
||||
version: 0.1.0
|
||||
home: https://github.com/something
|
||||
digest: "sha256:1234567890abcdef"
|
||||
keywords:
|
||||
- popular
|
||||
- web server
|
||||
- proxy
|
||||
- urls:
|
||||
- https://kubernetes-charts.storage.googleapis.com/nginx-0.2.0.tgz
|
||||
name: nginx
|
||||
description: string
|
||||
version: 0.2.0
|
||||
home: https://github.com/something/else
|
||||
digest: "sha256:1234567890abcdef"
|
||||
keywords:
|
||||
- popular
|
||||
- web server
|
||||
- proxy
|
||||
alpine:
|
||||
- urls:
|
||||
- https://kubernetes-charts.storage.googleapis.com/alpine-1.0.0.tgz
|
||||
- http://storage2.googleapis.com/kubernetes-charts/alpine-1.0.0.tgz
|
||||
name: alpine
|
||||
description: string
|
||||
version: 1.0.0
|
||||
home: https://github.com/something
|
||||
keywords:
|
||||
- linux
|
||||
- alpine
|
||||
- small
|
||||
- sumtin
|
||||
digest: "sha256:1234567890abcdef"
|
||||
Loading…
Reference in a new issue