Merge pull request #6656 from VilledeMontreal/fix/onlySubcommands

v3: 'helm show' -> 'helm show all' and 'helm get' -> 'helm get all'
pull/6681/head
Matthew Fisher 5 years ago committed by GitHub
commit 0c9374e122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,51 +23,27 @@ import (
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli/output"
)
var getHelp = `
This command shows the details of a named release.
It can be used to get extended information about the release, including:
This command consists of multiple subcommands which can be used to
get extended information about the release, including:
- The values used to generate the release
- The chart used to generate the release
- The generated manifest file
By default, this prints a human readable collection of information about the
chart, the supplied values, and the generated manifest file.
- The notes provided by the chart of the release
- The hooks associated with the release
`
func newGetCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
var template string
client := action.NewGet(cfg)
cmd := &cobra.Command{
Use: "get RELEASE_NAME",
Short: "download a named release",
Use: "get",
Short: "download extended information of a named release",
Long: getHelp,
Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
res, err := client.Run(args[0])
if err != nil {
return err
}
if template != "" {
data := map[string]interface{}{
"Release": res,
}
return tpl(template, data, out)
}
return output.Table.Write(out, &statusPrinter{res, true})
},
Args: require.NoArgs,
}
f := cmd.Flags()
f.IntVar(&client.Version, "revision", 0, "get the named release with revision")
f.StringVar(&template, "template", "", "go template for formatting the output, eg: {{.Release.Name}}")
cmd.AddCommand(newGetAllCmd(cfg, out))
cmd.AddCommand(newGetValuesCmd(cfg, out))
cmd.AddCommand(newGetManifestCmd(cfg, out))
cmd.AddCommand(newGetHooksCmd(cfg, out))

@ -0,0 +1,64 @@
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"io"
"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm/require"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/cli/output"
)
var getAllHelp = `
This command prints a human readable collection of information about the
notes, hooks, supplied values, and generated manifest file of the given release.
`
func newGetAllCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
var template string
client := action.NewGet(cfg)
cmd := &cobra.Command{
Use: "all RELEASE_NAME",
Short: "download all information for a named release",
Long: getAllHelp,
Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
res, err := client.Run(args[0])
if err != nil {
return err
}
if template != "" {
data := map[string]interface{}{
"Release": res,
}
return tpl(template, data, out)
}
return output.Table.Write(out, &statusPrinter{res, true})
},
}
f := cmd.Flags()
f.IntVar(&client.Version, "revision", 0, "get the named release with revision")
f.StringVar(&template, "template", "", "go template for formatting the output, eg: {{.Release.Name}}")
return cmd
}

@ -24,19 +24,19 @@ import (
func TestGetCmd(t *testing.T) {
tests := []cmdTestCase{{
name: "get with a release",
cmd: "get thomas-guide",
name: "get all with a release",
cmd: "get all thomas-guide",
golden: "output/get-release.txt",
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "thomas-guide"})},
}, {
name: "get with a formatted release",
cmd: "get elevated-turkey --template {{.Release.Chart.Metadata.Version}}",
name: "get all with a formatted release",
cmd: "get all elevated-turkey --template {{.Release.Chart.Metadata.Version}}",
golden: "output/get-release-template.txt",
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "elevated-turkey"})},
}, {
name: "get requires release name arg",
cmd: "get",
golden: "output/get-no-args.txt",
name: "get all requires release name arg",
cmd: "get all",
golden: "output/get-all-no-args.txt",
wantError: true,
}}
runTestCmd(t, tests)

@ -34,8 +34,8 @@ func newGetNotesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
client := action.NewGet(cfg)
cmd := &cobra.Command{
Use: "notes [flags] RELEASE_NAME",
Short: "displays the notes of the named release",
Use: "notes RELEASE_NAME",
Short: "download the notes for a named release",
Long: getNotesHelp,
Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {

@ -27,10 +27,12 @@ import (
)
const showDesc = `
This command inspects a chart and displays information. It takes a chart reference
('example/drupal'), a full path to a directory or packaged chart, or a URL.
This command consists of multiple subcommands to display information about a chart
`
Inspect prints the contents of the Chart.yaml file and the values.yaml file.
const showAllDesc = `
This command inspects a chart (directory, file, or URL) and displays all its content
(values.yaml, Charts.yaml, README)
`
const showValuesDesc = `
@ -52,12 +54,20 @@ func newShowCmd(out io.Writer) *cobra.Command {
client := action.NewShow(action.ShowAll)
showCommand := &cobra.Command{
Use: "show [CHART]",
Short: "inspect a chart",
Use: "show",
Short: "show information of a chart",
Aliases: []string{"inspect"},
Long: showDesc,
Args: require.ExactArgs(1),
Args: require.NoArgs,
}
all := &cobra.Command{
Use: "all [CHART]",
Short: "shows all information of the chart",
Long: showAllDesc,
Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client.OutputFormat = action.ShowAll
cp, err := client.ChartPathOptions.LocateChart(args[0], settings)
if err != nil {
return err
@ -73,7 +83,7 @@ func newShowCmd(out io.Writer) *cobra.Command {
valuesSubCmd := &cobra.Command{
Use: "values [CHART]",
Short: "shows values for this chart",
Short: "shows the chart's values",
Long: showValuesDesc,
Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
@ -93,7 +103,7 @@ func newShowCmd(out io.Writer) *cobra.Command {
chartSubCmd := &cobra.Command{
Use: "chart [CHART]",
Short: "shows the chart",
Short: "shows the chart's definition",
Long: showChartDesc,
Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
@ -131,12 +141,9 @@ func newShowCmd(out io.Writer) *cobra.Command {
},
}
cmds := []*cobra.Command{showCommand, readmeSubCmd, valuesSubCmd, chartSubCmd}
cmds := []*cobra.Command{all, readmeSubCmd, valuesSubCmd, chartSubCmd}
for _, subCmd := range cmds {
addChartPathOptionsFlags(subCmd.Flags(), &client.ChartPathOptions)
}
for _, subCmd := range cmds[1:] {
showCommand.AddCommand(subCmd)
}

@ -0,0 +1,3 @@
Error: "helm get all" requires 1 argument
Usage: helm get all RELEASE_NAME [flags]

@ -1,3 +0,0 @@
Error: "helm get" requires 1 argument
Usage: helm get RELEASE_NAME [flags]

@ -1,3 +1,3 @@
Error: "helm get notes" requires 1 argument
Usage: helm get notes [flags] RELEASE_NAME
Usage: helm get notes RELEASE_NAME [flags]

Loading…
Cancel
Save