Return error exit code when there is error

pull/2410/head
Sushil Kumar 9 years ago
parent b57e69b3a7
commit 066ddbdf8d

@ -19,13 +19,13 @@ import (
"errors"
"fmt"
"io"
"path/filepath"
"strings"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/plugin"
"k8s.io/helm/pkg/plugin/installer"
"path/filepath"
"github.com/spf13/cobra"
)
@ -67,16 +67,21 @@ func (pcmd *pluginUpdateCmd) run() error {
if err != nil {
return err
}
var errorPlugins []string
for _, name := range pcmd.names {
if found := findPlugin(plugins, name); found != nil {
if err := updatePlugin(found, pcmd.home); err != nil {
fmt.Fprintf(pcmd.out, "Failed to update plugin %s, got error (%v)\n", name, err)
errorPlugins = append(errorPlugins, fmt.Sprintf("Failed to update plugin %s, got error (%v)", name, err))
} else {
fmt.Fprintf(pcmd.out, "Updated plugin: %s\n", name)
}
} else {
fmt.Fprintf(pcmd.out, "Plugin: %s not found\n", name)
errorPlugins = append(errorPlugins, fmt.Sprintf("Plugin: %s not found", name))
}
}
if len(errorPlugins) > 0 {
return fmt.Errorf(strings.Join(errorPlugins, "\n"))
}
return nil
}

@ -104,13 +104,6 @@ func TestVCSInstaller(t *testing.T) {
} else if err.Error() != "cannot get information about plugin source" {
t.Errorf("expected error for inability to find plugin source, got (%v)", err)
}
// Testing update for error
if err := Update(i); err == nil {
t.Error("expected error for plugin does not exist, got none")
} else if err.Error() != "plugin does not exist" {
t.Errorf("expected error for plugin does not exist, got (%v)", err)
}
}
func TestVCSInstallerNonExistentVersion(t *testing.T) {

Loading…
Cancel
Save