diff --git a/cmd/tiller/release_server.go b/cmd/tiller/release_server.go index 4f00791f5..6e121a883 100644 --- a/cmd/tiller/release_server.go +++ b/cmd/tiller/release_server.go @@ -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) { - notes = v + // Only apply the notes if it belongs to the parent chart + if k == filepath.Join(ch.Metadata.Name, notesFileSuffix) { + notes = v + } delete(files, k) } } diff --git a/cmd/tiller/release_server_test.go b/cmd/tiller/release_server_test.go index e3073c189..da2863617 100644 --- a/cmd/tiller/release_server_test.go +++ b/cmd/tiller/release_server_test.go @@ -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()