Merge pull request #1216 from justyntemme/patch-4

Update deploy.go
This commit is contained in:
Sebastiaan van Stijn 2018-07-17 16:20:46 +02:00 committed by GitHub
commit 48fbb12b7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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