mirror of
https://github.com/helm/helm.git
synced 2026-04-25 08:10:48 -04:00
Save Chart.lock to helm package tar
Signed-off-by: Song Shukun <song.shukun@fujitsu.com>
This commit is contained in:
parent
ec2e77cded
commit
a992464fa2
2 changed files with 36 additions and 0 deletions
|
|
@ -161,6 +161,20 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Save Chart.lock
|
||||
// TODO: remove the APIVersion check when APIVersionV1 is not used anymore
|
||||
if c.Metadata.APIVersion == chart.APIVersionV2 {
|
||||
if c.Lock != nil {
|
||||
ldata, err := yaml.Marshal(c.Lock)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := writeToTar(out, filepath.Join(base, "Chart.lock"), ldata); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save values.yaml
|
||||
for _, f := range c.Raw {
|
||||
if f.Name == ValuesfileName {
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ func TestSave(t *testing.T) {
|
|||
Name: "ahab",
|
||||
Version: "1.2.3",
|
||||
},
|
||||
Lock: &chart.Lock{
|
||||
Digest: "testdigest",
|
||||
},
|
||||
Files: []*chart.File{
|
||||
{Name: "scheherazade/shahryar.txt", Data: []byte("1,001 Nights")},
|
||||
},
|
||||
|
|
@ -77,6 +80,9 @@ func TestSave(t *testing.T) {
|
|||
if len(c2.Files) != 1 || c2.Files[0].Name != "scheherazade/shahryar.txt" {
|
||||
t.Fatal("Files data did not match")
|
||||
}
|
||||
if c2.Lock != nil {
|
||||
t.Fatal("Expected v1 chart archive not to contain Chart.lock file")
|
||||
}
|
||||
|
||||
if !bytes.Equal(c.Schema, c2.Schema) {
|
||||
indentation := 4
|
||||
|
|
@ -87,6 +93,22 @@ func TestSave(t *testing.T) {
|
|||
if _, err := Save(&chartWithInvalidJSON, dest); err == nil {
|
||||
t.Fatalf("Invalid JSON was not caught while saving chart")
|
||||
}
|
||||
|
||||
c.Metadata.APIVersion = chart.APIVersionV2
|
||||
where, err = Save(c, dest)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to save: %s", err)
|
||||
}
|
||||
c2, err = loader.LoadFile(where)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c2.Lock == nil {
|
||||
t.Fatal("Expected v2 chart archive to containe a Chart.lock file")
|
||||
}
|
||||
if c2.Lock.Digest != c.Lock.Digest {
|
||||
t.Fatal("Chart.lock data did not match")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue