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.Add(c.Metadata, fname, baseURL, hash)
} }
index.SortEntries()
return index, nil return index, nil
} }

@ -197,12 +197,12 @@ func verifyLocalIndex(t *testing.T, i *IndexFile) {
Metadata: &chart.Metadata{ Metadata: &chart.Metadata{
Name: "nginx", Name: "nginx",
Description: "string", Description: "string",
Version: "0.1.0", Version: "0.2.0",
Keywords: []string{"popular", "web server", "proxy"}, Keywords: []string{"popular", "web server", "proxy"},
Home: "https://github.com/something", Home: "https://github.com/something/else",
}, },
URLs: []string{ 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", Digest: "sha256:1234567890abcdef",
}, },
@ -210,12 +210,12 @@ func verifyLocalIndex(t *testing.T, i *IndexFile) {
Metadata: &chart.Metadata{ Metadata: &chart.Metadata{
Name: "nginx", Name: "nginx",
Description: "string", Description: "string",
Version: "0.2.0", Version: "0.1.0",
Keywords: []string{"popular", "web server", "proxy"}, Keywords: []string{"popular", "web server", "proxy"},
Home: "https://github.com/something/else", Home: "https://github.com/something",
}, },
URLs: []string{ 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", Digest: "sha256:1234567890abcdef",
}, },
@ -282,6 +282,18 @@ func TestIndexDirectory(t *testing.T) {
if frob.Name != "frobnitz" { if frob.Name != "frobnitz" {
t.Errorf("Expected frobnitz, got %q", frob.Name) 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) { 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) 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 { if cr.RootPath != testRepository {
t.Errorf("Expected %s as RootPath but got %s", testRepository, cr.RootPath) 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", Version: "1.2.0",
}, },
}, },
{
Metadata: &chart.Metadata{
Name: "sprocket",
Version: "1.1.0",
},
},
}, },
} }

@ -2,22 +2,22 @@ apiVersion: v1
entries: entries:
nginx: nginx:
- urls: - 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 name: nginx
description: string description: string
version: 0.1.0 version: 0.2.0
home: https://github.com/something home: https://github.com/something/else
digest: "sha256:1234567890abcdef" digest: "sha256:1234567890abcdef"
keywords: keywords:
- popular - popular
- web server - web server
- proxy - proxy
- urls: - 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 name: nginx
description: string description: string
version: 0.2.0 version: 0.1.0
home: https://github.com/something/else home: https://github.com/something
digest: "sha256:1234567890abcdef" digest: "sha256:1234567890abcdef"
keywords: keywords:
- popular - popular

Binary file not shown.
Loading…
Cancel
Save