Merge pull request #8795 from mattfarina/feat-8767

Adding annotation to index.yaml file
pull/8846/head
Matt Farina 4 years ago committed by GitHub
commit 6297c021cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -83,6 +83,10 @@ type IndexFile struct {
Generated time.Time `json:"generated"` Generated time.Time `json:"generated"`
Entries map[string]ChartVersions `json:"entries"` Entries map[string]ChartVersions `json:"entries"`
PublicKeys []string `json:"publicKeys,omitempty"` PublicKeys []string `json:"publicKeys,omitempty"`
// Annotations are additional mappings uninterpreted by Helm. They are made available for
// other applications to add information to the index file.
Annotations map[string]string `json:"annotations,omitempty"`
} }
// NewIndexFile initializes an index. // NewIndexFile initializes an index.

@ -36,6 +36,7 @@ import (
const ( const (
testfile = "testdata/local-index.yaml" testfile = "testdata/local-index.yaml"
annotationstestfile = "testdata/local-index-annotations.yaml"
chartmuseumtestfile = "testdata/chartmuseum-index.yaml" chartmuseumtestfile = "testdata/chartmuseum-index.yaml"
unorderedTestfile = "testdata/local-index-unordered.yaml" unorderedTestfile = "testdata/local-index-unordered.yaml"
testRepo = "test-repo" testRepo = "test-repo"
@ -153,6 +154,21 @@ func TestLoadIndexFile(t *testing.T) {
verifyLocalIndex(t, i) verifyLocalIndex(t, i)
} }
func TestLoadIndexFileAnnotations(t *testing.T) {
i, err := LoadIndexFile(annotationstestfile)
if err != nil {
t.Fatal(err)
}
verifyLocalIndex(t, i)
if len(i.Annotations) != 1 {
t.Fatalf("Expected 1 annotation but got %d", len(i.Annotations))
}
if i.Annotations["helm.sh/test"] != "foo bar" {
t.Error("Did not get expected value for helm.sh/test annotation")
}
}
func TestLoadUnorderedIndex(t *testing.T) { func TestLoadUnorderedIndex(t *testing.T) {
b, err := ioutil.ReadFile(unorderedTestfile) b, err := ioutil.ReadFile(unorderedTestfile)
if err != nil { if err != nil {

@ -0,0 +1,50 @@
apiVersion: v1
entries:
nginx:
- 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
- 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
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"
chartWithNoURL:
- name: chartWithNoURL
description: string
version: 1.0.0
home: https://github.com/something
keywords:
- small
- sumtin
digest: "sha256:1234567890abcdef"
annotations:
helm.sh/test: foo bar
Loading…
Cancel
Save