Commit bc93de31 authored by deads2k's avatar deads2k

remove --ns-path option from .kubeconfig file, kick tests

parent 793677e8
......@@ -72,9 +72,7 @@ __kubectl_pre_command()
--client-key=
--insecure-skip-tls-verify=
--match-server-version=
-n
--namespace=
--ns-path=
-s
--server=
)
......@@ -85,7 +83,7 @@ __kubectl_pre_command()
COMPREPLY=( $(compgen -W "${api_versions[*]}" -- "$cur") )
return 0
;;
-a | --auth-path | --certificate-authority | --client-certificate | --client-key | --ns-path)
-a | --auth-path | --certificate-authority | --client-certificate | --client-key)
_filedir
return 0
;;
......
......@@ -83,8 +83,6 @@ type Context struct {
AuthInfo string `json:"user"`
// Namespace is the default namespace to use on unspecified requests
Namespace string `json:"namespace,omitempty"`
// NamespacePath is the path to a kubernetes ns file (~/.kubernetes_ns)
NamespacePath string `json:"namespace-path,omitempty"`
// Extensions holds additional information. This is useful for extenders so that reads and writes don't clobber unknown fields
Extensions map[string]runtime.EmbeddedObject `json:"extensions,omitempty"`
}
......
......@@ -83,8 +83,6 @@ type Context struct {
AuthInfo string `json:"user"`
// Namespace is the default namespace to use on unspecified requests
Namespace string `json:"namespace,omitempty"`
// NamespacePath is the path to a kubernetes ns file (~/.kubernetes_ns)
NamespacePath string `json:"namespace-path,omitempty"`
// Extensions holds additional information. This is useful for extenders so that reads and writes don't clobber unknown fields
Extensions []NamedExtension `json:"extensions,omitempty"`
}
......
......@@ -22,10 +22,10 @@ import (
"github.com/imdario/mergo"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
clientcmdapi "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/clientauth"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/errors"
)
......@@ -241,25 +241,10 @@ func (config DirectClientConfig) Namespace() (string, error) {
configContext := config.getContext()
if len(configContext.Namespace) != 0 {
return configContext.Namespace, nil
if len(configContext.Namespace) == 0 {
return api.NamespaceDefault, nil
}
if len(configContext.NamespacePath) != 0 {
nsInfo, err := kubectl.LoadNamespaceInfo(configContext.NamespacePath)
if err != nil {
return "", err
}
return nsInfo.Namespace, nil
}
// if nothing was specified, try the default file
nsInfo, err := kubectl.LoadNamespaceInfo(os.Getenv("HOME") + "/.kubernetes_ns")
if err != nil {
return "", err
}
return nsInfo.Namespace, nil
return configContext.Namespace, nil
}
// ConfirmUsable looks a particular context and determines if that particular part of the config is useable. There might still be errors in the config,
......
......@@ -56,7 +56,6 @@ type ContextOverrideFlags struct {
Namespace string
// allow the potential for shorter namespace flags for commands that tend to work across namespaces
NamespaceShort string
NamespacePath string
}
// ClusterOverride holds the flag names to be used for binding command line flags for Cluster objects
......@@ -69,19 +68,18 @@ type ClusterOverrideFlags struct {
}
const (
FlagClusterName = "cluster"
FlagAuthInfoName = "user"
FlagContext = "context"
FlagNamespace = "namespace"
FlagNamespacePath = "ns-path"
FlagAPIServer = "server"
FlagAPIVersion = "api-version"
FlagAuthPath = "auth-path"
FlagInsecure = "insecure-skip-tls-verify"
FlagCertFile = "client-certificate"
FlagKeyFile = "client-key"
FlagCAFile = "certificate-authority"
FlagBearerToken = "token"
FlagClusterName = "cluster"
FlagAuthInfoName = "user"
FlagContext = "context"
FlagNamespace = "namespace"
FlagAPIServer = "server"
FlagAPIVersion = "api-version"
FlagAuthPath = "auth-path"
FlagInsecure = "insecure-skip-tls-verify"
FlagCertFile = "client-certificate"
FlagKeyFile = "client-key"
FlagCAFile = "certificate-authority"
FlagBearerToken = "token"
)
// RecommendedAuthOverrideFlags is a convenience method to return recommended flag names prefixed with a string of your choosing
......@@ -117,10 +115,9 @@ func RecommendedConfigOverrideFlags(prefix string) ConfigOverrideFlags {
// RecommendedContextOverrideFlags is a convenience method to return recommended flag names prefixed with a string of your choosing
func RecommendedContextOverrideFlags(prefix string) ContextOverrideFlags {
return ContextOverrideFlags{
ClusterName: prefix + FlagClusterName,
AuthInfoName: prefix + FlagAuthInfoName,
Namespace: prefix + FlagNamespace,
NamespacePath: prefix + FlagNamespacePath,
ClusterName: prefix + FlagClusterName,
AuthInfoName: prefix + FlagAuthInfoName,
Namespace: prefix + FlagNamespace,
}
}
......@@ -153,5 +150,4 @@ func BindContextFlags(contextInfo *clientcmdapi.Context, flags *pflag.FlagSet, f
flags.StringVar(&contextInfo.Cluster, flagNames.ClusterName, "", "The name of the kubeconfig cluster to use")
flags.StringVar(&contextInfo.AuthInfo, flagNames.AuthInfoName, "", "The name of the kubeconfig user to use")
flags.StringVarP(&contextInfo.Namespace, flagNames.Namespace, flagNames.NamespaceShort, "", "If present, the namespace scope for this CLI request.")
flags.StringVar(&contextInfo.NamespacePath, flagNames.NamespacePath, "", "Path to the namespace info file that holds the namespace context to use for CLI requests.")
}
......@@ -18,43 +18,24 @@ package cmd
import (
"io"
"os"
"fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
"github.com/golang/glog"
"github.com/spf13/cobra"
)
// TODO remove once people have been given enough time to notice
func NewCmdNamespace(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "namespace [<namespace>]",
Short: "Set and view the current Kubernetes namespace",
Long: `Set and view the current Kubernetes namespace scope for command line requests.
A Kubernetes namespace subdivides the cluster into groups of logically related pods, services, and replication controllers.
Examples:
$ kubectl namespace
Using namespace default
Short: "SUPERCEDED: Set and view the current Kubernetes namespace",
Long: `SUPERCEDED: Set and view the current Kubernetes namespace scope for command line requests.
$ kubectl namespace other
Set current namespace to other`,
namespace has been superceded by the context.namespace field of .kubeconfig files. See 'kubectl config set-context --help' for more details.
`,
Run: func(cmd *cobra.Command, args []string) {
nsPath := GetFlagString(cmd, "ns-path")
var err error
var ns *kubectl.NamespaceInfo
switch len(args) {
case 0:
ns, err = kubectl.LoadNamespaceInfo(nsPath)
fmt.Printf("Using namespace %s\n", ns.Namespace)
case 1:
ns = &kubectl.NamespaceInfo{Namespace: args[0]}
err = kubectl.SaveNamespaceInfo(nsPath, ns)
fmt.Printf("Set current namespace to %s\n", ns.Namespace)
default:
usageError(cmd, "kubectl namespace [<namespace>]")
}
checkErr(err)
glog.Errorln("namespace has been superceded by the context.namespace field of .kubeconfig files. See 'kubectl config set-context --help' for more details.")
os.Exit(1)
},
}
return cmd
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment