From bdd58a409624b8f7fb33613ce67e47a9db850b43 Mon Sep 17 00:00:00 2001 From: Justyn Temme Date: Mon, 16 Jul 2018 13:41:22 -0500 Subject: [PATCH] Update deploy.go Clarified ambiguous error message Update kubernetes/cli.go Infromed user of why the error was caused when file is not there Signed-off-by: Justyn Temme --- cli/command/stack/deploy.go | 2 +- cli/command/stack/kubernetes/cli.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cli/command/stack/deploy.go b/cli/command/stack/deploy.go index 0165bbda1a..d2d16b4140 100644 --- a/cli/command/stack/deploy.go +++ b/cli/command/stack/deploy.go @@ -81,7 +81,7 @@ func RunDeploy(dockerCli command.Cli, flags *pflag.FlagSet, config *composetypes case commonOrchestrator.HasKubernetes(): kli, err := kubernetes.WrapCli(dockerCli, kubernetes.NewOptions(flags, commonOrchestrator)) if err != nil { - return err + return errors.Wrap(err, "unable to deploy to Kubernetes") } return kubernetes.RunDeploy(kli, opts, config) default: diff --git a/cli/command/stack/kubernetes/cli.go b/cli/command/stack/kubernetes/cli.go index bcd0b01e59..f1a54f16a6 100644 --- a/cli/command/stack/kubernetes/cli.go +++ b/cli/command/stack/kubernetes/cli.go @@ -4,10 +4,12 @@ import ( "fmt" "net" "net/url" + "os" "github.com/docker/cli/cli/command" "github.com/docker/cli/kubernetes" cliv1beta1 "github.com/docker/cli/kubernetes/client/clientset/typed/compose/v1beta1" + "github.com/pkg/errors" flag "github.com/spf13/pflag" kubeclient "k8s.io/client-go/kubernetes" restclient "k8s.io/client-go/rest" @@ -58,7 +60,10 @@ func WrapCli(dockerCli command.Cli, opts Options) (*KubeCli, error) { cli.kubeNamespace = opts.Namespace if opts.Namespace == "" { configNamespace, _, err := clientConfig.Namespace() - if err != nil { + switch { + case os.IsNotExist(err), os.IsPermission(err): + return nil, errors.Wrap(err, "unable to load configuration file") + case err != nil: return nil, err } cli.kubeNamespace = configNamespace