Skip to content

Commit

Permalink
Port --devel flag from v2 to v3
Browse files Browse the repository at this point in the history
Helm v2 PR helm#5141

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Signed-off-by: Matheus Hunsche <matheus.hunsche@ifood.com.br>
  • Loading branch information
hickeyma authored and Matheus Hunsche committed Oct 2, 2020
1 parent 48250fd commit d0b5bbf
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
49 changes: 27 additions & 22 deletions cmd/helm/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ func newShowCmd(out io.Writer) *cobra.Command {
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
}
output, err := client.Run(cp)
output, err := runShow(args, client)
if err != nil {
return err
}
Expand All @@ -97,11 +93,7 @@ func newShowCmd(out io.Writer) *cobra.Command {
Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client.OutputFormat = action.ShowValues
cp, err := client.ChartPathOptions.LocateChart(args[0], settings)
if err != nil {
return err
}
output, err := client.Run(cp)
output, err := runShow(args, client)
if err != nil {
return err
}
Expand All @@ -117,11 +109,7 @@ func newShowCmd(out io.Writer) *cobra.Command {
Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client.OutputFormat = action.ShowChart
cp, err := client.ChartPathOptions.LocateChart(args[0], settings)
if err != nil {
return err
}
output, err := client.Run(cp)
output, err := runShow(args, client)
if err != nil {
return err
}
Expand All @@ -137,11 +125,7 @@ func newShowCmd(out io.Writer) *cobra.Command {
Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client.OutputFormat = action.ShowReadme
cp, err := client.ChartPathOptions.LocateChart(args[0], settings)
if err != nil {
return err
}
output, err := client.Run(cp)
output, err := runShow(args, client)
if err != nil {
return err
}
Expand All @@ -152,12 +136,33 @@ func newShowCmd(out io.Writer) *cobra.Command {

cmds := []*cobra.Command{all, readmeSubCmd, valuesSubCmd, chartSubCmd}
for _, subCmd := range cmds {
addChartPathOptionsFlags(subCmd.Flags(), &client.ChartPathOptions)
showCommand.AddCommand(subCmd)
addShowFlags(showCommand, subCmd, client)

// Register the completion function for each subcommand
completion.RegisterValidArgsFunc(subCmd, validArgsFunc)
}

return showCommand
}

func addShowFlags(showCmd *cobra.Command, subCmd *cobra.Command, client *action.Show) {
f := subCmd.Flags()

f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored")
addChartPathOptionsFlags(f, &client.ChartPathOptions)
showCmd.AddCommand(subCmd)
}

func runShow(args []string, client *action.Show) (string, error) {
debug("Original chart version: %q", client.Version)
if client.Version == "" && client.Devel {
debug("setting version to >0.0.0-0")
client.Version = ">0.0.0-0"
}

cp, err := client.ChartPathOptions.LocateChart(args[0], settings)
if err != nil {
return "", err
}
return client.Run(cp)
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.13

require (
github.com/BurntSushi/toml v0.3.1
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/semver/v3 v3.0.3
github.com/Masterminds/sprig/v3 v3.0.2
github.com/Masterminds/vcs v1.13.1
Expand Down Expand Up @@ -34,6 +35,7 @@ require (
k8s.io/apimachinery v0.17.3
k8s.io/cli-runtime v0.17.3
k8s.io/client-go v0.17.3
k8s.io/helm v2.16.3+incompatible
k8s.io/klog v1.0.0
k8s.io/kubectl v0.17.3
sigs.k8s.io/yaml v1.1.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd h1:sjQovDkwrZp
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E=
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver/v3 v3.0.3 h1:znjIyLfpXEDQjOIEWh+ehwpTU14UzUPub3c3sm36u14=
github.com/Masterminds/semver/v3 v3.0.3/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Masterminds/sprig/v3 v3.0.2 h1:wz22D0CiSctrliXiI9ZO3HoNApweeRGftyDN+BQa3B8=
Expand Down Expand Up @@ -653,6 +655,8 @@ k8s.io/component-base v0.17.3 h1:hQzTSshY14aLSR6WGIYvmw+w+u6V4d+iDR2iDGMrlUg=
k8s.io/component-base v0.17.3/go.mod h1:GeQf4BrgelWm64PXkIXiPh/XS0hnO42d9gx9BtbZRp8=
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/helm v2.16.3+incompatible h1:MGUcXcG1uAXWZmxu4vzzgRjZOnfFUsSJbHgqM+kyqzM=
k8s.io/helm v2.16.3+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
Expand Down
3 changes: 2 additions & 1 deletion pkg/action/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ func (o ShowOutputFormat) String() string {
//
// It provides the implementation of 'helm show' and its respective subcommands.
type Show struct {
OutputFormat ShowOutputFormat
ChartPathOptions
Devel bool
OutputFormat ShowOutputFormat
}

// NewShow creates a new Show object with the given configuration.
Expand Down

0 comments on commit d0b5bbf

Please sign in to comment.