Skip to content

Commit 0c54139

Browse files
committed
Added support for hiding notes from install/upgrade output
Signed-off-by: Miles Wilson <[email protected]>
1 parent c288f0b commit 0c54139

8 files changed

+20
-10
lines changed

cmd/helm/get_all.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ func newGetAllCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
5858
}
5959
return tpl(template, data, out)
6060
}
61-
62-
return output.Table.Write(out, &statusPrinter{res, true, false, false, true})
61+
return output.Table.Write(out, &statusPrinter{res, true, false, false, true, false})
6362
},
6463
}
6564

cmd/helm/install.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ set for a key called 'foo', the 'newbar' value would take precedence:
8585
8686
$ helm install --set foo=bar --set foo=newbar myredis ./redis
8787
88-
Similarly, in the following example 'foo' is set to '["four"]':
88+
Similarly, in the following example 'foo' is set to '["four"]':
8989
9090
$ helm install --set-json='foo=["one", "two", "three"]' --set-json='foo=["four"]' myredis ./redis
9191
@@ -154,7 +154,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
154154
return errors.Wrap(err, "INSTALLATION FAILED")
155155
}
156156

157-
return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false})
157+
return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, client.HideNotes})
158158
},
159159
}
160160

@@ -191,6 +191,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal
191191
f.BoolVar(&client.SubNotes, "render-subchart-notes", false, "if set, render subchart notes along with the parent")
192192
f.StringToStringVarP(&client.Labels, "labels", "l", nil, "Labels that would be added to release metadata. Should be divided by comma.")
193193
f.BoolVar(&client.EnableDNS, "enable-dns", false, "enable DNS lookups when rendering templates")
194+
f.BoolVar(&client.HideNotes, "hide-notes", false, "if set, do not show notes in install output. Does not affect presence in chart metadata")
194195
addValueOptionsFlags(f, valueOpts)
195196
addChartPathOptionsFlags(f, &client.ChartPathOptions)
196197

cmd/helm/release_testing.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
7272
return runErr
7373
}
7474

75-
if err := outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false}); err != nil {
75+
if err := outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, client.HideNotes}); err != nil {
7676
return err
7777
}
7878

@@ -92,6 +92,7 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
9292
f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)")
9393
f.BoolVar(&outputLogs, "logs", false, "dump the logs from test pods (this runs after all tests are complete, but before any cleanup)")
9494
f.StringSliceVar(&filter, "filter", []string{}, "specify tests by attribute (currently \"name\") using attribute=value syntax or '!attribute=value' to exclude a test (can specify multiple or separate values with commas: name=test1,name=test2)")
95+
f.BoolVar(&client.HideNotes, "hide-notes", false, "if set, do not show notes in test output. Does not affect presence in chart metadata")
9596

9697
return cmd
9798
}

cmd/helm/status.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
8080
// strip chart metadata from the output
8181
rel.Chart = nil
8282

83-
return outfmt.Write(out, &statusPrinter{rel, false, client.ShowDescription, client.ShowResources, false})
83+
return outfmt.Write(out, &statusPrinter{rel, false, client.ShowDescription, client.ShowResources, false, false})
8484
},
8585
}
8686

@@ -113,6 +113,7 @@ type statusPrinter struct {
113113
showDescription bool
114114
showResources bool
115115
showMetadata bool
116+
hideNotes bool
116117
}
117118

118119
func (s statusPrinter) WriteJSON(out io.Writer) error {
@@ -219,8 +220,9 @@ func (s statusPrinter) WriteTable(out io.Writer) error {
219220
_, _ = fmt.Fprintf(out, "MANIFEST:\n%s\n", s.release.Manifest)
220221
}
221222

222-
if len(s.release.Info.Notes) > 0 {
223-
_, _ = fmt.Fprintf(out, "NOTES:\n%s\n", strings.TrimSpace(s.release.Info.Notes))
223+
// Hide notes from output - option in install and upgrades
224+
if !s.hideNotes && len(s.release.Info.Notes) > 0 {
225+
fmt.Fprintf(out, "NOTES:\n%s\n", strings.TrimSpace(s.release.Info.Notes))
224226
}
225227
return nil
226228
}

cmd/helm/upgrade.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
138138
instClient.PostRenderer = client.PostRenderer
139139
instClient.DisableOpenAPIValidation = client.DisableOpenAPIValidation
140140
instClient.SubNotes = client.SubNotes
141+
instClient.HideNotes = client.HideNotes
141142
instClient.Description = client.Description
142143
instClient.DependencyUpdate = client.DependencyUpdate
143144
instClient.Labels = client.Labels
@@ -147,7 +148,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
147148
if err != nil {
148149
return err
149150
}
150-
return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false})
151+
return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, instClient.HideNotes})
151152
} else if err != nil {
152153
return err
153154
}
@@ -225,6 +226,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
225226
}()
226227

227228
rel, err := client.RunWithContext(ctx, args[0], ch, vals)
229+
228230
if err != nil {
229231
return errors.Wrap(err, "UPGRADE FAILED")
230232
}
@@ -233,7 +235,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
233235
fmt.Fprintf(out, "Release %q has been upgraded. Happy Helming!\n", args[0])
234236
}
235237

236-
return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false})
238+
return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, client.HideNotes})
237239
},
238240
}
239241

@@ -258,6 +260,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
258260
f.IntVar(&client.MaxHistory, "history-max", settings.MaxHistory, "limit the maximum number of revisions saved per release. Use 0 for no limit")
259261
f.BoolVar(&client.CleanupOnFail, "cleanup-on-fail", false, "allow deletion of new resources created in this upgrade when upgrade fails")
260262
f.BoolVar(&client.SubNotes, "render-subchart-notes", false, "if set, render subchart notes along with the parent")
263+
f.BoolVar(&client.HideNotes, "hide-notes", false, "if set, do not show notes in upgrade output. Does not affect presence in chart metadata")
261264
f.StringToStringVarP(&client.Labels, "labels", "l", nil, "Labels that would be added to release metadata. Should be separated by comma. Original release labels will be merged with upgrade labels. You can unset label using null.")
262265
f.StringVar(&client.Description, "description", "", "add a custom description")
263266
f.BoolVar(&client.DependencyUpdate, "dependency-update", false, "update dependencies if they are missing before installing the chart")

pkg/action/install.go

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ type Install struct {
9090
Atomic bool
9191
SkipCRDs bool
9292
SubNotes bool
93+
HideNotes bool
9394
DisableOpenAPIValidation bool
9495
IncludeCRDs bool
9596
Labels map[string]string

pkg/action/release_testing.go

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type ReleaseTesting struct {
4444
// Used for fetching logs from test pods
4545
Namespace string
4646
Filters map[string][]string
47+
HideNotes bool
4748
}
4849

4950
// NewReleaseTesting creates a new ReleaseTesting object with the given configuration.

pkg/action/upgrade.go

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ type Upgrade struct {
9292
CleanupOnFail bool
9393
// SubNotes determines whether sub-notes are rendered in the chart.
9494
SubNotes bool
95+
// HideNotes determines whether notes are output during upgrade
96+
HideNotes bool
9597
// Description is the description of this operation
9698
Description string
9799
Labels map[string]string

0 commit comments

Comments
 (0)