mirror of https://github.com/docker/cli.git
Fix stack ls behaviour with Kubernetes and variout --namespace flag values
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
This commit is contained in:
parent
f097831eb3
commit
2af66bed41
|
@ -27,7 +27,7 @@ func NewStackCommand(dockerCli command.Cli) *cobra.Command {
|
|||
newServicesCommand(dockerCli),
|
||||
)
|
||||
flags := cmd.PersistentFlags()
|
||||
flags.String("namespace", "default", "Kubernetes namespace to use")
|
||||
flags.String("namespace", "", "Kubernetes namespace to use")
|
||||
flags.SetAnnotation("namespace", "kubernetes", nil)
|
||||
flags.SetAnnotation("namespace", "experimentalCLI", nil)
|
||||
flags.String("kubeconfig", "", "Kubernetes config file")
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package kubernetes
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/kubernetes"
|
||||
"github.com/docker/docker/pkg/homedir"
|
||||
flag "github.com/spf13/pflag"
|
||||
kubeclient "k8s.io/client-go/kubernetes"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
|
@ -44,19 +40,10 @@ func WrapCli(dockerCli command.Cli, opts Options) (*KubeCli, error) {
|
|||
cli := &KubeCli{
|
||||
Cli: dockerCli,
|
||||
}
|
||||
kubeConfig := opts.Config
|
||||
if kubeConfig == "" {
|
||||
if config := os.Getenv("KUBECONFIG"); config != "" {
|
||||
kubeConfig = config
|
||||
} else {
|
||||
kubeConfig = filepath.Join(homedir.Get(), ".kube/config")
|
||||
}
|
||||
}
|
||||
|
||||
clientConfig := kubernetes.NewKubernetesConfig(kubeConfig)
|
||||
clientConfig := kubernetes.NewKubernetesConfig(opts.Config)
|
||||
|
||||
cli.kubeNamespace = opts.Namespace
|
||||
if opts.Namespace == "default" {
|
||||
if opts.Namespace == "" {
|
||||
configNamespace, _, err := clientConfig.Namespace()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue