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 <justyntemme@gmail.com>
This commit is contained in:
Justyn Temme 2018-07-16 13:41:22 -05:00
parent 9e71207327
commit bdd58a4096
2 changed files with 7 additions and 2 deletions

View File

@ -81,7 +81,7 @@ func RunDeploy(dockerCli command.Cli, flags *pflag.FlagSet, config *composetypes
case commonOrchestrator.HasKubernetes(): case commonOrchestrator.HasKubernetes():
kli, err := kubernetes.WrapCli(dockerCli, kubernetes.NewOptions(flags, commonOrchestrator)) kli, err := kubernetes.WrapCli(dockerCli, kubernetes.NewOptions(flags, commonOrchestrator))
if err != nil { if err != nil {
return err return errors.Wrap(err, "unable to deploy to Kubernetes")
} }
return kubernetes.RunDeploy(kli, opts, config) return kubernetes.RunDeploy(kli, opts, config)
default: default:

View File

@ -4,10 +4,12 @@ import (
"fmt" "fmt"
"net" "net"
"net/url" "net/url"
"os"
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
"github.com/docker/cli/kubernetes" "github.com/docker/cli/kubernetes"
cliv1beta1 "github.com/docker/cli/kubernetes/client/clientset/typed/compose/v1beta1" cliv1beta1 "github.com/docker/cli/kubernetes/client/clientset/typed/compose/v1beta1"
"github.com/pkg/errors"
flag "github.com/spf13/pflag" flag "github.com/spf13/pflag"
kubeclient "k8s.io/client-go/kubernetes" kubeclient "k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest" restclient "k8s.io/client-go/rest"
@ -58,7 +60,10 @@ func WrapCli(dockerCli command.Cli, opts Options) (*KubeCli, error) {
cli.kubeNamespace = opts.Namespace cli.kubeNamespace = opts.Namespace
if opts.Namespace == "" { if opts.Namespace == "" {
configNamespace, _, err := clientConfig.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 return nil, err
} }
cli.kubeNamespace = configNamespace cli.kubeNamespace = configNamespace