cleanup + tests check

mine
derailed 2019-02-01 14:33:00 -07:00
parent 487cb43667
commit ae6d339765
91 changed files with 409 additions and 337 deletions

View File

@ -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"

View File

@ -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

2
CNAME
View File

@ -1 +1 @@
k9ss.io
k9s.io

View File

@ -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()

9
go.mod
View File

@ -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
)

27
go.sum
View File

@ -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=

View File

@ -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"
)

View File

@ -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"
)

View File

@ -1,7 +1,7 @@
package resource
import (
"github.com/k8sland/k9s/resource/k8s"
"github.com/derailed/k9s/resource/k8s"
"k8s.io/api/core/v1"
)

View File

@ -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"

View File

@ -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"
)

View File

@ -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"

View File

@ -1,7 +1,7 @@
package resource
import (
"github.com/k8sland/k9s/resource/k8s"
"github.com/derailed/k9s/resource/k8s"
log "github.com/sirupsen/logrus"
)

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"
)

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

30
vendor/modules.txt vendored
View File

@ -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

View File

@ -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

View File

@ -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) {
// }

View File

@ -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"
)

View File

@ -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"}

View File

@ -3,7 +3,7 @@ package views
import (
"fmt"
"github.com/k8sland/k9s/resource"
"github.com/derailed/k9s/resource"
)
type command struct {

View File

@ -2,7 +2,7 @@ package views
import (
"github.com/gdamore/tcell"
"github.com/k8sland/k9s/resource"
"github.com/derailed/k9s/resource"
)
type contextView struct {

View File

@ -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 {

View File

@ -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
}
}

41
views/flash_test.go Normal file
View File

@ -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))
}
}

View File

@ -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()
}

View File

@ -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)

View File

@ -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")},
}

View File

@ -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++

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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())

View File

@ -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)
}

View File

@ -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++

View File

@ -4,7 +4,7 @@ import (
"context"
"github.com/gdamore/tcell"
"github.com/k8sland/k9s/resource"
"github.com/derailed/k9s/resource"
"github.com/k8sland/tview"
)

View File

@ -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"
)