Merge pull request #4088 from jgleonard/2751

#2715 add child NOTES.txt rendering
pull/5177/head
Michelle Noorali 6 years ago committed by GitHub
commit 2b7221b5b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -32,6 +32,7 @@ Think of it like apt/yum/homebrew for Kubernetes.
## Install ## Install
Binary downloads of the Helm client can be found on [the Releases page](https://github.com/helm/helm/releases/latest). Binary downloads of the Helm client can be found on [the Releases page](https://github.com/helm/helm/releases/latest).
Unpack the `helm` binary and add it to your PATH and you are good to go! Unpack the `helm` binary and add it to your PATH and you are good to go!

@ -212,6 +212,8 @@ message UpdateReleaseRequest {
bool force = 11; bool force = 11;
// Description, if set, will set the description for the updated release // Description, if set, will set the description for the updated release
string description = 12; string description = 12;
// Render subchart notes if enabled
bool subNotes = 13;
} }
// UpdateReleaseResponse is the response to an update request. // UpdateReleaseResponse is the response to an update request.
@ -281,6 +283,9 @@ message InstallReleaseRequest {
// Description, if set, will set the description for the installed release // Description, if set, will set the description for the installed release
string description = 11; string description = 11;
bool subNotes = 12;
} }
// InstallReleaseResponse is the response from a release installation. // InstallReleaseResponse is the response from a release installation.

