Merge pull request #8529 from lingsamuel/status-show-desc

feat: add flag `--show-desc` to display description for `helm status`
pull/8695/head
Martin Hickey 4 years ago committed by GitHub
commit 2a9ef6d3b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -59,7 +59,7 @@ func newGetAllCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return tpl(template, data, out)
}
return output.Table.Write(out, &statusPrinter{res, true})
return output.Table.Write(out, &statusPrinter{res, true, false})
},
}

@ -122,7 +122,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return err
}
return outfmt.Write(out, &statusPrinter{rel, settings.Debug})
return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false})
},
}

@ -61,7 +61,7 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
return runErr
}
if err := outfmt.Write(out, &statusPrinter{rel, settings.Debug}); err != nil {
if err := outfmt.Write(out, &statusPrinter{rel, settings.Debug, false}); err != nil {
return err
}

@ -39,6 +39,8 @@ The status consists of:
- last deployment time
- k8s namespace in which the release lives
- state of the release (can be: unknown, deployed, uninstalled, superseded, failed, uninstalling, pending-install, pending-upgrade or pending-rollback)
- revision of the release
- description of the release (can be completion message or error message, need to enable --show-desc)
- list of resources that this release consists of, sorted by kind
- details on last test suite run, if applicable
- additional notes provided by the chart
@ -68,7 +70,7 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
// strip chart metadata from the output
rel.Chart = nil
return outfmt.Write(out, &statusPrinter{rel, false})
return outfmt.Write(out, &statusPrinter{rel, false, client.ShowDescription})
},
}
@ -88,13 +90,15 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
}
bindOutputFlag(cmd, &outfmt)
f.BoolVar(&client.ShowDescription, "show-desc", false, "if set, display the description message of the named release")
return cmd
}
type statusPrinter struct {
release *release.Release
debug bool
release *release.Release
debug bool
showDescription bool
}
func (s statusPrinter) WriteJSON(out io.Writer) error {
@ -116,6 +120,9 @@ func (s statusPrinter) WriteTable(out io.Writer) error {
fmt.Fprintf(out, "NAMESPACE: %s\n", s.release.Namespace)
fmt.Fprintf(out, "STATUS: %s\n", s.release.Info.Status.String())
fmt.Fprintf(out, "REVISION: %d\n", s.release.Version)
if s.showDescription {
fmt.Fprintf(out, "DESCRIPTION: %s\n", s.release.Info.Description)
}
executions := executionsByHookEvent(s.release)
if tests, ok := executions[release.HookTest]; !ok || len(tests) == 0 {

@ -44,6 +44,14 @@ func TestStatusCmd(t *testing.T) {
rels: releasesMockWithStatus(&release.Info{
Status: release.StatusDeployed,
}),
}, {
name: "get status of a deployed release, with desc",
cmd: "status --show-desc flummoxed-chickadee",
golden: "output/status-with-desc.txt",
rels: releasesMockWithStatus(&release.Info{
Status: release.StatusDeployed,
Description: "Mock description",
}),
}, {
name: "get status of a deployed release with notes",
cmd: "status flummoxed-chickadee",

@ -0,0 +1,7 @@
NAME: flummoxed-chickadee
LAST DEPLOYED: Sat Jan 16 00:00:00 2016
NAMESPACE: default
STATUS: deployed
REVISION: 0
DESCRIPTION: Mock description
TEST SUITE: None

@ -115,7 +115,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
if err != nil {
return err
}
return outfmt.Write(out, &statusPrinter{rel, settings.Debug})
return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false})
} else if err != nil {
return err
}
@ -160,7 +160,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
fmt.Fprintf(out, "Release %q has been upgraded. Happy Helming!\n", args[0])
}
return outfmt.Write(out, &statusPrinter{rel, settings.Debug})
return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false})
},
}

@ -27,6 +27,11 @@ type Status struct {
cfg *Configuration
Version int
// If true, display description to output format,
// only affect print type table.
// TODO Helm 4: Remove this flag and output the description by default.
ShowDescription bool
}
// NewStatus creates a new Status object with the given configuration.

Loading…
Cancel
Save