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) l.printRequirements(r, l.out)
fmt.Fprintln(l.out) fmt.Fprintln(l.out)
l.printMissing(r, l.out) l.printMissing(r)
return nil 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. // 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/*") folder := filepath.Join(l.chartpath, "charts/*")
files, err := filepath.Glob(folder) files, err := filepath.Glob(folder)
if err != nil { if err != nil {

@ -229,7 +229,7 @@ func (i *installCmd) run() error {
// If checkDependencies returns an error, we have unfullfilled dependencies. // If checkDependencies returns an error, we have unfullfilled dependencies.
// As of Helm 2.4.0, this is treated as a stopping condition: // As of Helm 2.4.0, this is treated as a stopping condition:
// https://github.com/kubernetes/helm/issues/2209 // 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) return prettyError(err)
} }
} else if err != chartutil.ErrRequirementsNotFound { } else if err != chartutil.ErrRequirementsNotFound {
@ -434,7 +434,7 @@ func defaultNamespace() string {
return "default" 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{} missing := []string{}
deps := ch.GetDependencies() deps := ch.GetDependencies()

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

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

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

@ -67,7 +67,7 @@ func (pcmd *pluginRemoveCmd) run() error {
var errorPlugins []string var errorPlugins []string
for _, name := range pcmd.names { for _, name := range pcmd.names {
if found := findPlugin(plugins, name); found != nil { 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)) errorPlugins = append(errorPlugins, fmt.Sprintf("Failed to remove plugin %s, got error (%v)", name, err))
} else { } else {
fmt.Fprintf(pcmd.out, "Removed plugin: %s\n", name) fmt.Fprintf(pcmd.out, "Removed plugin: %s\n", name)
@ -82,11 +82,11 @@ func (pcmd *pluginRemoveCmd) run() error {
return nil 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 { if err := os.Remove(p.Dir); err != nil {
return err return err
} }
return runHook(p, plugin.Delete, home) return runHook(p, plugin.Delete)
} }
func findPlugin(plugins []*plugin.Plugin, name string) *plugin.Plugin { 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 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", Short: "start a local http web server",
Long: serveDesc, Long: serveDesc,
PreRunE: func(cmd *cobra.Command, args []string) error { PreRunE: func(cmd *cobra.Command, args []string) error {
return srv.complete(args) return srv.complete()
}, },
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return srv.run() return srv.run()
@ -71,7 +71,7 @@ func newServeCmd(out io.Writer) *cobra.Command {
return cmd return cmd
} }
func (s *serveCmd) complete(args []string) error { func (s *serveCmd) complete() error {
if s.repoPath == "" { if s.repoPath == "" {
s.repoPath = settings.Home.LocalRepository() s.repoPath = settings.Home.LocalRepository()
} }

@ -78,7 +78,7 @@ func TestStatusCmd(t *testing.T) {
args: []string{"flummoxed-chickadee"}, args: []string{"flummoxed-chickadee"},
expected: outputWithStatus( expected: outputWithStatus(
fmt.Sprintf("DEPLOYED\n\nTEST SUITE:\nLast Started: %s\nLast Completed: %s\n\n", dateString, dateString) + 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 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)), fmt.Sprintf("test run 2\tFAILURE \t \t%s\t%s\n", dateString, dateString)),
rel: releaseMockWithStatus(&release.Status{ 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 // Check chart requirements to make sure all dependencies are present in /charts
if ch, err := chartutil.Load(chartPath); err == nil { if ch, err := chartutil.Load(chartPath); err == nil {
if req, err := chartutil.LoadRequirements(ch); 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 return err
} }
} else if err != chartutil.ErrRequirementsNotFound { } else if err != chartutil.ErrRequirementsNotFound {

Loading…
Cancel
Save