@ -136,6 +136,7 @@ type installCmd struct {
password string password string
devel bool devel bool
depUp bool depUp bool
subNotes bool
description string description string
certFile string certFile string
@ -219,6 +220,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
f.StringVar(&inst.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") f.StringVar(&inst.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
f.BoolVar(&inst.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.") f.BoolVar(&inst.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.")
f.BoolVar(&inst.depUp, "dep-up", false, "run helm dependency update before installing the chart") f.BoolVar(&inst.depUp, "dep-up", false, "run helm dependency update before installing the chart")
f.BoolVar(&inst.subNotes, "render-subchart-notes", false, "render subchart notes along with the parent")
f.StringVar(&inst.description, "description", "", "specify a description for the release") f.StringVar(&inst.description, "description", "", "specify a description for the release")
// set defaults from environment // set defaults from environment
@ -300,6 +302,7 @@ func (i *installCmd) run() error {
helm.InstallReuseName(i.replace), helm.InstallReuseName(i.replace),
helm.InstallDisableHooks(i.disableHooks), helm.InstallDisableHooks(i.disableHooks),
helm.InstallDisableCRDHook(i.disableCRDHook), helm.InstallDisableCRDHook(i.disableCRDHook),
helm.InstallSubNotes(i.subNotes),
helm.InstallTimeout(i.timeout), helm.InstallTimeout(i.timeout),
helm.InstallWait(i.wait), helm.InstallWait(i.wait),
helm.InstallDescription(i.description)) helm.InstallDescription(i.description))

@ -109,6 +109,7 @@ type upgradeCmd struct {
username string username string
password string password string
devel bool devel bool
subNotes bool
description string description string
certFile string certFile string
@ -173,6 +174,7 @@ func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command {
f.StringVar(&upgrade.keyFile, "key-file", "", "identify HTTPS client using this SSL key file") f.StringVar(&upgrade.keyFile, "key-file", "", "identify HTTPS client using this SSL key file")
f.StringVar(&upgrade.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") f.StringVar(&upgrade.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
f.BoolVar(&upgrade.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.") f.BoolVar(&upgrade.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.")
f.BoolVar(&upgrade.subNotes, "render-subchart-notes", false, "render subchart notes along with parent")
f.StringVar(&upgrade.description, "description", "", "specify the description to use for the upgrade, rather than the default") f.StringVar(&upgrade.description, "description", "", "specify the description to use for the upgrade, rather than the default")
f.MarkDeprecated("disable-hooks", "use --no-hooks instead") f.MarkDeprecated("disable-hooks", "use --no-hooks instead")
@ -264,6 +266,7 @@ func (u *upgradeCmd) run() error {
helm.UpgradeTimeout(u.timeout), helm.UpgradeTimeout(u.timeout),
helm.ResetValues(u.resetValues), helm.ResetValues(u.resetValues),
helm.ReuseValues(u.reuseValues), helm.ReuseValues(u.reuseValues),
helm.UpgradeSubNotes(u.subNotes),
helm.UpgradeWait(u.wait), helm.UpgradeWait(u.wait),
helm.UpgradeDescription(u.description)) helm.UpgradeDescription(u.description))
if err != nil { if err != nil {

@ -93,6 +93,7 @@ helm install [CHART] [flags]
--no-crd-hook prevent CRD hooks from running, but run other hooks --no-crd-hook prevent CRD hooks from running, but run other hooks
--no-hooks prevent hooks from running during install --no-hooks prevent hooks from running during install
--password string chart repository password where to locate the requested chart --password string chart repository password where to locate the requested chart
--render-subchart-notes render subchart notes along with the parent
--replace re-use the given name, even if that name is already used. This is unsafe in production --replace re-use the given name, even if that name is already used. This is unsafe in production
--repo string chart repository url where to locate the requested chart --repo string chart repository url where to locate the requested chart
--set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2) --set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
@ -128,4 +129,4 @@ helm install [CHART] [flags]
* [helm](helm.md) - The Helm package manager for Kubernetes. * [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 10-Aug-2018 ###### Auto generated by spf13/cobra on 1-Nov-2018

@ -79,6 +79,7 @@ helm upgrade [RELEASE] [CHART] [flags]
--no-hooks disable pre/post upgrade hooks --no-hooks disable pre/post upgrade hooks
--password string chart repository password where to locate the requested chart --password string chart repository password where to locate the requested chart
--recreate-pods performs pods restart for the resource if applicable --recreate-pods performs pods restart for the resource if applicable
--render-subchart-notes render subchart notes along with parent
--repo string chart repository url where to locate the requested chart --repo string chart repository url where to locate the requested chart
--reset-values when upgrading, reset the values to the ones built into the chart --reset-values when upgrading, reset the values to the ones built into the chart
--reuse-values when upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' is specified, this is ignored. --reuse-values when upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' is specified, this is ignored.
@ -115,4 +116,4 @@ helm upgrade [RELEASE] [CHART] [flags]
* [helm](helm.md) - The Helm package manager for Kubernetes. * [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 24-Aug-2018 ###### Auto generated by spf13/cobra on 1-Nov-2018

@ -346,6 +346,20 @@ func InstallReuseName(reuse bool) InstallOption {
} }
} }
// InstallSubNotes will (if true) instruct Tiller to render SubChart Notes
func InstallSubNotes(enable bool) InstallOption {
return func(opts *options) {
opts.instReq.SubNotes = enable
}
}
// UpgradeSubNotes will (if true) instruct Tiller to render SubChart Notes
func UpgradeSubNotes(enable bool) UpdateOption {
return func(opts *options) {
opts.updateReq.SubNotes = enable
}
}
// RollbackDisableHooks will disable hooks for a rollback operation // RollbackDisableHooks will disable hooks for a rollback operation
func RollbackDisableHooks(disable bool) RollbackOption { func RollbackDisableHooks(disable bool) RollbackOption {
return func(opts *options) { return func(opts *options) {

@ -381,6 +381,8 @@ type UpdateReleaseRequest struct {
Force bool `protobuf:"varint,11,opt,name=force" json:"force,omitempty"` Force bool `protobuf:"varint,11,opt,name=force" json:"force,omitempty"`
// Description, if set, will set the description for the updated release // Description, if set, will set the description for the updated release
Description string `protobuf:"bytes,12,opt,name=description" json:"description,omitempty"` Description string `protobuf:"bytes,12,opt,name=description" json:"description,omitempty"`
// Render subchart notes if enabled
SubNotes bool `protobuf:"varint,13,opt,name=subNotes" json:"subNotes,omitempty"`
} }
func (m *UpdateReleaseRequest) Reset() { *m = UpdateReleaseRequest{} } func (m *UpdateReleaseRequest) Reset() { *m = UpdateReleaseRequest{} }
@ -465,6 +467,13 @@ func (m *UpdateReleaseRequest) GetForce() bool {
return false return false
} }
func (m *UpdateReleaseRequest) GetSubNotes() bool {
if m != nil {
return m.SubNotes
}
return false
}
func (m *UpdateReleaseRequest) GetDescription() string { func (m *UpdateReleaseRequest) GetDescription() string {
if m != nil { if m != nil {
return m.Description return m.Description
@ -624,6 +633,7 @@ type InstallReleaseRequest struct {
DisableCrdHook bool `protobuf:"varint,10,opt,name=disable_crd_hook,json=disableCrdHook" json:"disable_crd_hook,omitempty"` DisableCrdHook bool `protobuf:"varint,10,opt,name=disable_crd_hook,json=disableCrdHook" json:"disable_crd_hook,omitempty"`
// Description, if set, will set the description for the installed release // Description, if set, will set the description for the installed release
Description string `protobuf:"bytes,11,opt,name=description" json:"description,omitempty"` Description string `protobuf:"bytes,11,opt,name=description" json:"description,omitempty"`
SubNotes bool `protobuf:"varint,12,opt,name=subNotes" json:"subNotes,omitempty"`
} }
func (m *InstallReleaseRequest) Reset() { *m = InstallReleaseRequest{} } func (m *InstallReleaseRequest) Reset() { *m = InstallReleaseRequest{} }
@ -701,6 +711,13 @@ func (m *InstallReleaseRequest) GetDisableCrdHook() bool {
return false return false
} }
func (m *InstallReleaseRequest) GetSubNotes() bool {
if m != nil {
return m.SubNotes
}
return false
}
func (m *InstallReleaseRequest) GetDescription() string { func (m *InstallReleaseRequest) GetDescription() string {
if m != nil { if m != nil {
return m.Description return m.Description

@ -84,7 +84,7 @@ func (s *ReleaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re
return nil, err return nil, err
} }
hooks, manifestDoc, notesTxt, err := s.renderResources(req.Chart, valuesToRender, caps.APIVersions) hooks, manifestDoc, notesTxt, err := s.renderResources(req.Chart, valuesToRender, req.SubNotes, caps.APIVersions)
if err != nil { if err != nil {
// Return a release with partial data so that client can show debugging // Return a release with partial data so that client can show debugging
// information. // information.

@ -268,7 +268,7 @@ func TestInstallRelease_WrongTillerVersion(t *testing.T) {
} }
} }
func TestInstallRelease_WithChartAndDependencyNotes(t *testing.T) { func TestInstallRelease_WithChartAndDependencyParentNotes(t *testing.T) {
c := helm.NewContext() c := helm.NewContext()
rs := rsFixture() rs := rsFixture()
@ -300,6 +300,39 @@ func TestInstallRelease_WithChartAndDependencyNotes(t *testing.T) {
} }
} }
func TestInstallRelease_WithChartAndDependencyAllNotes(t *testing.T) {
c := helm.NewContext()
rs := rsFixture()
req := installRequest(withSubNotes(),
withChart(
withNotes(notesText),
withDependency(withNotes(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 !strings.Contains(rel.Info.Status.Notes, notesText) || !strings.Contains(rel.Info.Status.Notes, notesText+" child") {
t.Fatalf("Expected '%s', got '%s'", notesText+"\n"+notesText+" child", rel.Info.Status.Notes)
}
if rel.Info.Description != "Install complete" {
t.Errorf("unexpected description: %s", rel.Info.Description)
}
}
func TestInstallRelease_DryRun(t *testing.T) { func TestInstallRelease_DryRun(t *testing.T) {
c := helm.NewContext() c := helm.NewContext()
rs := rsFixture() rs := rsFixture()

@ -278,7 +278,7 @@ func GetVersionSet(client discovery.ServerGroupsInterface) (chartutil.VersionSet
return chartutil.NewVersionSet(versions...), nil return chartutil.NewVersionSet(versions...), nil
} }
func (s *ReleaseServer) renderResources(ch *chart.Chart, values chartutil.Values, vs chartutil.VersionSet) ([]*release.Hook, *bytes.Buffer, string, error) { func (s *ReleaseServer) renderResources(ch *chart.Chart, values chartutil.Values, subNotes bool, vs chartutil.VersionSet) ([]*release.Hook, *bytes.Buffer, string, error) {
// Guard to make sure Tiller is at the right version to handle this chart. // Guard to make sure Tiller is at the right version to handle this chart.
sver := version.GetVersion() sver := version.GetVersion()
if ch.Metadata.TillerVersion != "" && if ch.Metadata.TillerVersion != "" &&
@ -307,18 +307,23 @@ func (s *ReleaseServer) renderResources(ch *chart.Chart, values chartutil.Values
// text file. We have to spin through this map because the file contains path information, so we // text file. We have to spin through this map because the file contains path information, so we
// look for terminating NOTES.txt. We also remove it from the files so that we don't have to skip // look for terminating NOTES.txt. We also remove it from the files so that we don't have to skip
// it in the sortHooks. // it in the sortHooks.
notes := "" var notesBuffer bytes.Buffer
for k, v := range files { for k, v := range files {
if strings.HasSuffix(k, notesFileSuffix) { if strings.HasSuffix(k, notesFileSuffix) {
// Only apply the notes if it belongs to the parent chart if subNotes || (k == path.Join(ch.Metadata.Name, "templates", notesFileSuffix)) {
// Note: Do not use filePath.Join since it creates a path with \ which is not expected
if k == path.Join(ch.Metadata.Name, "templates", notesFileSuffix) { // If buffer contains data, add newline before adding more
notes = v if notesBuffer.Len() > 0 {
notesBuffer.WriteString("\n")
}
notesBuffer.WriteString(v)
} }
delete(files, k) delete(files, k)
} }
} }
notes := notesBuffer.String()
// Sort hooks, manifests, and partials. Only hooks and manifests are returned, // Sort hooks, manifests, and partials. Only hooks and manifests are returned,
// as partials are not used after renderer.Render. Empty manifests are also // as partials are not used after renderer.Render. Empty manifests are also
// removed here. // removed here.

@ -221,6 +221,12 @@ func withChart(chartOpts ...chartOption) installOption {
} }
} }
func withSubNotes() installOption {
return func(opts *installOptions) {
opts.SubNotes = true
}
}
func installRequest(opts ...installOption) *services.InstallReleaseRequest { func installRequest(opts ...installOption) *services.InstallReleaseRequest {
reqOpts := &installOptions{ reqOpts := &installOptions{
&services.InstallReleaseRequest{ &services.InstallReleaseRequest{

@ -113,7 +113,7 @@ func (s *ReleaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*rele
return nil, nil, err return nil, nil, err
} }
hooks, manifestDoc, notesTxt, err := s.renderResources(req.Chart, valuesToRender, caps.APIVersions) hooks, manifestDoc, notesTxt, err := s.renderResources(req.Chart, valuesToRender, req.SubNotes, caps.APIVersions)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

Loading…
Cancel
Save