From 1bcdc65fcf464d595bfe1a3122cf1c3097d67259 Mon Sep 17 00:00:00 2001 From: derailed Date: Mon, 18 Feb 2019 18:32:23 -0700 Subject: [PATCH] cleaning up logs --- internal/cmd/root.go | 3 ++- internal/config/config.go | 2 -- internal/k8s/api.go | 45 ------------------------------------ internal/resource/context.go | 2 +- 4 files changed, 3 insertions(+), 49 deletions(-) diff --git a/internal/cmd/root.go b/internal/cmd/root.go index 293df3ce..e6fed6a3 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -129,10 +129,11 @@ func initK8sFlags() { "Bearer token for authentication to the API server", ) - rootCmd.Flags().StringVar( + rootCmd.Flags().StringVarP( k8sFlags.Namespace, "namespace", "n", + "", "If present, the namespace scope for this CLI request", ) } diff --git a/internal/config/config.go b/internal/config/config.go index 6b396b2f..19e5631d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -112,8 +112,6 @@ func (c *Config) Load(path string) error { // Save configuration to disk. func (c *Config) Save() error { log.Debugf("[Config] Saving configuration...") - c.Dump("Saving") - c.Validate() return c.SaveFile(K9sConfigFile) } diff --git a/internal/k8s/api.go b/internal/k8s/api.go index 6412250c..c660c808 100644 --- a/internal/k8s/api.go +++ b/internal/k8s/api.go @@ -74,27 +74,8 @@ func (a *apiServer) hasMetricsServer() bool { return a.useMetricServer } -// ActiveClusterOrDie Fetch the current cluster based on current context. -func ActiveClusterOrDie() string { - cl, err := conn.config.CurrentClusterName() - if err != nil { - panic(err) - } - return cl -} - -// AllClusterNamesOrDie fetch all available clusters from config. -func AllClusterNamesOrDie() []string { - if cc, err := conn.config.ClusterNames(); err != nil { - panic(err) - } else { - return cc - } -} - // DialOrDie returns a handle to api server or die. func (a *apiServer) dialOrDie() kubernetes.Interface { - a.checkCurrentConfig() if a.client != nil { return a.client } @@ -108,7 +89,6 @@ func (a *apiServer) dialOrDie() kubernetes.Interface { // DynDial returns a handle to the api server. func (a *apiServer) dynDialOrDie() dynamic.Interface { - a.checkCurrentConfig() if a.dClient != nil { return a.dClient } @@ -122,7 +102,6 @@ func (a *apiServer) dynDialOrDie() dynamic.Interface { } func (a *apiServer) nsDialOrDie() dynamic.NamespaceableResourceInterface { - a.checkCurrentConfig() if a.nsClient != nil { return a.nsClient } @@ -136,7 +115,6 @@ func (a *apiServer) nsDialOrDie() dynamic.NamespaceableResourceInterface { } func (a *apiServer) heapsterDial() (*metricsutil.HeapsterMetricsClient, error) { - a.checkCurrentConfig() if a.heapsterClient != nil { return a.heapsterClient, nil } @@ -152,7 +130,6 @@ func (a *apiServer) heapsterDial() (*metricsutil.HeapsterMetricsClient, error) { } func (a *apiServer) mxsDial() (*versioned.Clientset, error) { - a.checkCurrentConfig() if a.mxsClient != nil { return a.mxsClient, nil } @@ -162,14 +139,6 @@ func (a *apiServer) mxsDial() (*versioned.Clientset, error) { return a.mxsClient, err } -func (a *apiServer) configAccess() clientcmd.ConfigAccess { - cfg, err := a.config.ConfigAccess() - if err != nil { - panic(err) - } - return cfg -} - func (a *apiServer) restConfigOrDie() *restclient.Config { cfg, err := a.config.RESTConfig() if err != nil { @@ -193,20 +162,6 @@ func (a *apiServer) switchContextOrDie(ctx string) { } } -func (a *apiServer) checkCurrentConfig() { - // currentCluster, err := a.config.CurrentCluster() - // if err != nil { - // panic(err) - // } - - // if a.clusterName != currentCluster { - // a.reset() - // a.clusterName = currentCluster - // a.useMetricServer = a.supportsMxServer() - // return - // } -} - func (a *apiServer) reset() { a.client, a.dClient, a.nsClient = nil, nil, nil a.heapsterClient, a.mxsClient = nil, nil diff --git a/internal/resource/context.go b/internal/resource/context.go index 35cfd52f..b9998639 100644 --- a/internal/resource/context.go +++ b/internal/resource/context.go @@ -23,7 +23,7 @@ func NewContextList(ns string) List { // NewContextListWithArgs returns a new resource list. func NewContextListWithArgs(ns string, res Resource) List { - return newList(NotNamespaced, "ctx", res, SwitchAccess|DeleteAccess) + return newList(NotNamespaced, "ctx", res, SwitchAccess) } // NewContext instantiates a new Context.