From f185103b602645ddabbd27107fb1df9478159910 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Wed, 13 Mar 2019 08:58:35 -0700 Subject: [PATCH] ref(action): move AddFlags functions back to cmd Signed-off-by: Matthew Fisher --- cmd/helm/dependency_build.go | 14 +++++++++++- cmd/helm/dependency_update.go | 5 ++++- cmd/helm/get.go | 2 +- cmd/helm/get_hooks.go | 2 +- cmd/helm/get_manifest.go | 2 +- cmd/helm/get_values.go | 4 +++- cmd/helm/history.go | 4 +++- cmd/helm/install.go | 35 ++++++++++++++++++++++++++++- cmd/helm/lint.go | 4 +++- cmd/helm/list.go | 16 ++++++++++++- cmd/helm/package.go | 10 ++++++++- cmd/helm/pull.go | 8 ++++++- cmd/helm/release_testing.go | 4 +++- cmd/helm/rollback.go | 9 +++++++- cmd/helm/show.go | 2 +- cmd/helm/status.go | 4 +++- cmd/helm/template.go | 2 +- cmd/helm/uninstall.go | 6 ++++- cmd/helm/upgrade.go | 15 ++++++++++++- cmd/helm/verify.go | 2 +- pkg/action/dependency.go | 11 --------- pkg/action/get.go | 6 ----- pkg/action/get_values.go | 6 ----- pkg/action/history.go | 6 ----- pkg/action/install.go | 42 ----------------------------------- pkg/action/lint.go | 6 ----- pkg/action/list.go | 18 --------------- pkg/action/package.go | 12 ---------- pkg/action/pull.go | 10 --------- pkg/action/release_testing.go | 6 ----- pkg/action/rollback.go | 11 --------- pkg/action/show.go | 5 ----- pkg/action/status.go | 7 ------ pkg/action/uninstall.go | 8 ------- pkg/action/upgrade.go | 17 -------------- pkg/action/verify.go | 6 ----- 36 files changed, 130 insertions(+), 197 deletions(-) diff --git a/cmd/helm/dependency_build.go b/cmd/helm/dependency_build.go index 340eddb22..af7231d69 100644 --- a/cmd/helm/dependency_build.go +++ b/cmd/helm/dependency_build.go @@ -17,10 +17,12 @@ package main import ( "io" + "os" "path/filepath" "github.com/spf13/cobra" + "k8s.io/client-go/util/homedir" "k8s.io/helm/cmd/helm/require" "k8s.io/helm/pkg/action" "k8s.io/helm/pkg/downloader" @@ -68,7 +70,17 @@ func newDependencyBuildCmd(out io.Writer) *cobra.Command { }, } - client.AddBuildFlags(cmd.Flags()) + f := cmd.Flags() + f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures") + f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") return cmd } + +// defaultKeyring returns the expanded path to the default keyring. +func defaultKeyring() string { + if v, ok := os.LookupEnv("GNUPGHOME"); ok { + return filepath.Join(v, "pubring.gpg") + } + return filepath.Join(homedir.HomeDir(), ".gnupg", "pubring.gpg") +} diff --git a/cmd/helm/dependency_update.go b/cmd/helm/dependency_update.go index 1b7edc2c1..bad61e709 100644 --- a/cmd/helm/dependency_update.go +++ b/cmd/helm/dependency_update.go @@ -75,7 +75,10 @@ func newDependencyUpdateCmd(out io.Writer) *cobra.Command { }, } - client.AddUpdateFlags(cmd.Flags()) + f := cmd.Flags() + f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures") + f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") + f.BoolVar(&client.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache") return cmd } diff --git a/cmd/helm/get.go b/cmd/helm/get.go index 166c16014..e6e853305 100644 --- a/cmd/helm/get.go +++ b/cmd/helm/get.go @@ -55,7 +55,7 @@ func newGetCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision") cmd.AddCommand(newGetValuesCmd(cfg, out)) cmd.AddCommand(newGetManifestCmd(cfg, out)) diff --git a/cmd/helm/get_hooks.go b/cmd/helm/get_hooks.go index 77cd4267a..6ac8aed6a 100644 --- a/cmd/helm/get_hooks.go +++ b/cmd/helm/get_hooks.go @@ -52,7 +52,7 @@ func newGetHooksCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision") return cmd } diff --git a/cmd/helm/get_manifest.go b/cmd/helm/get_manifest.go index d2d738b76..8a76c7f2e 100644 --- a/cmd/helm/get_manifest.go +++ b/cmd/helm/get_manifest.go @@ -52,7 +52,7 @@ func newGetManifestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command }, } - client.AddFlags(cmd.Flags()) + cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision") return cmd } diff --git a/cmd/helm/get_values.go b/cmd/helm/get_values.go index dbce71603..f29f6c865 100644 --- a/cmd/helm/get_values.go +++ b/cmd/helm/get_values.go @@ -48,6 +48,8 @@ func newGetValuesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + f := cmd.Flags() + f.IntVar(&client.Version, "revision", 0, "get the named release with revision") + f.BoolVarP(&client.AllValues, "all", "a", false, "dump all (computed) values") return cmd } diff --git a/cmd/helm/history.go b/cmd/helm/history.go index 655665d7c..b16f6c8d0 100644 --- a/cmd/helm/history.go +++ b/cmd/helm/history.go @@ -61,7 +61,9 @@ func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + f := cmd.Flags() + f.StringVarP(&client.OutputFormat, "output", "o", action.Table.String(), "prints the output in the specified format (json|table|yaml)") + f.IntVar(&client.Max, "max", 256, "maximum number of revision to include in history") return cmd } diff --git a/cmd/helm/install.go b/cmd/helm/install.go index b05dce503..de20f0f68 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -22,6 +22,7 @@ import ( "k8s.io/helm/pkg/release" "github.com/spf13/cobra" + "github.com/spf13/pflag" "k8s.io/helm/cmd/helm/require" "k8s.io/helm/pkg/action" @@ -111,11 +112,43 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + addInstallFlags(cmd.Flags(), client) return cmd } +func addInstallFlags(f *pflag.FlagSet, client *action.Install) { + f.BoolVar(&client.DryRun, "dry-run", false, "simulate an install") + f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during install") + f.BoolVar(&client.Replace, "replace", false, "re-use the given name, even if that name is already used. This is unsafe in production") + f.Int64Var(&client.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") + f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout") + f.BoolVarP(&client.GenerateName, "generate-name", "g", false, "generate the name (and omit the NAME parameter)") + f.StringVar(&client.NameTemplate, "name-template", "", "specify template used to name the release") + f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.") + f.BoolVar(&client.DependencyUpdate, "dependency-update", false, "run helm dependency update before installing the chart") + addValueOptionsFlags(f, &client.ValueOptions) + addChartPathOptionsFlags(f, &client.ChartPathOptions) +} + +func addValueOptionsFlags(f *pflag.FlagSet, v *action.ValueOptions) { + f.StringSliceVarP(&v.ValueFiles, "values", "f", []string{}, "specify values in a YAML file or a URL(can specify multiple)") + f.StringArrayVar(&v.Values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") + f.StringArrayVar(&v.StringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") +} + +func addChartPathOptionsFlags(f *pflag.FlagSet, c *action.ChartPathOptions) { + f.StringVar(&c.Version, "version", "", "specify the exact chart version to install. If this is not specified, the latest version is installed") + f.BoolVar(&c.Verify, "verify", false, "verify the package before installing it") + f.StringVar(&c.Keyring, "keyring", defaultKeyring(), "location of public keys used for verification") + f.StringVar(&c.RepoURL, "repo", "", "chart repository url where to locate the requested chart") + f.StringVar(&c.Username, "username", "", "chart repository username where to locate the requested chart") + f.StringVar(&c.Password, "password", "", "chart repository password where to locate the requested chart") + f.StringVar(&c.CertFile, "cert-file", "", "identify HTTPS client using this SSL certificate file") + f.StringVar(&c.KeyFile, "key-file", "", "identify HTTPS client using this SSL key file") + f.StringVar(&c.CaFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") +} + func runInstall(args []string, client *action.Install, out io.Writer) (*release.Release, error) { debug("Original chart version: %q", client.Version) if client.Version == "" && client.Devel { diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index 8799b81da..eb6c7402a 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -70,7 +70,9 @@ func newLintCmd(out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + f := cmd.Flags() + f.BoolVar(&client.Strict, "strict", false, "fail on lint warnings") + addValueOptionsFlags(f, &client.ValueOptions) return cmd } diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 6dcd3cf46..2c3a89cfb 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -83,7 +83,21 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + f := cmd.Flags() + f.BoolVarP(&client.Short, "short", "q", false, "output short (quiet) listing format") + f.BoolVarP(&client.ByDate, "date", "d", false, "sort by release date") + f.BoolVarP(&client.SortDesc, "reverse", "r", false, "reverse the sort order") + f.BoolVarP(&client.All, "all", "a", false, "show all releases, not just the ones marked deployed") + f.BoolVar(&client.Uninstalled, "uninstalled", false, "show uninstalled releases") + f.BoolVar(&client.Superseded, "superseded", false, "show superseded releases") + f.BoolVar(&client.Uninstalling, "uninstalling", false, "show releases that are currently being uninstalled") + f.BoolVar(&client.Deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled") + f.BoolVar(&client.Failed, "failed", false, "show failed releases") + f.BoolVar(&client.Pending, "pending", false, "show pending releases") + f.BoolVar(&client.AllNamespaces, "all-namespaces", false, "list releases across all namespaces") + f.IntVarP(&client.Limit, "max", "m", 256, "maximum number of releases to fetch") + f.IntVarP(&client.Offset, "offset", "o", 0, "next release name in the list, used to offset from start value") + f.StringVarP(&client.Filter, "filter", "f", "", "a regular expression (Perl compatible). Any releases that match the expression will be included in the results") return cmd } diff --git a/cmd/helm/package.go b/cmd/helm/package.go index e308e4026..efd35b067 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -95,7 +95,15 @@ func newPackageCmd(out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + f := cmd.Flags() + f.BoolVar(&client.Sign, "sign", false, "use a PGP private key to sign this package") + f.StringVar(&client.Key, "key", "", "name of the key to use when signing. Used if --sign is true") + f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "location of a public keyring") + f.StringVar(&client.Version, "version", "", "set the version on the chart to this semver version") + f.StringVar(&client.AppVersion, "app-version", "", "set the appVersion on the chart to this version") + f.StringVarP(&client.Destination, "destination", "d", ".", "location to write the chart.") + f.BoolVarP(&client.DependencyUpdate, "dependency-update", "u", false, `update dependencies from "Chart.yaml" to dir "charts/" before packaging`) + addValueOptionsFlags(f, &client.ValueOptions) return cmd } diff --git a/cmd/helm/pull.go b/cmd/helm/pull.go index d938e5fb9..cd1adf8c2 100644 --- a/cmd/helm/pull.go +++ b/cmd/helm/pull.go @@ -68,7 +68,13 @@ func newPullCmd(out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + f := cmd.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.") + f.BoolVar(&client.Untar, "untar", false, "if set to true, will untar the chart after downloading it") + f.BoolVar(&client.VerifyLater, "prov", false, "fetch the provenance file, but don't perform verification") + f.StringVar(&client.UntarDir, "untardir", ".", "if untar is specified, this flag specifies the name of the directory into which the chart is expanded") + f.StringVarP(&client.DestDir, "destination", "d", ".", "location to write the chart. If this and tardir are specified, tardir is appended to this") + addChartPathOptionsFlags(f, &client.ChartPathOptions) return cmd } diff --git a/cmd/helm/release_testing.go b/cmd/helm/release_testing.go index 524bdfdce..bd27a618d 100644 --- a/cmd/helm/release_testing.go +++ b/cmd/helm/release_testing.go @@ -68,7 +68,9 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command }, } - client.AddFlags(cmd.Flags()) + f := cmd.Flags() + f.Int64Var(&client.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") + f.BoolVar(&client.Cleanup, "cleanup", false, "delete test pods upon completion") return cmd } diff --git a/cmd/helm/rollback.go b/cmd/helm/rollback.go index af2d4f1ea..f691fbfb9 100644 --- a/cmd/helm/rollback.go +++ b/cmd/helm/rollback.go @@ -54,7 +54,14 @@ func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + f := cmd.Flags() + f.IntVarP(&client.Version, "version", "v", 0, "revision number to rollback to (default: rollback to previous release)") + f.BoolVar(&client.DryRun, "dry-run", false, "simulate a rollback") + f.BoolVar(&client.Recreate, "recreate-pods", false, "performs pods restart for the resource if applicable") + f.BoolVar(&client.Force, "force", false, "force resource update through delete/recreate if needed") + f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during rollback") + f.Int64Var(&client.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") + f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout") return cmd } diff --git a/cmd/helm/show.go b/cmd/helm/show.go index 8aac2183b..d8970f077 100644 --- a/cmd/helm/show.go +++ b/cmd/helm/show.go @@ -133,7 +133,7 @@ func newShowCmd(out io.Writer) *cobra.Command { cmds := []*cobra.Command{showCommand, readmeSubCmd, valuesSubCmd, chartSubCmd} for _, subCmd := range cmds { - client.AddFlags(subCmd.Flags()) + addChartPathOptionsFlags(subCmd.Flags(), &client.ChartPathOptions) } for _, subCmd := range cmds[1:] { diff --git a/cmd/helm/status.go b/cmd/helm/status.go index 146bde9bc..0c6bee728 100644 --- a/cmd/helm/status.go +++ b/cmd/helm/status.go @@ -83,7 +83,9 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.PersistentFlags()) + f := cmd.PersistentFlags() + f.IntVar(&client.Version, "revision", 0, "if set, display the status of the named release with revision") + f.StringVarP(&client.OutputFormat, "output", "o", "", "output the status in the specified format (json or yaml)") return cmd } diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 64cd336d8..f33237dea 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -76,7 +76,7 @@ func newTemplateCmd(out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + addInstallFlags(cmd.Flags(), client) return cmd } diff --git a/cmd/helm/uninstall.go b/cmd/helm/uninstall.go index ed70d36ce..a52d151e4 100644 --- a/cmd/helm/uninstall.go +++ b/cmd/helm/uninstall.go @@ -61,7 +61,11 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + f := cmd.Flags() + f.BoolVar(&client.DryRun, "dry-run", false, "simulate a uninstall") + f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation") + f.BoolVar(&client.Purge, "purge", false, "remove the release from the store and make its name free for later use") + f.Int64Var(&client.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") return cmd } diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 5e9fbb92f..a5079e91e 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -135,7 +135,20 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + f := cmd.Flags() + f.BoolVarP(&client.Install, "install", "i", false, "if a release by this name doesn't already exist, run an install") + f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.") + f.BoolVar(&client.DryRun, "dry-run", false, "simulate an upgrade") + f.BoolVar(&client.Recreate, "recreate-pods", false, "performs pods restart for the resource if applicable") + f.BoolVar(&client.Force, "force", false, "force resource update through delete/recreate if needed") + f.BoolVar(&client.DisableHooks, "no-hooks", false, "disable pre/post upgrade hooks") + f.Int64Var(&client.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") + f.BoolVar(&client.ResetValues, "reset-values", false, "when upgrading, reset the values to the ones built into the chart") + f.BoolVar(&client.ReuseValues, "reuse-values", false, "when upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' is specified, this is ignored.") + f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout") + f.IntVar(&client.MaxHistory, "history-max", 0, "limit the maximum number of revisions saved per release. Use 0 for no limit.") + addChartPathOptionsFlags(f, &client.ChartPathOptions) + addValueOptionsFlags(f, &client.ValueOptions) return cmd } diff --git a/cmd/helm/verify.go b/cmd/helm/verify.go index c34845e7d..d9069312a 100644 --- a/cmd/helm/verify.go +++ b/cmd/helm/verify.go @@ -48,7 +48,7 @@ func newVerifyCmd(out io.Writer) *cobra.Command { }, } - client.AddFlags(cmd.Flags()) + cmd.Flags().StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") return cmd } diff --git a/pkg/action/dependency.go b/pkg/action/dependency.go index e877697bc..b17a09aa4 100644 --- a/pkg/action/dependency.go +++ b/pkg/action/dependency.go @@ -24,7 +24,6 @@ import ( "github.com/Masterminds/semver" "github.com/gosuri/uitable" - "github.com/spf13/pflag" "k8s.io/helm/pkg/chart" "k8s.io/helm/pkg/chart/loader" @@ -44,16 +43,6 @@ func NewDependency() *Dependency { return &Dependency{} } -func (d *Dependency) AddBuildFlags(f *pflag.FlagSet) { - f.BoolVar(&d.Verify, "verify", false, "verify the packages against signatures") - f.StringVar(&d.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") -} - -func (d *Dependency) AddUpdateFlags(f *pflag.FlagSet) { - d.AddBuildFlags(f) - f.BoolVar(&d.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache") -} - // List executes 'helm dependency list'. func (d *Dependency) List(chartpath string, out io.Writer) error { c, err := loader.Load(chartpath) diff --git a/pkg/action/get.go b/pkg/action/get.go index 453173e27..f4726c48c 100644 --- a/pkg/action/get.go +++ b/pkg/action/get.go @@ -17,8 +17,6 @@ limitations under the License. package action import ( - "github.com/spf13/pflag" - "k8s.io/helm/pkg/release" ) @@ -42,7 +40,3 @@ func NewGet(cfg *Configuration) *Get { func (g *Get) Run(name string) (*release.Release, error) { return g.cfg.releaseContent(name, g.Version) } - -func (g *Get) AddFlags(f *pflag.FlagSet) { - f.IntVar(&g.Version, "revision", 0, "get the named release with revision") -} diff --git a/pkg/action/get_values.go b/pkg/action/get_values.go index 95c494929..eaea54929 100644 --- a/pkg/action/get_values.go +++ b/pkg/action/get_values.go @@ -18,7 +18,6 @@ package action import ( "github.com/ghodss/yaml" - "github.com/spf13/pflag" "k8s.io/helm/pkg/chartutil" ) @@ -67,8 +66,3 @@ func (g *GetValues) Run(name string) (string, error) { return string(resConfig), nil } - -func (g *GetValues) AddFlags(f *pflag.FlagSet) { - f.IntVar(&g.Version, "revision", 0, "get the named release with revision") - f.BoolVarP(&g.AllValues, "all", "a", false, "dump all (computed) values") -} diff --git a/pkg/action/history.go b/pkg/action/history.go index 25570d0d4..d90350708 100644 --- a/pkg/action/history.go +++ b/pkg/action/history.go @@ -23,7 +23,6 @@ import ( "github.com/ghodss/yaml" "github.com/gosuri/uitable" "github.com/pkg/errors" - "github.com/spf13/pflag" "k8s.io/helm/pkg/chart" "k8s.io/helm/pkg/release" @@ -136,11 +135,6 @@ func (h *History) Run(name string) (string, error) { return string(history), nil } -func (h *History) AddFlags(f *pflag.FlagSet) { - f.StringVarP(&h.OutputFormat, "output", "o", Table.String(), "prints the output in the specified format (json|table|yaml)") - f.IntVar(&h.Max, "max", 256, "maximum number of revision to include in history") -} - func getReleaseHistory(rls []*release.Release) (history releaseHistory) { for i := len(rls) - 1; i >= 0; i-- { r := rls[i] diff --git a/pkg/action/install.go b/pkg/action/install.go index d6df201eb..b3cb92d04 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -33,8 +33,6 @@ import ( "github.com/Masterminds/sprig" "github.com/ghodss/yaml" "github.com/pkg/errors" - "github.com/spf13/pflag" - "k8s.io/client-go/util/homedir" "k8s.io/helm/pkg/chart" "k8s.io/helm/pkg/chartutil" @@ -487,46 +485,6 @@ func (i *Install) NameAndChart(args []string) (string, string, error) { return fmt.Sprintf("%s-%d", base, time.Now().Unix()), args[0], nil } -func (i *Install) AddFlags(f *pflag.FlagSet) { - f.BoolVar(&i.DryRun, "dry-run", false, "simulate an install") - f.BoolVar(&i.DisableHooks, "no-hooks", false, "prevent hooks from running during install") - f.BoolVar(&i.Replace, "replace", false, "re-use the given name, even if that name is already used. This is unsafe in production") - f.Int64Var(&i.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") - f.BoolVar(&i.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout") - f.BoolVarP(&i.GenerateName, "generate-name", "g", false, "generate the name (and omit the NAME parameter)") - f.StringVar(&i.NameTemplate, "name-template", "", "specify template used to name the release") - f.BoolVar(&i.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.") - f.BoolVar(&i.DependencyUpdate, "dependency-update", false, "run helm dependency update before installing the chart") - i.ValueOptions.AddFlags(f) - i.ChartPathOptions.AddFlags(f) -} - -func (v *ValueOptions) AddFlags(f *pflag.FlagSet) { - f.StringSliceVarP(&v.ValueFiles, "values", "f", []string{}, "specify values in a YAML file or a URL(can specify multiple)") - f.StringArrayVar(&v.Values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") - f.StringArrayVar(&v.StringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") -} - -func (c *ChartPathOptions) AddFlags(f *pflag.FlagSet) { - f.StringVar(&c.Version, "version", "", "specify the exact chart version to install. If this is not specified, the latest version is installed") - f.BoolVar(&c.Verify, "verify", false, "verify the package before installing it") - f.StringVar(&c.Keyring, "keyring", defaultKeyring(), "location of public keys used for verification") - f.StringVar(&c.RepoURL, "repo", "", "chart repository url where to locate the requested chart") - f.StringVar(&c.Username, "username", "", "chart repository username where to locate the requested chart") - f.StringVar(&c.Password, "password", "", "chart repository password where to locate the requested chart") - f.StringVar(&c.CertFile, "cert-file", "", "identify HTTPS client using this SSL certificate file") - f.StringVar(&c.KeyFile, "key-file", "", "identify HTTPS client using this SSL key file") - f.StringVar(&c.CaFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") -} - -// defaultKeyring returns the expanded path to the default keyring. -func defaultKeyring() string { - if v, ok := os.LookupEnv("GNUPGHOME"); ok { - return filepath.Join(v, "pubring.gpg") - } - return filepath.Join(homedir.HomeDir(), ".gnupg", "pubring.gpg") -} - func TemplateName(nameTemplate string) (string, error) { if nameTemplate == "" { return "", nil diff --git a/pkg/action/lint.go b/pkg/action/lint.go index 1ed1adc2d..e7e464e92 100644 --- a/pkg/action/lint.go +++ b/pkg/action/lint.go @@ -23,7 +23,6 @@ import ( "strings" "github.com/pkg/errors" - "github.com/spf13/pflag" "k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/lint" @@ -115,8 +114,3 @@ func lintChart(path string, vals map[string]interface{}, namespace string, stric return lint.All(chartPath, vals, namespace, strict), nil } - -func (l *Lint) AddFlags(f *pflag.FlagSet) { - f.BoolVar(&l.Strict, "strict", false, "fail on lint warnings") - l.ValueOptions.AddFlags(f) -} diff --git a/pkg/action/list.go b/pkg/action/list.go index 9ec0347cb..27e6577d9 100644 --- a/pkg/action/list.go +++ b/pkg/action/list.go @@ -21,7 +21,6 @@ import ( "regexp" "github.com/gosuri/uitable" - "github.com/spf13/pflag" "k8s.io/helm/pkg/release" "k8s.io/helm/pkg/releaseutil" @@ -138,23 +137,6 @@ func NewList(cfg *Configuration) *List { } } -func (l *List) AddFlags(f *pflag.FlagSet) { - f.BoolVarP(&l.Short, "short", "q", false, "output short (quiet) listing format") - f.BoolVarP(&l.ByDate, "date", "d", false, "sort by release date") - f.BoolVarP(&l.SortDesc, "reverse", "r", false, "reverse the sort order") - f.BoolVarP(&l.All, "all", "a", false, "show all releases, not just the ones marked deployed") - f.BoolVar(&l.Uninstalled, "uninstalled", false, "show uninstalled releases") - f.BoolVar(&l.Superseded, "superseded", false, "show superseded releases") - f.BoolVar(&l.Uninstalling, "uninstalling", false, "show releases that are currently being uninstalled") - f.BoolVar(&l.Deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled") - f.BoolVar(&l.Failed, "failed", false, "show failed releases") - f.BoolVar(&l.Pending, "pending", false, "show pending releases") - f.BoolVar(&l.AllNamespaces, "all-namespaces", false, "list releases across all namespaces") - f.IntVarP(&l.Limit, "max", "m", 256, "maximum number of releases to fetch") - f.IntVarP(&l.Offset, "offset", "o", 0, "next release name in the list, used to offset from start value") - f.StringVarP(&l.Filter, "filter", "f", "", "a regular expression (Perl compatible). Any releases that match the expression will be included in the results") -} - func (l *List) SetConfiguration(cfg *Configuration) { l.cfg = cfg } diff --git a/pkg/action/package.go b/pkg/action/package.go index d3a3ee4a9..8624118fc 100644 --- a/pkg/action/package.go +++ b/pkg/action/package.go @@ -24,7 +24,6 @@ import ( "github.com/Masterminds/semver" "github.com/pkg/errors" - "github.com/spf13/pflag" "golang.org/x/crypto/ssh/terminal" "k8s.io/helm/pkg/chart" @@ -112,17 +111,6 @@ func (p *Package) Run(path string) (string, error) { return "", err } -func (p *Package) AddFlags(f *pflag.FlagSet) { - f.BoolVar(&p.Sign, "sign", false, "use a PGP private key to sign this package") - f.StringVar(&p.Key, "key", "", "name of the key to use when signing. Used if --sign is true") - f.StringVar(&p.Keyring, "keyring", defaultKeyring(), "location of a public keyring") - f.StringVar(&p.Version, "version", "", "set the version on the chart to this semver version") - f.StringVar(&p.AppVersion, "app-version", "", "set the appVersion on the chart to this version") - f.StringVarP(&p.Destination, "destination", "d", ".", "location to write the chart.") - f.BoolVarP(&p.DependencyUpdate, "dependency-update", "u", false, `update dependencies from "Chart.yaml" to dir "charts/" before packaging`) - p.ValueOptions.AddFlags(f) -} - func setVersion(ch *chart.Chart, ver string) error { // Verify that version is a Version, and error out if it is not. if _, err := semver.NewVersion(ver); err != nil { diff --git a/pkg/action/pull.go b/pkg/action/pull.go index b1fc3fa98..0c23941ca 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -24,7 +24,6 @@ import ( "strings" "github.com/pkg/errors" - "github.com/spf13/pflag" "k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/cli" @@ -121,12 +120,3 @@ func (p *Pull) Run(chartRef string) (string, error) { } return out.String(), nil } - -func (p *Pull) AddFlags(f *pflag.FlagSet) { - f.BoolVar(&p.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.") - f.BoolVar(&p.Untar, "untar", false, "if set to true, will untar the chart after downloading it") - f.BoolVar(&p.VerifyLater, "prov", false, "fetch the provenance file, but don't perform verification") - f.StringVar(&p.UntarDir, "untardir", ".", "if untar is specified, this flag specifies the name of the directory into which the chart is expanded") - f.StringVarP(&p.DestDir, "destination", "d", ".", "location to write the chart. If this and tardir are specified, tardir is appended to this") - p.ChartPathOptions.AddFlags(f) -} diff --git a/pkg/action/release_testing.go b/pkg/action/release_testing.go index 39ce242fd..f98ecbe3f 100644 --- a/pkg/action/release_testing.go +++ b/pkg/action/release_testing.go @@ -18,7 +18,6 @@ package action import ( "github.com/pkg/errors" - "github.com/spf13/pflag" "k8s.io/helm/pkg/release" reltesting "k8s.io/helm/pkg/releasetesting" @@ -41,11 +40,6 @@ func NewReleaseTesting(cfg *Configuration) *ReleaseTesting { } } -func (r *ReleaseTesting) AddFlags(f *pflag.FlagSet) { - f.Int64Var(&r.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") - f.BoolVar(&r.Cleanup, "cleanup", false, "delete test pods upon completion") -} - // Run executes 'helm test' against the given release. func (r *ReleaseTesting) Run(name string) (<-chan *release.TestReleaseResponse, <-chan error) { errc := make(chan error, 1) diff --git a/pkg/action/rollback.go b/pkg/action/rollback.go index 2dc533947..48c4dfda2 100644 --- a/pkg/action/rollback.go +++ b/pkg/action/rollback.go @@ -23,7 +23,6 @@ import ( "time" "github.com/pkg/errors" - "github.com/spf13/pflag" "k8s.io/helm/pkg/hooks" "k8s.io/helm/pkg/release" @@ -51,16 +50,6 @@ func NewRollback(cfg *Configuration) *Rollback { } } -func (r *Rollback) AddFlags(f *pflag.FlagSet) { - f.IntVarP(&r.Version, "version", "v", 0, "revision number to rollback to (default: rollback to previous release)") - f.BoolVar(&r.DryRun, "dry-run", false, "simulate a rollback") - f.BoolVar(&r.Recreate, "recreate-pods", false, "performs pods restart for the resource if applicable") - f.BoolVar(&r.Force, "force", false, "force resource update through delete/recreate if needed") - f.BoolVar(&r.DisableHooks, "no-hooks", false, "prevent hooks from running during rollback") - f.Int64Var(&r.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") - f.BoolVar(&r.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout") -} - // Run executes 'helm rollback' against the given release. func (r *Rollback) Run(name string) (*release.Release, error) { r.cfg.Log("preparing rollback of %s", name) diff --git a/pkg/action/show.go b/pkg/action/show.go index b20db2b24..8d1389f1d 100644 --- a/pkg/action/show.go +++ b/pkg/action/show.go @@ -21,7 +21,6 @@ import ( "strings" "github.com/ghodss/yaml" - "github.com/spf13/pflag" "k8s.io/helm/pkg/chart" "k8s.io/helm/pkg/chart/loader" @@ -73,10 +72,6 @@ func NewShow(output ShowOutputFormat) *Show { } } -func (s *Show) AddFlags(f *pflag.FlagSet) { - s.ChartPathOptions.AddFlags(f) -} - // Run executes 'helm show' against the given release. func (s *Show) Run(chartpath string) (string, error) { var out strings.Builder diff --git a/pkg/action/status.go b/pkg/action/status.go index 3bb58112c..3f7f684a3 100644 --- a/pkg/action/status.go +++ b/pkg/action/status.go @@ -17,8 +17,6 @@ limitations under the License. package action import ( - "github.com/spf13/pflag" - "k8s.io/helm/pkg/release" ) @@ -39,11 +37,6 @@ func NewStatus(cfg *Configuration) *Status { } } -func (s *Status) AddFlags(f *pflag.FlagSet) { - f.IntVar(&s.Version, "revision", 0, "if set, display the status of the named release with revision") - f.StringVarP(&s.OutputFormat, "output", "o", "", "output the status in the specified format (json or yaml)") -} - // Run executes 'helm status' against the given release. func (s *Status) Run(name string) (*release.Release, error) { return s.cfg.releaseContent(name, s.Version) diff --git a/pkg/action/uninstall.go b/pkg/action/uninstall.go index 08adc6804..37df65921 100644 --- a/pkg/action/uninstall.go +++ b/pkg/action/uninstall.go @@ -23,7 +23,6 @@ import ( "time" "github.com/pkg/errors" - "github.com/spf13/pflag" "k8s.io/helm/pkg/hooks" "k8s.io/helm/pkg/kube" @@ -50,13 +49,6 @@ func NewUninstall(cfg *Configuration) *Uninstall { } } -func (u *Uninstall) AddFlags(f *pflag.FlagSet) { - f.BoolVar(&u.DryRun, "dry-run", false, "simulate a uninstall") - f.BoolVar(&u.DisableHooks, "no-hooks", false, "prevent hooks from running during uninstallation") - f.BoolVar(&u.Purge, "purge", false, "remove the release from the store and make its name free for later use") - f.Int64Var(&u.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") -} - // Run uninstalls the given release. func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error) { if u.DryRun { diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 0931e70f6..8e8dce162 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -25,7 +25,6 @@ import ( "time" "github.com/pkg/errors" - "github.com/spf13/pflag" "k8s.io/client-go/discovery" "k8s.io/helm/pkg/chart" @@ -72,22 +71,6 @@ func NewUpgrade(cfg *Configuration) *Upgrade { } } -func (u *Upgrade) AddFlags(f *pflag.FlagSet) { - f.BoolVarP(&u.Install, "install", "i", false, "if a release by this name doesn't already exist, run an install") - f.BoolVar(&u.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.") - f.BoolVar(&u.DryRun, "dry-run", false, "simulate an upgrade") - f.BoolVar(&u.Recreate, "recreate-pods", false, "performs pods restart for the resource if applicable") - f.BoolVar(&u.Force, "force", false, "force resource update through delete/recreate if needed") - f.BoolVar(&u.DisableHooks, "no-hooks", false, "disable pre/post upgrade hooks") - f.Int64Var(&u.Timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") - f.BoolVar(&u.ResetValues, "reset-values", false, "when upgrading, reset the values to the ones built into the chart") - f.BoolVar(&u.ReuseValues, "reuse-values", false, "when upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' is specified, this is ignored.") - f.BoolVar(&u.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as --timeout") - f.IntVar(&u.MaxHistory, "history-max", 0, "limit the maximum number of revisions saved per release. Use 0 for no limit.") - u.ChartPathOptions.AddFlags(f) - u.ValueOptions.AddFlags(f) -} - // Run executes the upgrade on the given release. func (u *Upgrade) Run(name string, chart *chart.Chart) (*release.Release, error) { if err := chartutil.ProcessDependencies(chart, u.Values); err != nil { diff --git a/pkg/action/verify.go b/pkg/action/verify.go index 3e272b0d9..533ef8813 100644 --- a/pkg/action/verify.go +++ b/pkg/action/verify.go @@ -17,8 +17,6 @@ limitations under the License. package action import ( - "github.com/spf13/pflag" - "k8s.io/helm/pkg/downloader" ) @@ -34,10 +32,6 @@ func NewVerify() *Verify { return &Verify{} } -func (v *Verify) AddFlags(f *pflag.FlagSet) { - f.StringVar(&v.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") -} - // Run executes 'helm verify'. func (v *Verify) Run(chartfile string) error { _, err := downloader.VerifyChart(chartfile, v.Keyring)