removed panic, and replaced with error

Signed-off-by: EItanya <eitan.yarmush@solo.io>
pull/7356/head
EItanya 5 years ago
parent 2f534f9742
commit 640d527190

@ -65,7 +65,10 @@ func main() {
initKubeLogs()
actionConfig := new(action.Configuration)
cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:])
cmd, err := newRootCmd(actionConfig, os.Stdout, os.Args[1:])
if err != nil {
log.Fatal(err)
}
if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), os.Getenv("HELM_DRIVER"), debug); err != nil {
log.Fatal(err)

@ -107,7 +107,11 @@ func executeActionCommandC(store *storage.Storage, cmd string) (*cobra.Command,
Log: func(format string, v ...interface{}) {},
}
root := newRootCmd(actionConfig, buf, args)
root, err := newRootCmd(actionConfig, buf, args)
if err != nil {
return nil, "", err
}
root.SetOutput(buf)
root.SetArgs(args)

@ -345,7 +345,7 @@ By default, the default directories depend on the Operating System. The defaults
+------------------+---------------------------+--------------------------------+-------------------------+
`
func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) *cobra.Command {
func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) (*cobra.Command, error) {
cmd := &cobra.Command{
Use: "helm",
Short: "The Helm package manager for Kubernetes.",
@ -419,8 +419,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
registry.ClientOptCredentialsFile(settings.RegistryConfig),
)
if err != nil {
// TODO: don't panic here, refactor newRootCmd to return error
panic(err)
return nil, err
}
actionConfig.RegistryClient = registryClient
cmd.AddCommand(
@ -431,5 +430,5 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
// Find and add plugins
loadPlugins(cmd, out)
return cmd
return cmd, nil
}

Loading…
Cancel
Save