fix(tiller): ensure only the parent NOTES is used

pull/1409/head
Adnan Abdulhussein 8 years ago
parent fcdb79da16
commit 168b17cf87

@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"log"
"path/filepath"
"regexp"
"strings"
@ -678,7 +679,10 @@ func (s *releaseServer) renderResources(ch *chart.Chart, values chartutil.Values
notes := ""
for k, v := range files {
if strings.HasSuffix(k, notesFileSuffix) {
// Only apply the notes if it belongs to the parent chart
if k == filepath.Join(ch.Metadata.Name, notesFileSuffix) {
notes = v
}
delete(files, k)
}
}

@ -393,6 +393,53 @@ func TestInstallReleaseWithNotesRendered(t *testing.T) {
}
}
func TestInstallReleaseWithChartAndDependencyNotes(t *testing.T) {
c := helm.NewContext()
rs := rsFixture()
// TODO: Refactor this into a mock.
req := &services.InstallReleaseRequest{
Namespace: "spaced",
Chart: &chart.Chart{
Metadata: &chart.Metadata{Name: "hello"},
Templates: []*chart.Template{
{Name: "hello", Data: []byte("hello: world")},
{Name: "hooks", Data: []byte(manifestWithHook)},
{Name: "NOTES.txt", Data: []byte(notesText)},
},
Dependencies: []*chart.Chart{
{
Metadata: &chart.Metadata{Name: "hello"},
Templates: []*chart.Template{
{Name: "hello", Data: []byte("hello: world")},
{Name: "hooks", Data: []byte(manifestWithHook)},
{Name: "NOTES.txt", Data: []byte(notesText + " child")},
},
},
},
},
}
res, err := rs.InstallRelease(c, req)
if err != nil {
t.Fatalf("Failed install: %s", err)
}
if res.Release.Name == "" {
t.Errorf("Expected release name.")
}
rel, err := rs.env.Releases.Get(res.Release.Name, res.Release.Version)
if err != nil {
t.Errorf("Expected release for %s (%v).", res.Release.Name, rs.env.Releases)
}
t.Logf("rel: %v", rel)
if rel.Info.Status.Notes != notesText {
t.Fatalf("Expected '%s', got '%s'", notesText, rel.Info.Status.Notes)
}
}
func TestInstallReleaseDryRun(t *testing.T) {
c := helm.NewContext()
rs := rsFixture()

Loading…
Cancel
Save