Merge pull request #1394 from fibonacci1729/fix/1357

fix(1357): print help text if revision is not specified
pull/1405/head
Brian 8 years ago committed by GitHub
commit 4899faa9ba

@ -19,6 +19,7 @@ package main
import (
"fmt"
"io"
"strconv"
"github.com/spf13/cobra"
@ -32,7 +33,7 @@ The argument of the rollback command is the name of a release.
type rollbackCmd struct {
name string
version int32
revision int32
dryRun bool
disableHooks bool
out io.Writer
@ -51,17 +52,24 @@ func newRollbackCmd(c helm.Interface, out io.Writer) *cobra.Command {
Long: rollbackDesc,
PersistentPreRunE: setupConnection,
RunE: func(cmd *cobra.Command, args []string) error {
if err := checkArgsLength(len(args), "release name"); err != nil {
if err := checkArgsLength(len(args), "release name", "revision number"); err != nil {
return err
}
rollback.name = args[0]
v64, err := strconv.ParseInt(args[1], 10, 32)
if err != nil {
return fmt.Errorf("invalid revision number '%q': %s", args[1], err)
}
rollback.revision = int32(v64)
rollback.client = ensureHelmClient(rollback.client)
return rollback.run()
},
}
f := cmd.Flags()
f.Int32Var(&rollback.version, "revision", 0, "revision to deploy")
f.BoolVar(&rollback.dryRun, "dry-run", false, "simulate a rollback")
f.BoolVar(&rollback.disableHooks, "no-hooks", false, "prevent hooks from running during rollback")
@ -73,7 +81,7 @@ func (r *rollbackCmd) run() error {
r.name,
helm.RollbackDryRun(r.dryRun),
helm.RollbackDisableHooks(r.disableHooks),
helm.RollbackVersion(r.version),
helm.RollbackVersion(r.revision),
)
if err != nil {
return prettyError(err)

@ -28,14 +28,13 @@ func TestRollbackCmd(t *testing.T) {
tests := []releaseCase{
{
name: "rollback a release",
args: []string{"funny-honey"},
flags: []string{"revision", "1"},
args: []string{"funny-honey", "1"},
expected: "Rollback was a success! Happy Helming!",
},
{
name: "rollback a release without version",
name: "rollback a release without revision",
args: []string{"funny-honey"},
expected: "Rollback was a success! Happy Helming!",
err: true,
},
}

Loading…
Cancel
Save