feat: status command display description

Signed-off-by: Ling Samuel <lingsamuelgrace@gmail.com>
pull/8529/head
Ling Samuel 4 years ago
parent 8e11f15659
commit da6878dc0f
No known key found for this signature in database
GPG Key ID: 1405A670863B367F

@ -59,7 +59,7 @@ func newGetAllCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return tpl(template, data, out) 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 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 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 return err
} }

@ -39,6 +39,8 @@ The status consists of:
- last deployment time - last deployment time
- k8s namespace in which the release lives - 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) - 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 - list of resources that this release consists of, sorted by kind
- details on last test suite run, if applicable - details on last test suite run, if applicable
- additional notes provided by the chart - 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 // strip chart metadata from the output
rel.Chart = nil rel.Chart = nil
return outfmt.Write(out, &statusPrinter{rel, false}) return outfmt.Write(out, &statusPrinter{rel, false, client.ShowDescription})
}, },
} }
@ -88,6 +90,7 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
} }
bindOutputFlag(cmd, &outfmt) bindOutputFlag(cmd, &outfmt)
f.BoolVar(&client.ShowDescription, "show-desc", false, "if set, display the description message of the named release")
return cmd return cmd
} }
@ -95,6 +98,7 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
type statusPrinter struct { type statusPrinter struct {
release *release.Release release *release.Release
debug bool debug bool
showDescription bool
} }
func (s statusPrinter) WriteJSON(out io.Writer) error { 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, "NAMESPACE: %s\n", s.release.Namespace)
fmt.Fprintf(out, "STATUS: %s\n", s.release.Info.Status.String()) fmt.Fprintf(out, "STATUS: %s\n", s.release.Info.Status.String())
fmt.Fprintf(out, "REVISION: %d\n", s.release.Version) 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) executions := executionsByHookEvent(s.release)
if tests, ok := executions[release.HookTest]; !ok || len(tests) == 0 { if tests, ok := executions[release.HookTest]; !ok || len(tests) == 0 {

@ -44,6 +44,14 @@ func TestStatusCmd(t *testing.T) {
rels: releasesMockWithStatus(&release.Info{ rels: releasesMockWithStatus(&release.Info{
Status: release.StatusDeployed, 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", name: "get status of a deployed release with notes",
cmd: "status flummoxed-chickadee", 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 { if err != nil {
return err return err
} }
return outfmt.Write(out, &statusPrinter{rel, settings.Debug}) return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false})
} else if err != nil { } else if err != nil {
return err 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]) 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 cfg *Configuration
Version int 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. // NewStatus creates a new Status object with the given configuration.

Loading…
Cancel
Save