fix(repo): ensure index generates in the right order

reviewable/pr1412/r1
Adnan Abdulhussein 9 years ago
parent 313a9dc4a3
commit 839f22226c

@ -222,6 +222,7 @@ func IndexDirectory(dir, baseURL string) (*IndexFile, error) {
}
index.Add(c.Metadata, fname, baseURL, hash)
}
index.SortEntries()
return index, nil
}

@ -197,12 +197,12 @@ func verifyLocalIndex(t *testing.T, i *IndexFile) {
Metadata: &chart.Metadata{
Name: "nginx",
Description: "string",
Version: "0.1.0",
Version: "0.2.0",
Keywords: []string{"popular", "web server", "proxy"},
Home: "https://github.com/something",
Home: "https://github.com/something/else",
},
URLs: []string{
"http://storage.googleapis.com/kubernetes-charts/nginx-0.1.0.tgz",
"http://storage.googleapis.com/kubernetes-charts/nginx-0.2.0.tgz",
},
Digest: "sha256:1234567890abcdef",
},
@ -210,12 +210,12 @@ func verifyLocalIndex(t *testing.T, i *IndexFile) {
Metadata: &chart.Metadata{
Name: "nginx",
Description: "string",
Version: "0.2.0",
Version: "0.1.0",
Keywords: []string{"popular", "web server", "proxy"},
Home: "https://github.com/something/else",
Home: "https://github.com/something",
},
URLs: []string{
"http://storage.googleapis.com/kubernetes-charts/nginx-0.2.0.tgz",
"http://storage.googleapis.com/kubernetes-charts/nginx-0.1.0.tgz",
},
Digest: "sha256:1234567890abcdef",
},
@ -282,6 +282,18 @@ func TestIndexDirectory(t *testing.T) {
if frob.Name != "frobnitz" {
t.Errorf("Expected frobnitz, got %q", frob.Name)
}
cname = "sprocket"
sprocket, ok := index.Entries[cname]
if !ok {
t.Fatalf("Could not read chart %s", cname)
}
sproc := sprocket[0]
expectedVersion := "1.2.0"
if sproc.Version != expectedVersion {
t.Errorf("Expected %q, got %q", expectedVersion, sproc.Version)
}
}
func TestLoadUnversionedIndex(t *testing.T) {

@ -133,7 +133,7 @@ func TestLoadChartRepository(t *testing.T) {
t.Errorf("Problem loading chart repository from %s: %v", testRepository, err)
}
paths := []string{filepath.Join(testRepository, "frobnitz-1.2.3.tgz"), filepath.Join(testRepository, "sprocket-1.2.0.tgz")}
paths := []string{filepath.Join(testRepository, "frobnitz-1.2.3.tgz"), filepath.Join(testRepository, "sprocket-1.1.0.tgz"), filepath.Join(testRepository, "sprocket-1.2.0.tgz")}
if cr.RootPath != testRepository {
t.Errorf("Expected %s as RootPath but got %s", testRepository, cr.RootPath)
@ -211,6 +211,12 @@ func verifyIndex(t *testing.T, actual *IndexFile) {
Version: "1.2.0",
},
},
{
Metadata: &chart.Metadata{
Name: "sprocket",
Version: "1.1.0",
},
},
},
}

@ -2,22 +2,22 @@ apiVersion: v1
entries:
nginx:
- urls:
- http://storage.googleapis.com/kubernetes-charts/nginx-0.1.0.tgz
- http://storage.googleapis.com/kubernetes-charts/nginx-0.2.0.tgz
name: nginx
description: string
version: 0.1.0
home: https://github.com/something
version: 0.2.0
home: https://github.com/something/else
digest: "sha256:1234567890abcdef"
keywords:
- popular
- web server
- proxy
- urls:
- http://storage.googleapis.com/kubernetes-charts/nginx-0.2.0.tgz
- http://storage.googleapis.com/kubernetes-charts/nginx-0.1.0.tgz
name: nginx
description: string
version: 0.2.0
home: https://github.com/something/else
version: 0.1.0
home: https://github.com/something
digest: "sha256:1234567890abcdef"
keywords:
- popular

Binary file not shown.
Loading…
Cancel
Save