Merge pull request #2563 from adamreese/ref/code-cleanup

ref(helm): mix bag of syntax cleanup in cmd/helm
pull/1932/head
Adam Reese 8 years ago committed by GitHub
commit 401f8bcc18

@ -150,7 +150,7 @@ func (l *dependencyListCmd) run() error {
l.printRequirements(r, l.out)
fmt.Fprintln(l.out)
l.printMissing(r, l.out)
l.printMissing(r)
return nil
}
@ -240,7 +240,7 @@ func (l *dependencyListCmd) printRequirements(reqs *chartutil.Requirements, out
}
// printMissing prints warnings about charts that are present on disk, but are not in the requirements.
func (l *dependencyListCmd) printMissing(reqs *chartutil.Requirements, out io.Writer) {
func (l *dependencyListCmd) printMissing(reqs *chartutil.Requirements) {
folder := filepath.Join(l.chartpath, "charts/*")
files, err := filepath.Glob(folder)
if err != nil {

@ -229,7 +229,7 @@ func (i *installCmd) run() error {
// If checkDependencies returns an error, we have unfullfilled dependencies.
// As of Helm 2.4.0, this is treated as a stopping condition:
// https://github.com/kubernetes/helm/issues/2209
if err := checkDependencies(chartRequested, req, i.out); err != nil {
if err := checkDependencies(chartRequested, req); err != nil {
return prettyError(err)
}
} else if err != chartutil.ErrRequirementsNotFound {
@ -434,7 +434,7 @@ func defaultNamespace() string {
return "default"
}
func checkDependencies(ch *chart.Chart, reqs *chartutil.Requirements, out io.Writer) error {
func checkDependencies(ch *chart.Chart, reqs *chartutil.Requirements) error {
missing := []string{}
deps := ch.GetDependencies()

@ -87,7 +87,7 @@ func newPackageCmd(out io.Writer) *cobra.Command {
}
for i := 0; i < len(args); i++ {
pkg.path = args[i]
if err := pkg.run(cmd, args); err != nil {
if err := pkg.run(); err != nil {
return err
}
}
@ -107,7 +107,7 @@ func newPackageCmd(out io.Writer) *cobra.Command {
return cmd
}
func (p *packageCmd) run(cmd *cobra.Command, args []string) error {
func (p *packageCmd) run() error {
path, err := filepath.Abs(p.path)
if err != nil {
return err
@ -146,7 +146,7 @@ func (p *packageCmd) run(cmd *cobra.Command, args []string) error {
}
if reqs, err := chartutil.LoadRequirements(ch); err == nil {
if err := checkDependencies(ch, reqs, p.out); err != nil {
if err := checkDependencies(ch, reqs); err != nil {
return err
}
} else {

@ -21,7 +21,6 @@ import (
"os"
"os/exec"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/plugin"
"github.com/spf13/cobra"
@ -47,7 +46,7 @@ func newPluginCmd(out io.Writer) *cobra.Command {
}
// runHook will execute a plugin hook.
func runHook(p *plugin.Plugin, event string, home helmpath.Home) error {
func runHook(p *plugin.Plugin, event string) error {
hook := p.Metadata.Hooks.Get(event)
if hook == "" {
return nil

@ -75,7 +75,7 @@ func (pcmd *pluginInstallCmd) run() error {
return err
}
if err := runHook(p, plugin.Install, pcmd.home); err != nil {
if err := runHook(p, plugin.Install); err != nil {
return err
}

@ -67,7 +67,7 @@ func (pcmd *pluginRemoveCmd) run() error {
var errorPlugins []string
for _, name := range pcmd.names {
if found := findPlugin(plugins, name); found != nil {
if err := removePlugin(found, pcmd.home); err != nil {
if err := removePlugin(found); err != nil {
errorPlugins = append(errorPlugins, fmt.Sprintf("Failed to remove plugin %s, got error (%v)", name, err))
} else {
fmt.Fprintf(pcmd.out, "Removed plugin: %s\n", name)
@ -82,11 +82,11 @@ func (pcmd *pluginRemoveCmd) run() error {
return nil
}
func removePlugin(p *plugin.Plugin, home helmpath.Home) error {
func removePlugin(p *plugin.Plugin) error {
if err := os.Remove(p.Dir); err != nil {
return err
}
return runHook(p, plugin.Delete, home)
return runHook(p, plugin.Delete)
}
func findPlugin(plugins []*plugin.Plugin, name string) *plugin.Plugin {

@ -109,5 +109,5 @@ func updatePlugin(p *plugin.Plugin, home helmpath.Home) error {
return err
}
return runHook(updatedPlugin, plugin.Update, home)
return runHook(updatedPlugin, plugin.Update)
}

@ -56,7 +56,7 @@ func newServeCmd(out io.Writer) *cobra.Command {
Short: "start a local http web server",
Long: serveDesc,
PreRunE: func(cmd *cobra.Command, args []string) error {
return srv.complete(args)
return srv.complete()
},
RunE: func(cmd *cobra.Command, args []string) error {
return srv.run()
@ -71,7 +71,7 @@ func newServeCmd(out io.Writer) *cobra.Command {
return cmd
}
func (s *serveCmd) complete(args []string) error {
func (s *serveCmd) complete() error {
if s.repoPath == "" {
s.repoPath = settings.Home.LocalRepository()
}

@ -78,7 +78,7 @@ func TestStatusCmd(t *testing.T) {
args: []string{"flummoxed-chickadee"},
expected: outputWithStatus(
fmt.Sprintf("DEPLOYED\n\nTEST SUITE:\nLast Started: %s\nLast Completed: %s\n\n", dateString, dateString) +
fmt.Sprint("TEST \tSTATUS \tINFO \tSTARTED \tCOMPLETED \n") +
"TEST \tSTATUS \tINFO \tSTARTED \tCOMPLETED \n" +
fmt.Sprintf("test run 1\tSUCCESS \textra info\t%s\t%s\n", dateString, dateString) +
fmt.Sprintf("test run 2\tFAILURE \t \t%s\t%s\n", dateString, dateString)),
rel: releaseMockWithStatus(&release.Status{

@ -184,7 +184,7 @@ func (u *upgradeCmd) run() error {
// Check chart requirements to make sure all dependencies are present in /charts
if ch, err := chartutil.Load(chartPath); err == nil {
if req, err := chartutil.LoadRequirements(ch); err == nil {
if err := checkDependencies(ch, req, u.out); err != nil {
if err := checkDependencies(ch, req); err != nil {
return err
}
} else if err != chartutil.ErrRequirementsNotFound {

Loading…
Cancel
Save