From ae6d33976507b04866295177a1d69a5e0f367658 Mon Sep 17 00:00:00 2001 From: derailed Date: Fri, 1 Feb 2019 14:33:00 -0700 Subject: [PATCH] cleanup + tests check --- .goreleaser.yml | 12 ++--- .travis.yml | 2 +- CNAME | 2 +- cmd/root.go | 20 +++----- go.mod | 9 +++- go.sum | 27 +++++++++++ main.go | 2 +- resource/base.go | 2 +- resource/cluster.go | 2 +- resource/cluster_test.go | 4 +- resource/cm.go | 2 +- resource/cm_test.go | 4 +- resource/context.go | 2 +- resource/context_test.go | 4 +- resource/cr.go | 2 +- resource/cr_binding.go | 2 +- resource/cr_binding_test.go | 4 +- resource/cr_test.go | 4 +- resource/crd.go | 2 +- resource/crd_test.go | 4 +- resource/cronjob.go | 2 +- resource/cronjob_test.go | 4 +- resource/custom.go | 2 +- resource/dp.go | 2 +- resource/dp_test.go | 4 +- resource/ds.go | 2 +- resource/ds_test.go | 4 +- resource/ep.go | 2 +- resource/ep_test.go | 4 +- resource/evt.go | 2 +- resource/evt_test.go | 4 +- resource/hpa.go | 2 +- resource/hpa_test.go | 4 +- resource/ing.go | 2 +- resource/ing_test.go | 4 +- resource/job.go | 2 +- resource/job_test.go | 4 +- resource/list.go | 5 +- resource/mock_caller_test.go | 4 +- resource/mock_clusterifc_test.go | 2 +- resource/mock_metricsifc_test.go | 4 +- resource/mock_resource_test.go | 4 +- resource/mock_switchableres_test.go | 4 +- resource/no.go | 2 +- resource/no_test.go | 4 +- resource/ns.go | 2 +- resource/ns_test.go | 4 +- resource/pod.go | 2 +- resource/pod_test.go | 4 +- resource/pv.go | 2 +- resource/pv_test.go | 4 +- resource/pvc.go | 2 +- resource/pvc_test.go | 4 +- resource/ro.go | 2 +- resource/ro_binding.go | 2 +- resource/ro_binding_test.go | 4 +- resource/ro_test.go | 4 +- resource/rs.go | 2 +- resource/rs_test.go | 4 +- resource/sa.go | 2 +- resource/sa_test.go | 4 +- resource/secret.go | 2 +- resource/secret_test.go | 4 +- resource/sts.go | 2 +- resource/sts_test.go | 4 +- resource/svc.go | 2 +- resource/svc_test.go | 4 +- vendor/modules.txt | 30 ++++++------ views/app.go | 75 ++++++++++++++++------------- views/buttons.go | 27 ----------- views/colorer.go | 2 +- views/colorer_test.go | 4 +- views/command.go | 2 +- views/context.go | 2 +- views/details.go | 2 +- views/flash.go | 57 +++++++++++++--------- views/flash_test.go | 41 ++++++++++++++++ views/help.go | 23 ++++----- views/helpers.go | 3 ++ views/helpers_test.go | 3 +- views/info.go | 4 +- views/log.go | 25 +++++----- views/logs.go | 10 ++-- views/menu.go | 4 +- views/pod.go | 18 +++---- views/registrar.go | 66 ++++++++++++------------- views/resource.go | 10 ++-- views/splash.go | 52 ++++++++++---------- views/table.go | 25 +++++----- views/xray.go | 2 +- views/yaml.go | 2 +- 91 files changed, 409 insertions(+), 337 deletions(-) delete mode 100644 views/buttons.go create mode 100644 views/flash_test.go diff --git a/.goreleaser.yml b/.goreleaser.yml index 666bbf1b..441ce21b 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -20,7 +20,7 @@ builds: - 386 - amd64 ldflags: - - -s -w -X github.com/k8sland/k9s/cmd.version={{.Version}} -X github.com/k8sland/k9s/cmd.commit={{.Commit}} -X github.com/k8sland/k9s/cmd.date={{.Date}} + - -s -w -X github.com/derailed/k9s/cmd.version={{.Version}} -X github.com/derailed/k9s/cmd.commit={{.Commit}} -X github.com/derailed/k9s/cmd.date={{.Date}} archive: replacements: @@ -44,13 +44,13 @@ changelog: brew: name: k9s github: - owner: k8sland + owner: derailed name: k9s-homebrew-tap commit_author: - name: k8sland - email: fernand@k8sland.io + name: derailed + email: fernand@imhotep.io folder: Formula - homepage: https://k9ss.io - description: A CLI to interact with your Kubernetes clusters + homepage: https://k9s.io + description: A graphical terminal CLI to interact with your Kubernetes clusters! test: | system "k9s version" \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 5a8dd048..dac76c00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: go -go_import_path: github.com/k8sland/k9s +go_import_path: github.com/derailed/k9s go: - 1.11.2 # - master diff --git a/CNAME b/CNAME index c41db67e..5fd012c4 100644 --- a/CNAME +++ b/CNAME @@ -1 +1 @@ -k9ss.io \ No newline at end of file +k9s.io \ No newline at end of file diff --git a/cmd/root.go b/cmd/root.go index f5c07dd5..1705fc8d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -5,35 +5,31 @@ import ( "github.com/gdamore/tcell" - "github.com/k8sland/k9s/views" + "github.com/derailed/k9s/views" "github.com/k8sland/tview" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "k8s.io/client-go/kubernetes" ) -const ( - defaultRefreshRate = 5 // secs -) +const defaultRefreshRate = 5 // secs var ( version = "dev" commit = "dev" date = "n/a" - srv kubernetes.Interface refreshRate int namespace string rootCmd = &cobra.Command{ Use: "k9s", - Short: "K9s a Kubernetes cluster management CLI", - Long: `K9s is a Kubernetes CLI to view and manage your Kubernetes clusters.`, + Short: "A graphical CLI for your Kubernetes cluster management.", + Long: `k9s is a Kubernetes CLI to view and manage your Kubernetes clusters.`, Run: run, } versionCmd = &cobra.Command{ Use: "version", - Short: "Print K9s version", - Long: "Prints K9s version", + Short: "Print k9s version", + Long: "Prints k9s version", Run: func(cmd *cobra.Command, args []string) { fmt.Printf("Version:%s GitCommit:%s On %s\n", version, commit, date) }, @@ -56,7 +52,6 @@ func init() { "", "Uses a given namespace versus all-namespaces", ) - } // Execute root command @@ -70,9 +65,6 @@ func run(cmd *cobra.Command, args []string) { initStyles() initKeys() - if refreshRate < 0 { - refreshRate = defaultRefreshRate - } app := views.NewApp(version, refreshRate, namespace) app.Init() app.Run() diff --git a/go.mod b/go.mod index 3a15697d..28e227bf 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,14 @@ -module github.com/k8sland/k9s +module github.com/derailed/k9s // replace github.com/k8sland/tview => /Users/fernand/k8sland/src/github.com/k8sland/tview require ( cloud.google.com/go v0.34.0 // indirect + github.com/emicklei/go-restful v2.8.1+incompatible // indirect + github.com/evanphx/json-patch v4.1.0+incompatible // indirect github.com/gdamore/tcell v1.1.0 github.com/ghodss/yaml v1.0.0 // indirect + github.com/go-openapi/spec v0.18.0 // indirect github.com/gogo/protobuf v1.1.1 // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect @@ -23,6 +26,7 @@ require ( github.com/onsi/gomega v1.4.3 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/petergtz/pegomock v0.0.0-20181206220228-b113d17a7e81 + github.com/pkg/errors v0.8.1 // indirect github.com/sirupsen/logrus v1.2.0 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect @@ -43,6 +47,9 @@ require ( k8s.io/apiextensions-apiserver v0.0.0-20181206111255-bb0a52a3f19d // indirect k8s.io/apimachinery v0.0.0-20181108045954-261df694e725 k8s.io/client-go v9.0.0+incompatible + k8s.io/kube-openapi v0.0.0-20190131215449-d8b685cd2daa // indirect k8s.io/kubernetes v1.13.0 k8s.io/metrics v0.0.0-20181121073115-d8618695b08f + sigs.k8s.io/kind v0.0.0-20190131032353-9307ec01e70f // indirect + sigs.k8s.io/kustomize v1.0.11 // indirect ) diff --git a/go.sum b/go.sum index f4a72f24..04c8e344 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,15 @@ cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emicklei/go-restful v2.8.1+incompatible h1:AyDqLHbJ1quqbWr/OWDw+PlIP8ZFoTmYrGYaxzrLbNg= +github.com/emicklei/go-restful v2.8.1+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/evanphx/json-patch v4.1.0+incompatible h1:K1MDoo4AZ4wU0GIU/fPmtZg7VpzLjCxu+UwBD1FvwOc= +github.com/evanphx/json-patch v4.1.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gdamore/encoding v0.0.0-20151215212835-b23993cbb635 h1:hheUEMzaOie/wKeIc1WPa7CDVuIO5hqQxjS+dwTQEnI= @@ -10,6 +18,14 @@ github.com/gdamore/tcell v1.1.0 h1:RbQgl7jukmdqROeNcKps7R2YfDCQbWkOd1BwdXrxfr4= github.com/gdamore/tcell v1.1.0/go.mod h1:tqyG50u7+Ctv1w5VX67kLzKcj9YXR/JSBZQq/+mLl1A= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonreference v0.17.0 h1:yJW3HCkTHg7NOA+gZ83IPHzUSnUzGXhGmsdiCcMexbA= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/spec v0.18.0 h1:aIjeyG5mo5/FrvDkpKKEGZPmF9MPHahS72mzfVqeQXQ= +github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880= +github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= @@ -42,6 +58,8 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGi github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08 h1:5MnxBC15uMxFv5FY/J/8vzyaBiArCOkMdFT9Jsw78iY= github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08/go.mod h1:NXg0ArsFk0Y01623LgUqoqcouGDB+PwCCQlrwrG6xJ4= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= @@ -56,6 +74,8 @@ github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+v github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/petergtz/pegomock v0.0.0-20181206220228-b113d17a7e81 h1:MhSbvsIs4KvpPYr4taOvb6j+r9VNbj/08AfjsKi+Ui0= github.com/petergtz/pegomock v0.0.0-20181206220228-b113d17a7e81/go.mod h1:nuBLWZpVyv/fLo56qTwt/AUau7jgouO1h7bEvZCq82o= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= @@ -76,6 +96,7 @@ golang.org/x/crypto v0.0.0-20181106171534-e4dc69e5b2fd h1:VtIkGDhk0ph3t+THbvXHfM golang.org/x/crypto v0.0.0-20181106171534-e4dc69e5b2fd/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181102091132-c10e9556a7bc h1:ZMCWScCvS2fUVFw8LOpxyUUW5qiviqr4Dg5NdjLeiLU= golang.org/x/net v0.0.0-20181102091132-c10e9556a7bc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/oauth2 v0.0.0-20181105165119-ca4130e427c7 h1:g9UOdtsRWEwHYUG2bDHMxKrvfSGE5epIX2HkaMHSMBY= @@ -113,7 +134,13 @@ k8s.io/apimachinery v0.0.0-20181108045954-261df694e725 h1:b4fe6FhSyMdpi6WNeCxxr+ k8s.io/apimachinery v0.0.0-20181108045954-261df694e725/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= k8s.io/client-go v9.0.0+incompatible h1:2kqW3X2xQ9SbFvWZjGEHBLlWc1LG9JIJNXWkuqwdZ3A= k8s.io/client-go v9.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= +k8s.io/kube-openapi v0.0.0-20190131215449-d8b685cd2daa h1:BaHeFwQGkOr0hofNfYbGmI7WXu8AIWBlZ0mUWvXt+SQ= +k8s.io/kube-openapi v0.0.0-20190131215449-d8b685cd2daa/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= k8s.io/kubernetes v1.13.0 h1:2psb4AOWOU3rESSjRVkqHRIIXkqLppfeiR6YE0trpt0= k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= k8s.io/metrics v0.0.0-20181121073115-d8618695b08f h1:HyUoIBzks9xTaSnMJ6kv/SSmwaQQccokuiriu2cV0aA= k8s.io/metrics v0.0.0-20181121073115-d8618695b08f/go.mod h1:a25VAbm3QT3xiVl1jtoF1ueAKQM149UdZ+L93ePfV3M= +sigs.k8s.io/kind v0.0.0-20190131032353-9307ec01e70f h1:Rb8ZMMK39NO/kSyz+0RFjwhQpYKxGaRc10mXV8mVsDs= +sigs.k8s.io/kind v0.0.0-20190131032353-9307ec01e70f/go.mod h1:4luVoV3UfY4B4ZNzvRPdM0egGo9zqFn/drRXqYPw9Ig= +sigs.k8s.io/kustomize v1.0.11 h1:Yb+6DDt9+aR2AvQApvUaKS/ugteeG4MPyoFeUHiPOjk= +sigs.k8s.io/kustomize v1.0.11/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= diff --git a/main.go b/main.go index cb86d841..7f068e87 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,7 @@ import ( "os" "path" - "github.com/k8sland/k9s/cmd" + "github.com/derailed/k9s/cmd" log "github.com/sirupsen/logrus" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" ) diff --git a/resource/base.go b/resource/base.go index acb2f892..141316ef 100644 --- a/resource/base.go +++ b/resource/base.go @@ -3,7 +3,7 @@ package resource import ( "path" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/resource/cluster.go b/resource/cluster.go index 7cbd6ef0..c2eb557a 100644 --- a/resource/cluster.go +++ b/resource/cluster.go @@ -1,7 +1,7 @@ package resource import ( - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" "k8s.io/api/core/v1" ) diff --git a/resource/cluster_test.go b/resource/cluster_test.go index 1b6ef6e5..00ab49dc 100644 --- a/resource/cluster_test.go +++ b/resource/cluster_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" diff --git a/resource/cm.go b/resource/cm.go index ac8ad5d6..585fda25 100644 --- a/resource/cm.go +++ b/resource/cm.go @@ -4,7 +4,7 @@ import ( "log" "strconv" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" yaml "gopkg.in/yaml.v2" "k8s.io/api/core/v1" ) diff --git a/resource/cm_test.go b/resource/cm_test.go index 2f1968f6..7173b769 100644 --- a/resource/cm_test.go +++ b/resource/cm_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/resource/context.go b/resource/context.go index 04222718..6f83698a 100644 --- a/resource/context.go +++ b/resource/context.go @@ -1,7 +1,7 @@ package resource import ( - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" ) diff --git a/resource/context_test.go b/resource/context_test.go index 3b05aca5..b7d1216b 100644 --- a/resource/context_test.go +++ b/resource/context_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" pegomock "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" diff --git a/resource/cr.go b/resource/cr.go index f5d74a27..14d7c3df 100644 --- a/resource/cr.go +++ b/resource/cr.go @@ -1,7 +1,7 @@ package resource import ( - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" "k8s.io/api/rbac/v1" diff --git a/resource/cr_binding.go b/resource/cr_binding.go index 9032bea6..4a57fdcc 100644 --- a/resource/cr_binding.go +++ b/resource/cr_binding.go @@ -1,7 +1,7 @@ package resource import ( - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" "k8s.io/api/rbac/v1" diff --git a/resource/cr_binding_test.go b/resource/cr_binding_test.go index a330b11a..ff771874 100644 --- a/resource/cr_binding_test.go +++ b/resource/cr_binding_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" rbacv1 "k8s.io/api/rbac/v1" diff --git a/resource/cr_test.go b/resource/cr_test.go index 1f588255..1a203be1 100644 --- a/resource/cr_test.go +++ b/resource/cr_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" diff --git a/resource/crd.go b/resource/crd.go index d6ce4d2e..97ed0d1c 100644 --- a/resource/crd.go +++ b/resource/crd.go @@ -3,7 +3,7 @@ package resource import ( "time" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/resource/crd_test.go b/resource/crd_test.go index 018314e0..045b8a27 100644 --- a/resource/crd_test.go +++ b/resource/crd_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/resource/cronjob.go b/resource/cronjob.go index 2c49f848..f3a53b15 100644 --- a/resource/cronjob.go +++ b/resource/cronjob.go @@ -3,7 +3,7 @@ package resource import ( "strconv" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" batchv1beta1 "k8s.io/api/batch/v1beta1" diff --git a/resource/cronjob_test.go b/resource/cronjob_test.go index c2cf0e1d..f8c1f784 100644 --- a/resource/cronjob_test.go +++ b/resource/cronjob_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" batchv1beta1 "k8s.io/api/batch/v1beta1" diff --git a/resource/custom.go b/resource/custom.go index 87827d40..33a4e3f7 100644 --- a/resource/custom.go +++ b/resource/custom.go @@ -7,7 +7,7 @@ import ( "path" "strings" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1" diff --git a/resource/dp.go b/resource/dp.go index 59464e71..eb024baa 100644 --- a/resource/dp.go +++ b/resource/dp.go @@ -3,7 +3,7 @@ package resource import ( "strconv" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/apps/v1" diff --git a/resource/dp_test.go b/resource/dp_test.go index c93a7d03..8ba03f97 100644 --- a/resource/dp_test.go +++ b/resource/dp_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" diff --git a/resource/ds.go b/resource/ds.go index 9d24b3e9..f7e7f1fa 100644 --- a/resource/ds.go +++ b/resource/ds.go @@ -3,7 +3,7 @@ package resource import ( "strconv" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" extv1beta1 "k8s.io/api/extensions/v1beta1" diff --git a/resource/ds_test.go b/resource/ds_test.go index 8a7127d1..f3ddbbe9 100644 --- a/resource/ds_test.go +++ b/resource/ds_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" extv1beta1 "k8s.io/api/extensions/v1beta1" diff --git a/resource/ep.go b/resource/ep.go index 8e95f59d..9b34b160 100644 --- a/resource/ep.go +++ b/resource/ep.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/core/v1" diff --git a/resource/ep_test.go b/resource/ep_test.go index 3ce7db22..56d6cbff 100644 --- a/resource/ep_test.go +++ b/resource/ep_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/resource/evt.go b/resource/evt.go index 24a1e85d..255bd703 100644 --- a/resource/evt.go +++ b/resource/evt.go @@ -4,7 +4,7 @@ import ( "regexp" "strconv" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/core/v1" diff --git a/resource/evt_test.go b/resource/evt_test.go index 7183b758..12b0c647 100644 --- a/resource/evt_test.go +++ b/resource/evt_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/resource/hpa.go b/resource/hpa.go index d514e543..a6124c1e 100644 --- a/resource/hpa.go +++ b/resource/hpa.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/autoscaling/v1" diff --git a/resource/hpa_test.go b/resource/hpa_test.go index 0366fc7a..db267e22 100644 --- a/resource/hpa_test.go +++ b/resource/hpa_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/autoscaling/v1" diff --git a/resource/ing.go b/resource/ing.go index 7dbcaf72..9fb6e832 100644 --- a/resource/ing.go +++ b/resource/ing.go @@ -3,7 +3,7 @@ package resource import ( "strings" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/core/v1" diff --git a/resource/ing_test.go b/resource/ing_test.go index 16e6d8fe..3b914ffb 100644 --- a/resource/ing_test.go +++ b/resource/ing_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/extensions/v1beta1" diff --git a/resource/job.go b/resource/job.go index ffbe53bb..40eb932d 100644 --- a/resource/job.go +++ b/resource/job.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/batch/v1" diff --git a/resource/job_test.go b/resource/job_test.go index 3cd84b8b..671f92b7 100644 --- a/resource/job_test.go +++ b/resource/job_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/batch/v1" diff --git a/resource/list.go b/resource/list.go index fdbebaaf..21afdd01 100644 --- a/resource/list.go +++ b/resource/list.go @@ -4,7 +4,7 @@ import ( "reflect" "sort" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" "k8s.io/apimachinery/pkg/watch" ) @@ -154,6 +154,9 @@ func (l *list) GetNamespace() string { // SetNamespace updates the namespace on the list. Default ns is "" for all // namespaces. func (l *list) SetNamespace(n string) { + if l.namespace == n { + return + } l.cache = RowEvents{} if l.Access(NamespaceAccess) { l.namespace = n diff --git a/resource/mock_caller_test.go b/resource/mock_caller_test.go index eb03f6ed..29562d4c 100644 --- a/resource/mock_caller_test.go +++ b/resource/mock_caller_test.go @@ -1,10 +1,10 @@ // Code generated by pegomock. DO NOT EDIT. -// Source: github.com/k8sland/k9s/resource (interfaces: Caller) +// Source: github.com/derailed/k9s/resource (interfaces: Caller) package resource_test import ( - k8s "github.com/k8sland/k9s/resource/k8s" + k8s "github.com/derailed/k9s/resource/k8s" pegomock "github.com/petergtz/pegomock" "reflect" "time" diff --git a/resource/mock_clusterifc_test.go b/resource/mock_clusterifc_test.go index 03756cbd..7be9872b 100644 --- a/resource/mock_clusterifc_test.go +++ b/resource/mock_clusterifc_test.go @@ -1,5 +1,5 @@ // Code generated by pegomock. DO NOT EDIT. -// Source: github.com/k8sland/k9s/resource (interfaces: ClusterIfc) +// Source: github.com/derailed/k9s/resource (interfaces: ClusterIfc) package resource_test diff --git a/resource/mock_metricsifc_test.go b/resource/mock_metricsifc_test.go index 218fe3c4..6a97b05d 100644 --- a/resource/mock_metricsifc_test.go +++ b/resource/mock_metricsifc_test.go @@ -1,10 +1,10 @@ // Code generated by pegomock. DO NOT EDIT. -// Source: github.com/k8sland/k9s/resource (interfaces: MetricsIfc) +// Source: github.com/derailed/k9s/resource (interfaces: MetricsIfc) package resource_test import ( - k8s "github.com/k8sland/k9s/resource/k8s" + k8s "github.com/derailed/k9s/resource/k8s" pegomock "github.com/petergtz/pegomock" v1 "k8s.io/api/core/v1" "reflect" diff --git a/resource/mock_resource_test.go b/resource/mock_resource_test.go index e4eb565b..48ebb1b2 100644 --- a/resource/mock_resource_test.go +++ b/resource/mock_resource_test.go @@ -1,10 +1,10 @@ // Code generated by pegomock. DO NOT EDIT. -// Source: github.com/k8sland/k9s/resource (interfaces: Resource) +// Source: github.com/derailed/k9s/resource (interfaces: Resource) package resource_test import ( - resource "github.com/k8sland/k9s/resource" + resource "github.com/derailed/k9s/resource" pegomock "github.com/petergtz/pegomock" "reflect" "time" diff --git a/resource/mock_switchableres_test.go b/resource/mock_switchableres_test.go index 50d4d001..74146fa6 100644 --- a/resource/mock_switchableres_test.go +++ b/resource/mock_switchableres_test.go @@ -1,10 +1,10 @@ // Code generated by pegomock. DO NOT EDIT. -// Source: github.com/k8sland/k9s/resource (interfaces: SwitchableRes) +// Source: github.com/derailed/k9s/resource (interfaces: SwitchableRes) package resource_test import ( - k8s "github.com/k8sland/k9s/resource/k8s" + k8s "github.com/derailed/k9s/resource/k8s" pegomock "github.com/petergtz/pegomock" "reflect" "time" diff --git a/resource/no.go b/resource/no.go index 2e7de884..55cd927b 100644 --- a/resource/no.go +++ b/resource/no.go @@ -5,7 +5,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/core/v1" diff --git a/resource/no_test.go b/resource/no_test.go index 8a2715d8..18fc9042 100644 --- a/resource/no_test.go +++ b/resource/no_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/resource/ns.go b/resource/ns.go index 44fc77e6..a0ab86fb 100644 --- a/resource/ns.go +++ b/resource/ns.go @@ -1,7 +1,7 @@ package resource import ( - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/core/v1" diff --git a/resource/ns_test.go b/resource/ns_test.go index 565eea13..1690aaf4 100644 --- a/resource/ns_test.go +++ b/resource/ns_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/resource/pod.go b/resource/pod.go index aa3d7cbb..4edbe22b 100644 --- a/resource/pod.go +++ b/resource/pod.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" "k8s.io/api/core/v1" diff --git a/resource/pod_test.go b/resource/pod_test.go index 1dc22426..8e90d24f 100644 --- a/resource/pod_test.go +++ b/resource/pod_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/resource/pv.go b/resource/pv.go index 259a4efc..605ac06a 100644 --- a/resource/pv.go +++ b/resource/pv.go @@ -4,7 +4,7 @@ import ( "path" "strings" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" "k8s.io/api/core/v1" diff --git a/resource/pv_test.go b/resource/pv_test.go index b84e7e10..7402ad17 100644 --- a/resource/pv_test.go +++ b/resource/pv_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/resource/pvc.go b/resource/pvc.go index 707a887a..180f3f37 100644 --- a/resource/pvc.go +++ b/resource/pvc.go @@ -1,7 +1,7 @@ package resource import ( - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" "k8s.io/api/core/v1" diff --git a/resource/pvc_test.go b/resource/pvc_test.go index 1a5597a5..6bf359c3 100644 --- a/resource/pvc_test.go +++ b/resource/pvc_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/resource/ro.go b/resource/ro.go index 350e232f..36284c94 100644 --- a/resource/ro.go +++ b/resource/ro.go @@ -3,7 +3,7 @@ package resource import ( "strings" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" "k8s.io/api/rbac/v1" diff --git a/resource/ro_binding.go b/resource/ro_binding.go index 50f783af..f37b2fff 100644 --- a/resource/ro_binding.go +++ b/resource/ro_binding.go @@ -3,7 +3,7 @@ package resource import ( "strings" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" "k8s.io/api/rbac/v1" diff --git a/resource/ro_binding_test.go b/resource/ro_binding_test.go index 5f5791f9..b0085f14 100644 --- a/resource/ro_binding_test.go +++ b/resource/ro_binding_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/rbac/v1" diff --git a/resource/ro_test.go b/resource/ro_test.go index 92300e03..bc50ec3f 100644 --- a/resource/ro_test.go +++ b/resource/ro_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/rbac/v1" diff --git a/resource/rs.go b/resource/rs.go index 3bf86541..3ec29c06 100644 --- a/resource/rs.go +++ b/resource/rs.go @@ -3,7 +3,7 @@ package resource import ( "strconv" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/apps/v1" diff --git a/resource/rs_test.go b/resource/rs_test.go index 457d18b5..00ed8131 100644 --- a/resource/rs_test.go +++ b/resource/rs_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/apps/v1" diff --git a/resource/sa.go b/resource/sa.go index 1cc683a9..d09c71b6 100644 --- a/resource/sa.go +++ b/resource/sa.go @@ -3,7 +3,7 @@ package resource import ( "strconv" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" "k8s.io/api/core/v1" diff --git a/resource/sa_test.go b/resource/sa_test.go index 7dcbd874..e18f0b22 100644 --- a/resource/sa_test.go +++ b/resource/sa_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/resource/secret.go b/resource/secret.go index d02f4859..89344759 100644 --- a/resource/secret.go +++ b/resource/secret.go @@ -4,7 +4,7 @@ import ( "log" "strconv" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" yaml "gopkg.in/yaml.v2" "k8s.io/api/core/v1" ) diff --git a/resource/secret_test.go b/resource/secret_test.go index bf4232aa..ec889a04 100644 --- a/resource/secret_test.go +++ b/resource/secret_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/resource/sts.go b/resource/sts.go index 2ab85295..dbaa374f 100644 --- a/resource/sts.go +++ b/resource/sts.go @@ -3,7 +3,7 @@ package resource import ( "strconv" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/apps/v1" diff --git a/resource/sts_test.go b/resource/sts_test.go index 61d46ecf..7c0534b5 100644 --- a/resource/sts_test.go +++ b/resource/sts_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/apps/v1" diff --git a/resource/svc.go b/resource/svc.go index 71cc7b08..defac178 100644 --- a/resource/svc.go +++ b/resource/svc.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource/k8s" log "github.com/sirupsen/logrus" yaml "gopkg.in/yaml.v2" "k8s.io/api/core/v1" diff --git a/resource/svc_test.go b/resource/svc_test.go index f6c64e96..14782330 100644 --- a/resource/svc_test.go +++ b/resource/svc_test.go @@ -3,8 +3,8 @@ package resource_test import ( "testing" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" m "github.com/petergtz/pegomock" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" diff --git a/vendor/modules.txt b/vendor/modules.txt index 0754349a..99cbe60d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -148,14 +148,16 @@ k8s.io/apiextensions-apiserver/pkg/apis/apiextensions # k8s.io/apimachinery v0.0.0-20181108045954-261df694e725 k8s.io/apimachinery/pkg/apis/meta/v1 k8s.io/apimachinery/pkg/apis/meta/v1/unstructured +k8s.io/apimachinery/pkg/apis/meta/v1beta1 k8s.io/apimachinery/pkg/util/duration k8s.io/apimachinery/pkg/util/sets k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/pkg/labels +k8s.io/apimachinery/pkg/runtime k8s.io/apimachinery/pkg/runtime/schema +k8s.io/apimachinery/pkg/runtime/serializer k8s.io/apimachinery/pkg/util/net k8s.io/apimachinery/pkg/util/yaml -k8s.io/apimachinery/pkg/runtime k8s.io/apimachinery/pkg/util/intstr k8s.io/apimachinery/pkg/api/resource k8s.io/apimachinery/pkg/types @@ -165,30 +167,28 @@ k8s.io/apimachinery/pkg/selection k8s.io/apimachinery/pkg/util/runtime k8s.io/apimachinery/pkg/util/json k8s.io/apimachinery/pkg/util/validation -k8s.io/apimachinery/pkg/api/meta -k8s.io/apimachinery/pkg/runtime/serializer -k8s.io/apimachinery/pkg/runtime/serializer/json -k8s.io/apimachinery/pkg/runtime/serializer/streaming -k8s.io/apimachinery/pkg/runtime/serializer/versioning -k8s.io/apimachinery/pkg/api/errors -k8s.io/apimachinery/pkg/util/errors -k8s.io/apimachinery/pkg/api/validation -k8s.io/apimachinery/pkg/version -k8s.io/apimachinery/pkg/util/clock k8s.io/apimachinery/pkg/conversion/queryparams +k8s.io/apimachinery/pkg/util/errors k8s.io/apimachinery/pkg/util/naming -k8s.io/apimachinery/third_party/forked/golang/reflect -k8s.io/apimachinery/pkg/util/validation/field -k8s.io/apimachinery/pkg/apis/meta/v1beta1 +k8s.io/apimachinery/pkg/runtime/serializer/json k8s.io/apimachinery/pkg/runtime/serializer/protobuf k8s.io/apimachinery/pkg/runtime/serializer/recognizer +k8s.io/apimachinery/pkg/runtime/serializer/versioning +k8s.io/apimachinery/pkg/api/meta +k8s.io/apimachinery/pkg/runtime/serializer/streaming +k8s.io/apimachinery/pkg/api/errors +k8s.io/apimachinery/pkg/api/validation +k8s.io/apimachinery/third_party/forked/golang/reflect +k8s.io/apimachinery/pkg/util/validation/field k8s.io/apimachinery/pkg/util/framer +k8s.io/apimachinery/pkg/version +k8s.io/apimachinery/pkg/util/clock k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/apis/meta/v1/validation # k8s.io/client-go v9.0.0+incompatible k8s.io/client-go/plugin/pkg/client/auth/gcp -k8s.io/client-go/kubernetes k8s.io/client-go/dynamic +k8s.io/client-go/kubernetes k8s.io/client-go/rest k8s.io/client-go/tools/clientcmd k8s.io/client-go/tools/clientcmd/api diff --git a/views/app.go b/views/app.go index db933fe5..28b1bbe0 100644 --- a/views/app.go +++ b/views/app.go @@ -19,7 +19,6 @@ const ( type ( focusHandler func(tview.Primitive) - // Igniter represents a component that must be initialized. igniter interface { tview.Primitive init(ctx context.Context, ns string) @@ -51,18 +50,21 @@ type ( // NewApp returns a K9s app instance. func NewApp(v string, rate int, ns string) *appView { - app := appView{ - Application: tview.NewApplication(), - pages: tview.NewPages(), - version: v, - menuView: newMenuView(), - content: tview.NewPages(), - refreshRate: rate, - defaultNS: ns, + var app appView + { + app = appView{ + Application: tview.NewApplication(), + pages: tview.NewPages(), + version: v, + menuView: newMenuView(), + content: tview.NewPages(), + refreshRate: rate, + defaultNS: ns, + } + app.command = newCommand(&app) + app.focusChanged = app.changedFocus + app.SetInputCapture(app.keyboard) } - app.command = newCommand(&app) - app.focusChanged = app.changedFocus - app.SetInputCapture(app.keyboard) return &app } @@ -72,20 +74,24 @@ func (a *appView) Init() { a.flashView = newFlashView(a.Application, "Initializing...") - header := tview.NewFlex().SetDirection(tview.FlexColumn) - header.AddItem(logoView(), 30, 1, false) - header.AddItem(a.menuView, 0, 1, false) - header.AddItem(a.infoView, 25, 1, false) + header := tview.NewFlex() + { + header.SetDirection(tview.FlexColumn) + header.AddItem(a.infoView, 25, 1, false) + header.AddItem(a.menuView, 0, 1, false) + header.AddItem(logoView(), 25, 1, false) + } main := tview.NewFlex() - main.SetDirection(tview.FlexRow) - main.AddItem(header, 6, 1, false) - main.AddItem(a.content, 0, 10, true) - main.AddItem(a.flashView, 1, 1, false) + { + main.SetDirection(tview.FlexRow) + main.AddItem(header, 6, 1, false) + main.AddItem(a.content, 0, 10, true) + main.AddItem(a.flashView, 1, 1, false) + } a.pages.AddPage("main", main, true, false) a.pages.AddPage("splash", NewSplash(a.version), true, true) - a.SetRoot(a.pages, true) } @@ -143,9 +149,11 @@ func (a *appView) inject(p igniter) { a.content.RemovePage("main") a.content.AddPage("main", p, true, true) - ctx, cancel := context.WithCancel(context.TODO()) - a.cancel = cancel - p.init(ctx, a.defaultNS) + { + var ctx context.Context + ctx, a.cancel = context.WithCancel(context.TODO()) + p.init(ctx, a.defaultNS) + } go func() { <-time.After(100 * time.Millisecond) @@ -162,31 +170,30 @@ func (a *appView) refresh() { a.infoView.refresh() } -// Quit the application. func (a *appView) quit(*tcell.EventKey) { a.Stop() os.Exit(0) } -// Flash a user message. func (a *appView) flash(level flashLevel, m ...string) { a.flashView.setMessage(level, m...) } -// SetHints for menu bar. func (a *appView) setHints(h hints) { a.menuView.setMenu(h) } func logoView() tview.Primitive { v := tview.NewTextView() - v.SetWordWrap(false) - v.SetWrap(false) - v.SetDynamicColors(true) - for i, s := range logo { - fmt.Fprintf(v, "[orange::b]%s", s) - if i+1 < len(logo) { - fmt.Fprintf(v, "\n") + { + v.SetWordWrap(false) + v.SetWrap(false) + v.SetDynamicColors(true) + for i, s := range logoSmall { + fmt.Fprintf(v, "[orange::b]%s", s) + if i+1 < len(logoSmall) { + fmt.Fprintf(v, "\n") + } } } return v diff --git a/views/buttons.go b/views/buttons.go deleted file mode 100644 index da2dd9cb..00000000 --- a/views/buttons.go +++ /dev/null @@ -1,27 +0,0 @@ -package views - -// type buttonView struct { -// *tview.Grid -// } - -// func newButtonView() *buttonView { -// v := buttonView{Grid: tview.NewGrid()} -// v.SetBorder(true) -// v.SetTitle("Buttons") -// v.SetRows(1, 1, 1, 1) -// v.SetColumns(5, 5, 5, 5) -// v.SetGap(1, 1) - -// for r := 0; r < 4; r++ { -// for c := 0; c < 4; c++ { -// b := tview.NewButton(fmt.Sprintf("%d:%d", r, c)) -// b.SetBackgroundColor(tcell.ColorGray) -// v.AddItem(b, r, c, 1, 1, 1, 1, false) -// } -// } - -// return &v -// } - -// func (b *buttonView) init(context.Context) { -// } diff --git a/views/colorer.go b/views/colorer.go index 0fe551f0..725875d1 100644 --- a/views/colorer.go +++ b/views/colorer.go @@ -4,7 +4,7 @@ import ( "strings" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" + "github.com/derailed/k9s/resource" "k8s.io/apimachinery/pkg/watch" ) diff --git a/views/colorer_test.go b/views/colorer_test.go index 19bcf2dc..d622242c 100644 --- a/views/colorer_test.go +++ b/views/colorer_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" + "github.com/derailed/k9s/resource" "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/watch" ) @@ -221,7 +221,7 @@ func TestCtxColorer(t *testing.T) { } } -func TestPoColorer(t *testing.T) { +func TestPodColorer(t *testing.T) { var ( nsRow = resource.Row{"blee", "fred", "1/1", "Running"} toastNS = resource.Row{"blee", "fred", "1/1", "Boom"} diff --git a/views/command.go b/views/command.go index c614de8f..695c2076 100644 --- a/views/command.go +++ b/views/command.go @@ -3,7 +3,7 @@ package views import ( "fmt" - "github.com/k8sland/k9s/resource" + "github.com/derailed/k9s/resource" ) type command struct { diff --git a/views/context.go b/views/context.go index 6890f124..11a873bc 100644 --- a/views/context.go +++ b/views/context.go @@ -2,7 +2,7 @@ package views import ( "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" + "github.com/derailed/k9s/resource" ) type contextView struct { diff --git a/views/details.go b/views/details.go index aeb83dd9..b122a54c 100644 --- a/views/details.go +++ b/views/details.go @@ -7,7 +7,7 @@ import ( "github.com/k8sland/tview" ) -const detailFmt = " [orange::b]%s [aqua::-]YAML " +const detailFmt = " [aqua::-]%s [fuchsia::b]YAML " // detailsView display yaml output type detailsView struct { diff --git a/views/flash.go b/views/flash.go index 81f792da..9878d250 100644 --- a/views/flash.go +++ b/views/flash.go @@ -15,6 +15,11 @@ const ( flashErr flashFatal flashDelay = 5 + + emoDoh = "😗" + emoRed = "😡" + emoDead = "💀" + emoHappy = "😎" ) type ( @@ -29,10 +34,13 @@ type ( ) func newFlashView(app *tview.Application, m string) *flashView { - f := flashView{app: app, TextView: tview.NewTextView()} - f.SetTextColor(tcell.ColorAqua) - f.SetTextAlign(tview.AlignLeft) - f.SetBorderPadding(0, 0, 1, 1) + var f flashView + { + f = flashView{app: app, TextView: tview.NewTextView()} + f.SetTextColor(tcell.ColorAqua) + f.SetTextAlign(tview.AlignLeft) + f.SetBorderPadding(0, 0, 1, 1) + } return &f } @@ -40,34 +48,37 @@ func (f *flashView) setMessage(level flashLevel, msg ...string) { if f.cancel != nil { f.cancel() } - ctx, cancel := context.WithTimeout(context.TODO(), flashDelay*time.Second) - f.cancel = cancel - go func(ctx context.Context) { - m := strings.Join(msg, " ") - f.SetTextColor(flashColor(level)) - f.SetText(flashEmoji(level) + " " + m) - f.app.Draw() - for { - select { - case <-ctx.Done(): - f.Clear() - f.app.Draw() - return + + var ctx context.Context + { + ctx, f.cancel = context.WithTimeout(context.TODO(), flashDelay*time.Second) + go func(ctx context.Context) { + m := strings.Join(msg, " ") + f.SetTextColor(flashColor(level)) + f.SetText(flashEmoji(level) + " " + m) + f.app.Draw() + for { + select { + case <-ctx.Done(): + f.Clear() + f.app.Draw() + return + } } - } - }(ctx) + }(ctx) + } } func flashEmoji(l flashLevel) string { switch l { case flashWarn: - return "😗" + return emoDoh case flashErr: - return "😡" + return emoRed case flashFatal: - return "💀" + return emoDead default: - return "😎" + return emoHappy } } diff --git a/views/flash_test.go b/views/flash_test.go new file mode 100644 index 00000000..0477d74f --- /dev/null +++ b/views/flash_test.go @@ -0,0 +1,41 @@ +package views + +import ( + "testing" + + "github.com/gdamore/tcell" + "github.com/stretchr/testify/assert" +) + +func TestFlashEmoji(t *testing.T) { + uu := []struct { + level flashLevel + emoji string + }{ + {flashWarn, emoDoh}, + {flashErr, emoRed}, + {flashFatal, emoDead}, + {flashInfo, emoHappy}, + } + + for _, u := range uu { + assert.Equal(t, u.emoji, flashEmoji(u.level)) + } +} + +func TestFlashColor(t *testing.T) { + uu := []struct { + level flashLevel + color tcell.Color + }{ + {flashWarn, tcell.ColorOrange}, + {flashErr, tcell.ColorOrangeRed}, + {flashFatal, tcell.ColorFuchsia}, + {flashInfo, tcell.ColorNavajoWhite}, + } + + for _, u := range uu { + assert.Equal(t, u.color, flashColor(u.level)) + } + +} diff --git a/views/help.go b/views/help.go index fe063a88..af6d1619 100644 --- a/views/help.go +++ b/views/help.go @@ -5,8 +5,8 @@ import ( "sort" "strings" + "github.com/derailed/k9s/resource" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" "github.com/k8sland/tview" ) @@ -32,14 +32,17 @@ func (v *helpView) init(context.Context, string) { tcell.KeyCtrlB: keyAction{description: "Help Back", action: v.back}, } - t := tview.NewTable() - t.SetBorder(true) - t.SetTitle(" [::b]Commands Help ") - t.SetTitleColor(tcell.ColorAqua) - t.SetBorderColor(tcell.ColorDodgerBlue) - t.SetSelectable(true, false) - t.SetSelectedStyle(tcell.ColorWhite, tcell.ColorFuchsia, tcell.AttrNone) - t.SetInputCapture(v.keyboard) + var t *tview.Table + { + t = tview.NewTable() + t.SetBorder(true) + t.SetTitle(" [::b]Commands Help ") + t.SetTitleColor(tcell.ColorAqua) + t.SetBorderColor(tcell.ColorDodgerBlue) + t.SetSelectable(true, false) + t.SetSelectedStyle(tcell.ColorWhite, tcell.ColorFuchsia, tcell.AttrNone) + t.SetInputCapture(v.keyboard) + } var row int for c, h := range []string{"ALIAS", "RESOURCE", "APIGROUP"} { @@ -50,7 +53,6 @@ func (v *helpView) init(context.Context, string) { row++ cmds := helpCmds() - kk := make([]string, 0, len(cmds)) for k := range cmds { kk = append(kk, k) @@ -98,7 +100,6 @@ func (v *helpView) back(evt *tcell.EventKey) { v.app.inject(v.current) } -// Hints fetch menu hints func (v *helpView) hints() hints { return v.keys.toHints() } diff --git a/views/helpers.go b/views/helpers.go index bc2d5b8a..183ab523 100644 --- a/views/helpers.go +++ b/views/helpers.go @@ -25,6 +25,9 @@ func deltas(c, n string) string { } if isAlpha(c) { + if strings.Contains(c, "(") { + return n + } switch strings.Compare(c, n) { case -1: return plus(n) diff --git a/views/helpers_test.go b/views/helpers_test.go index e61305bd..31811cd9 100644 --- a/views/helpers_test.go +++ b/views/helpers_test.go @@ -3,7 +3,7 @@ package views import ( "testing" - "github.com/k8sland/k9s/resource" + "github.com/derailed/k9s/resource" "github.com/stretchr/testify/assert" ) @@ -16,6 +16,7 @@ func TestDeltas(t *testing.T) { {"1", "2", plus("2")}, {"2", "1", minus("1")}, {"10Gi", "20Gi", plus("20Gi")}, + {"15%(-)", "15%", "15%"}, {resource.MissingValue, "fred", delta("fred")}, {resource.NAValue, "fred", delta("fred")}, } diff --git a/views/info.go b/views/info.go index ddd4dc53..676cd8d2 100644 --- a/views/info.go +++ b/views/info.go @@ -1,8 +1,8 @@ package views import ( + "github.com/derailed/k9s/resource" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" "github.com/k8sland/tview" log "github.com/sirupsen/logrus" ) @@ -20,10 +20,10 @@ func newInfoView(app *appView) *infoView { func (v *infoView) init() { var row int cluster := resource.NewCluster() - rev := cluster.Version() v.SetCell(row, 0, v.sectionCell("Cluster")) v.SetCell(row, 1, v.infoCell(cluster.Name())) row++ + rev := cluster.Version() v.SetCell(row, 0, v.sectionCell("K8s Version")) v.SetCell(row, 1, v.infoCell(rev)) row++ diff --git a/views/log.go b/views/log.go index 628f53b5..127f02f3 100644 --- a/views/log.go +++ b/views/log.go @@ -15,17 +15,18 @@ type logView struct { } func newLogView(title string, pv *podView) *logView { - v := logView{TextView: tview.NewTextView()} - - v.SetScrollable(true) - v.SetDynamicColors(true) - v.SetBorder(true) - v.SetBorderPadding(0, 0, 1, 1) - v.SetTitle(fmt.Sprintf(logTitleFmt, pv.selectedItem, title)) - v.SetWrap(false) - v.SetChangedFunc(func() { - pv.app.Draw() - }) - + var v logView + { + v = logView{TextView: tview.NewTextView()} + v.SetScrollable(true) + v.SetDynamicColors(true) + v.SetBorder(true) + v.SetBorderPadding(0, 0, 1, 1) + v.SetTitle(fmt.Sprintf(logTitleFmt, pv.selectedItem, title)) + v.SetWrap(false) + v.SetChangedFunc(func() { + pv.app.Draw() + }) + } return &v } diff --git a/views/logs.go b/views/logs.go index 19d08555..384c448d 100644 --- a/views/logs.go +++ b/views/logs.go @@ -5,8 +5,8 @@ import ( "fmt" "strconv" + "github.com/derailed/k9s/resource" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" "github.com/k8sland/tview" log "github.com/sirupsen/logrus" ) @@ -21,9 +21,11 @@ type logsView struct { } func newLogsView(pv *podView) *logsView { - v := logsView{Pages: tview.NewPages(), pv: pv, containers: []string{}} - v.SetInputCapture(v.keyboard) - + var v logsView + { + v = logsView{Pages: tview.NewPages(), pv: pv, containers: []string{}} + v.SetInputCapture(v.keyboard) + } return &v } diff --git a/views/menu.go b/views/menu.go index e26e1236..3159b156 100644 --- a/views/menu.go +++ b/views/menu.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" + "github.com/derailed/k9s/resource" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" "github.com/k8sland/tview" ) @@ -92,7 +92,6 @@ type ( description string action keyboardHandler } - keyActions map[tcell.Key]keyAction menuView struct { @@ -112,7 +111,6 @@ func newMenuView() *menuView { func (v *menuView) setMenu(hh hints) { v.Clear() - v.SetRows(1, 1, 1, 1) v.SetColumns(colLen, colLen) isNS := true diff --git a/views/pod.go b/views/pod.go index d15bd96b..4ed531e8 100644 --- a/views/pod.go +++ b/views/pod.go @@ -1,8 +1,8 @@ package views import ( + "github.com/derailed/k9s/resource" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" log "github.com/sirupsen/logrus" ) @@ -15,12 +15,13 @@ func newPodView(t string, app *appView, list resource.List, c colorerFn) resourc v.extraActionsFn = v.extraActions logs := newLogsView(&v) - logs.setActions(keyActions{ - tcell.KeyCtrlB: {description: "Back", action: v.stopLogs}, - tcell.KeyCtrlK: {description: "Clear", action: v.clearLogs}, - }) - - v.AddPage("logs", logs, true, false) + { + logs.setActions(keyActions{ + tcell.KeyCtrlB: {description: "Back", action: v.stopLogs}, + tcell.KeyCtrlK: {description: "Clear", action: v.clearLogs}, + }) + v.AddPage("logs", logs, true, false) + } picker := newSelectList() { @@ -31,11 +32,10 @@ func newPodView(t string, app *appView, list resource.List, c colorerFn) resourc picker.setActions(keyActions{ tcell.KeyCtrlB: {description: "Back", action: v.back}, }) + v.AddPage("choose", picker, true, false) } - v.AddPage("choose", picker, true, false) v.switchPage("po") - return &v } diff --git a/views/registrar.go b/views/registrar.go index 49fca604..3c36d2f9 100644 --- a/views/registrar.go +++ b/views/registrar.go @@ -1,9 +1,9 @@ package views import ( + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" ) type ( @@ -21,13 +21,13 @@ type ( ) var cmdMap = map[string]resCmd{ - // "cm": resCmd{ - // title: "Config Maps", - // api: "core", - // viewFn: newResourceView, - // listFn: resource.NewConfigMapList, - // colorerFn: defaultColorer, - // }, + "cm": resCmd{ + title: "Config Maps", + api: "core", + viewFn: newResourceView, + listFn: resource.NewConfigMapList, + colorerFn: defaultColorer, + }, "cr": resCmd{ title: "Cluster Roles", api: "rbac.authorization.k8s.io", @@ -189,17 +189,17 @@ var cmdMap = map[string]resCmd{ listFn: resource.NewStatefulSetList, colorerFn: stsColorer, }, - // "svc": resCmd{ - // title: "Services", - // api: "core", - // viewFn: newResourceView, - // listFn: resource.NewServiceList, - // colorerFn: defaultColorer, - // }, + "svc": resCmd{ + title: "Services", + api: "core", + viewFn: newResourceView, + listFn: resource.NewServiceList, + colorerFn: defaultColorer, + }, } func helpCmds() map[string]resCmd { - cmds := map[string]resCmd{} + cmds := make(map[string]resCmd, len(cmdMap)) for k, v := range cmdMap { cmds[k] = v } @@ -242,23 +242,23 @@ func getCRDS() map[string]k8s.ApiGroup { } } - m["cm"] = k8s.ApiGroup{ - Version: "v1", - Group: "", - Kind: "ConfigMap", - Singular: "configmap", - Plural: "configmaps", - Aliases: []string{"cm"}, - } + // m["cm"] = k8s.ApiGroup{ + // Version: "v1", + // Group: "core", + // Kind: "ConfigMap", + // Singular: "configmap", + // Plural: "configmaps", + // Aliases: []string{"cm"}, + // } - m["svc"] = k8s.ApiGroup{ - Version: "v1", - Group: "", - Kind: "Service", - Singular: "service", - Plural: "services", - Aliases: []string{"svc"}, - } + // m["svc"] = k8s.ApiGroup{ + // Version: "v1", + // Group: "core", + // Kind: "Service", + // Singular: "service", + // Plural: "services", + // Aliases: []string{"svc"}, + // } return m } diff --git a/views/resource.go b/views/resource.go index 46c4890c..e741ceae 100644 --- a/views/resource.go +++ b/views/resource.go @@ -9,12 +9,12 @@ import ( "strings" "time" + "github.com/derailed/k9s/resource" + "github.com/derailed/k9s/resource/k8s" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" - "github.com/k8sland/k9s/resource/k8s" "github.com/k8sland/tview" log "github.com/sirupsen/logrus" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" ) const noSelection = "" @@ -200,8 +200,9 @@ func (v *resourceView) switchNamespace(evt *tcell.EventKey) { v.refresh() } v.resume() - v.selectedItem = noSelection + v.selectItem(0, 0) v.getTV().resetTitle() + v.getTV().Select(0, 0) v.app.resetCmd() } @@ -223,6 +224,7 @@ func (v *resourceView) refresh() { if _, ok := v.CurrentPage().Item.(*tableView); !ok { return } + v.list.SetNamespace(v.selectedNS) if err := v.list.Reconcile(); err != nil { v.app.flash(flashErr, err.Error()) diff --git a/views/splash.go b/views/splash.go index 2c23fe87..b3f653ac 100644 --- a/views/splash.go +++ b/views/splash.go @@ -13,7 +13,8 @@ const ( product = "Kubernetes CLI Island Style!" ) -var logo = []string{ +var logoSmall = []string{ + ` __ ______ `, `| | __/ __ \ ______`, `| |/ /> < / ___/`, @@ -22,6 +23,15 @@ var logo = []string{ ` \/ \/ \/ `, } +var logo = []string{ + ` ____ __. ______ _________ .___`, + `| |/ _|/ __ \ _____\_ ___ \ _____ __| _/`, + `| < > < / ___/ \ \/ / \ / __ | `, + `| | \/ -- \\___ \\ \___| Y Y \/ /_/ | `, + `|____|__ \______ /____ >\______ /__|_| /\____ | `, + ` \/ \/ \/ \/ \/ \/ `, +} + var co = []string{ `.__ .__ __ .__ `, `|__| _____ | |__ _____/ |_ ____ ______ |__| ____ `, @@ -40,28 +50,25 @@ type Splash struct { func NewSplash(rev string) *Splash { v := Splash{tview.NewFlex()} - t1 := tview.NewTextView() - t1.SetDynamicColors(true) - t1.SetBackgroundColor(tcell.ColorDefault) - t1.SetTextAlign(tview.AlignCenter) - v.layoutLogo(t1) + logo := tview.NewTextView() + { + logo.SetDynamicColors(true) + logo.SetBackgroundColor(tcell.ColorDefault) + logo.SetTextAlign(tview.AlignCenter) + } + v.layoutLogo(logo) - t2 := tview.NewTextView() - t2.SetDynamicColors(true) - t2.SetBackgroundColor(tcell.ColorDefault) - t2.SetTextAlign(tview.AlignCenter) - v.layoutCo(t2) - - t3 := tview.NewTextView() - t3.SetDynamicColors(true) - t3.SetBackgroundColor(tcell.ColorDefault) - t3.SetTextAlign(tview.AlignCenter) - v.layoutRev(t3, rev) + vers := tview.NewTextView() + { + vers.SetDynamicColors(true) + vers.SetBackgroundColor(tcell.ColorDefault) + vers.SetTextAlign(tview.AlignCenter) + } + v.layoutRev(vers, rev) v.SetDirection(tview.FlexRow) - v.AddItem(t2, 0, 2, false) - v.AddItem(t1, 0, 4, false) - v.AddItem(t3, 2, 1, false) + v.AddItem(logo, 10, 1, false) + v.AddItem(vers, 1, 1, false) return &v } @@ -70,11 +77,6 @@ func (v *Splash) layoutLogo(t *tview.TextView) { fmt.Fprintf(t, "%s[orange::b]%s\n", strings.Repeat("\n", 2), logo) } -func (v *Splash) layoutCo(t *tview.TextView) { - cos := strings.Join(co, "\n[yellowgreen::b]") - fmt.Fprintf(t, "[yellowgreen::b]%s\n", cos) -} - func (v *Splash) layoutRev(t *tview.TextView, rev string) { fmt.Fprintf(t, "[white::b]Revision [red::b]%s", rev) } diff --git a/views/table.go b/views/table.go index 5c9921d3..167d5eca 100644 --- a/views/table.go +++ b/views/table.go @@ -2,16 +2,15 @@ package views import ( "fmt" - "strings" + "github.com/derailed/k9s/resource" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" "github.com/k8sland/tview" ) const ( titleFmt = " [aqua::b]%s[aqua::-]([fuchsia::b]%d[aqua::-]) " - nsTitleFmt = " [aqua::-]<[fuchsia::b]%s[aqua::-]>" + titleFmt + nsTitleFmt = " [aqua::b]%s([fuchsia::b]%s[aqua::-])[aqua::-][[aqua::b]%d[aqua::-]][aqua::-] " ) type ( @@ -98,7 +97,7 @@ func (v *tableView) resetTitle() { if v.currentNS == resource.AllNamespaces { ns = "all" } - v.SetTitle(fmt.Sprintf(nsTitleFmt, strings.Title(ns), v.baseTitle, v.GetRowCount()-1)) + v.SetTitle(fmt.Sprintf(nsTitleFmt, v.baseTitle, ns, v.GetRowCount()-1)) } } @@ -110,12 +109,13 @@ func (v *tableView) update(data resource.TableData) { var row int for col, h := range data.Header { c := tview.NewTableCell(h) - if len(h) == 0 { - c.SetExpansion(1) - } else { + { c.SetExpansion(3) + if len(h) == 0 { + c.SetExpansion(1) + } + c.SetTextColor(tcell.ColorWhite) } - c.SetTextColor(tcell.ColorWhite) v.SetCell(row, col, c) } row++ @@ -132,12 +132,13 @@ func (v *tableView) update(data resource.TableData) { } for col, f := range data.Rows[k].Fields { c := tview.NewTableCell(deltas(data.Rows[k].Deltas[col], f)) - if len(data.Header[col]) == 0 { - c.SetExpansion(1) - } else { + { c.SetExpansion(3) + if len(data.Header[col]) == 0 { + c.SetExpansion(1) + } + c.SetTextColor(fgColor) } - c.SetTextColor(fgColor) v.SetCell(row, col, c) } row++ diff --git a/views/xray.go b/views/xray.go index c7ee86a7..eb63bcea 100644 --- a/views/xray.go +++ b/views/xray.go @@ -4,7 +4,7 @@ import ( "context" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" + "github.com/derailed/k9s/resource" "github.com/k8sland/tview" ) diff --git a/views/yaml.go b/views/yaml.go index 44c4187b..d301642c 100644 --- a/views/yaml.go +++ b/views/yaml.go @@ -6,8 +6,8 @@ import ( "sort" "strings" + "github.com/derailed/k9s/resource" "github.com/gdamore/tcell" - "github.com/k8sland/k9s/resource" "github.com/k8sland/tview" )