diff --git a/README.md b/README.md index d00c08fe1b..753e3bc7ed 100644 --- a/README.md +++ b/README.md @@ -75,11 +75,6 @@ K9s is available on Linux, macOS and Windows platforms. pkg install k9s ``` -* Via [Winget](https://github.com/microsoft/winget-cli) for Windows - ```shell - winget install k9s - ``` - * Via [Scoop](https://scoop.sh) for Windows ```shell diff --git a/go.mod b/go.mod index 2fb7f9705e..db3cc34b60 100644 --- a/go.mod +++ b/go.mod @@ -19,19 +19,19 @@ require ( github.com/rakyll/hey v0.1.4 github.com/rs/zerolog v1.29.1 github.com/sahilm/fuzzy v0.1.0 - github.com/spf13/cobra v1.7.0 + github.com/spf13/cobra v1.6.1 github.com/stretchr/testify v1.8.3 - golang.org/x/text v0.9.0 + golang.org/x/text v0.8.0 gopkg.in/yaml.v2 v2.4.0 - helm.sh/helm/v3 v3.12.0 + helm.sh/helm/v3 v3.11.1 k8s.io/api v0.27.2 - k8s.io/apiextensions-apiserver v0.27.1 + k8s.io/apiextensions-apiserver v0.26.1 k8s.io/apimachinery v0.27.2 k8s.io/cli-runtime v0.27.2 k8s.io/client-go v0.27.2 k8s.io/klog/v2 v2.90.1 - k8s.io/kubectl v0.27.1 - k8s.io/metrics v0.27.1 + k8s.io/kubectl v0.26.1 + k8s.io/metrics v0.26.2 sigs.k8s.io/yaml v1.3.0 ) @@ -83,11 +83,9 @@ require ( github.com/gorilla/mux v1.8.0 // indirect github.com/gosuri/uitable v0.0.4 // indirect github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/huandu/xstrings v1.4.0 // indirect github.com/imdario/mergo v0.3.13 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmoiron/sqlx v1.3.5 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -151,8 +149,8 @@ require ( google.golang.org/protobuf v1.28.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiserver v0.27.1 // indirect - k8s.io/component-base v0.27.1 // indirect + k8s.io/apiserver v0.26.2 // indirect + k8s.io/component-base v0.26.2 // indirect k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 // indirect oras.land/oras-go v1.2.2 // indirect diff --git a/go.sum b/go.sum index d8fac28044..3342c16fed 100644 --- a/go.sum +++ b/go.sum @@ -179,7 +179,6 @@ github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYF github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= -github.com/foxcpp/go-mockdns v1.0.0 h1:7jBqxd3WDWwi/6WhDvacvH1XsN3rOLXyHM1uhvIx6FI= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -337,13 +336,11 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFb github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= @@ -371,8 +368,8 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= -github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= +github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= @@ -465,7 +462,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/dns v1.1.25 h1:dFwPR6SfLtrSwgDcIq2bcU/gVutB4sNApq2HBdqcakg= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= @@ -628,8 +624,8 @@ github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= -github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= -github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= +github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -753,7 +749,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -931,8 +927,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1140,9 +1136,9 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= -helm.sh/helm/v3 v3.12.0 h1:rOq2TPVzg5jt4q5ermAZGZFxNW2uQhKjRhBneAutMEM= -helm.sh/helm/v3 v3.12.0/go.mod h1:8K/469yxjUMu6BaD2EagCitkPjELUL/l2AgCO142G94= +gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= +helm.sh/helm/v3 v3.11.1 h1:cmL9fFohOoNQf+wnp2Wa0OhNFH0KFnSzEkVxi3fcc3I= +helm.sh/helm/v3 v3.11.1/go.mod h1:z/Bu/BylToGno/6dtNGuSmjRqxKq5gaH+FU0BPO+AQ8= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1152,26 +1148,26 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/api v0.27.2 h1:+H17AJpUMvl+clT+BPnKf0E3ksMAzoBBg7CntpSuADo= k8s.io/api v0.27.2/go.mod h1:ENmbocXfBT2ADujUXcBhHV55RIT31IIEvkntP6vZKS4= -k8s.io/apiextensions-apiserver v0.27.1 h1:Hp7B3KxKHBZ/FxmVFVpaDiXI6CCSr49P1OJjxKO6o4g= -k8s.io/apiextensions-apiserver v0.27.1/go.mod h1:8jEvRDtKjVtWmdkhOqE84EcNWJt/uwF8PC4627UZghY= +k8s.io/apiextensions-apiserver v0.26.1 h1:cB8h1SRk6e/+i3NOrQgSFij1B2S0Y0wDoNl66bn8RMI= +k8s.io/apiextensions-apiserver v0.26.1/go.mod h1:AptjOSXDGuE0JICx/Em15PaoO7buLwTs0dGleIHixSM= k8s.io/apimachinery v0.27.2 h1:vBjGaKKieaIreI+oQwELalVG4d8f3YAMNpWLzDXkxeg= k8s.io/apimachinery v0.27.2/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= -k8s.io/apiserver v0.27.1 h1:phY+BtXjjzd+ta3a4kYbomC81azQSLa1K8jo9RBw7Lg= -k8s.io/apiserver v0.27.1/go.mod h1:UGrOjLY2KsieA9Fw6lLiTObxTb8Z1xEba4uqSuMY0WU= +k8s.io/apiserver v0.26.2 h1:Pk8lmX4G14hYqJd1poHGC08G03nIHVqdJMR0SD3IH3o= +k8s.io/apiserver v0.26.2/go.mod h1:GHcozwXgXsPuOJ28EnQ/jXEM9QeG6HT22YxSNmpYNh8= k8s.io/cli-runtime v0.27.2 h1:9HI8gfReNujKXt16tGOAnb8b4NZ5E+e0mQQHKhFGwYw= k8s.io/cli-runtime v0.27.2/go.mod h1:9UecpyPDTkhiYY4d9htzRqN+rKomJgyb4wi0OfrmCjw= k8s.io/client-go v0.27.2 h1:vDLSeuYvCHKeoQRhCXjxXO45nHVv2Ip4Fe0MfioMrhE= k8s.io/client-go v0.27.2/go.mod h1:tY0gVmUsHrAmjzHX9zs7eCjxcBsf8IiNe7KQ52biTcQ= -k8s.io/component-base v0.27.1 h1:kEB8p8lzi4gCs5f2SPU242vOumHJ6EOsOnDM3tTuDTM= -k8s.io/component-base v0.27.1/go.mod h1:UGEd8+gxE4YWoigz5/lb3af3Q24w98pDseXcXZjw+E0= +k8s.io/component-base v0.26.2 h1:IfWgCGUDzrD6wLLgXEstJKYZKAFS2kO+rBRi0p3LqcI= +k8s.io/component-base v0.26.2/go.mod h1:DxbuIe9M3IZPRxPIzhch2m1eT7uFrSBJUBuVCQEBivs= k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg= k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= -k8s.io/kubectl v0.27.1 h1:9T5c5KdpburYiW8XKQSH0Uly1kMNE90aGSnbYUZNdcA= -k8s.io/kubectl v0.27.1/go.mod h1:QsAkSmrRsKTPlAFzF8kODGDl4p35BIwQnc9XFhkcsy8= -k8s.io/metrics v0.27.1 h1:qIASSok+9dhKPrfAZmFreIdpgBgKTfXwkM9CQ+tNM90= -k8s.io/metrics v0.27.1/go.mod h1:5sYmQTC3aeL/24kkJ5fYECVuIz0xhO6oipfGJ81JC1Y= +k8s.io/kubectl v0.26.1 h1:K8A0Jjlwg8GqrxOXxAbjY5xtmXYeYjLU96cHp2WMQ7s= +k8s.io/kubectl v0.26.1/go.mod h1:miYFVzldVbdIiXMrHZYmL/EDWwJKM+F0sSsdxsATFPo= +k8s.io/metrics v0.26.2 h1:2gUvUWWnHPdE2tyA5DvyHC8HGryr+izhY9i5dzLP06s= +k8s.io/metrics v0.26.2/go.mod h1:PX1wm9REV9hSGuw9GcXTFNDgab1KRXck3mNeiLYbRho= k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 h1:kmDqav+P+/5e1i9tFfHq1qcF3sOrDp+YEkVDAHu7Jwk= k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= oras.land/oras-go v1.2.2 h1:0E9tOHUfrNH7TCDk5KU0jVBEzCqbfdyuVfGmJ7ZeRPE= diff --git a/internal/config/styles.go b/internal/config/styles.go index a5fa6b691e..e05e9fcd39 100644 --- a/internal/config/styles.go +++ b/internal/config/styles.go @@ -61,13 +61,16 @@ type ( // Body tracks body styles. Body struct { - FgColor Color `yaml:"fgColor"` - BgColor Color `yaml:"bgColor"` - LogoColor Color `yaml:"logoColor"` - LogoColorMsg Color `yaml:"logoColorMsg"` - LogoColorInfo Color `yaml:"logoColorInfo"` - LogoColorWarn Color `yaml:"logoColorWarn"` - LogoColorError Color `yaml:"logoColorError"` + FgColor Color `yaml:"fgColor"` + BgColor Color `yaml:"bgColor"` + LogoColor Color `yaml:"logoColor"` + LogoColorMsg Color `yaml:"logoColorMsg"` + LogoColorInfo Color `yaml:"logoColorInfo"` + LogoColorWarn Color `yaml:"logoColorWarn"` + LogoColorError Color `yaml:"logoColorError"` + FlashColorOk Color `yaml:"flashColorOk"` + FlashColorWarn Color `yaml:"flashColorWarn"` + FlashColorError Color `yaml:"flashColorError"` } // Dialog tracks dialog styles. @@ -80,6 +83,7 @@ type ( ButtonFocusBgColor Color `yaml:"buttonFocusBgColor"` LabelFgColor Color `yaml:"labelFgColor"` FieldFgColor Color `yaml:"fieldFgColor"` + ErrorColor Color `yaml:"errorColor"` } // Frame tracks frame styles. @@ -279,6 +283,7 @@ func newDialog() Dialog { ButtonFocusFgColor: "black", LabelFgColor: "white", FieldFgColor: "white", + ErrorColor: "orangered", } } @@ -336,13 +341,16 @@ func newHelp() Help { func newBody() Body { return Body{ - FgColor: "cadetblue", - BgColor: "black", - LogoColor: "orange", - LogoColorMsg: "white", - LogoColorInfo: "green", - LogoColorWarn: "mediumvioletred", - LogoColorError: "red", + FgColor: "cadetblue", + BgColor: "black", + LogoColor: "orange", + LogoColorMsg: "white", + LogoColorInfo: "green", + LogoColorWarn: "mediumvioletred", + LogoColorError: "red", + FlashColorOk: "green", + FlashColorWarn: "yellow", + FlashColorError: "red", } } @@ -480,6 +488,21 @@ func (s *Styles) BgColor() tcell.Color { return s.Body().BgColor.Color() } +// FlashColorOk returns the color in combination with happy emoji. +func (s *Styles) FlashColorOk() tcell.Color { + return s.Body().FlashColorOk.Color() +} + +// FlashColorWarn returns the color in combination with warn emoji. +func (s *Styles) FlashColorWarn() tcell.Color { + return s.Body().FlashColorWarn.Color() +} + +// FlashColorWarn returns the color in combination with angry emoji. +func (s *Styles) FlashColorError() tcell.Color { + return s.Body().FlashColorError.Color() +} + // AddListener registers a new listener. func (s *Styles) AddListener(l StyleListener) { s.listeners = append(s.listeners, l) diff --git a/internal/render/benchmark.go b/internal/render/benchmark.go index 2b60cff68c..1642bc1105 100644 --- a/internal/render/benchmark.go +++ b/internal/render/benchmark.go @@ -9,7 +9,6 @@ import ( "strings" "github.com/derailed/k9s/internal/client" - "github.com/derailed/tcell/v2" "github.com/derailed/tview" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,12 +29,7 @@ type Benchmark struct { // ColorerFunc colors a resource row. func (b Benchmark) ColorerFunc() ColorerFunc { - return func(ns string, h Header, re RowEvent) tcell.Color { - if !Happy(ns, h, re.Row) { - return ErrColor - } - return tcell.ColorPaleGreen - } + return DefaultColorer } // Header returns a header row. diff --git a/internal/render/dir.go b/internal/render/dir.go index 6c50c17d04..f8445a3fe9 100644 --- a/internal/render/dir.go +++ b/internal/render/dir.go @@ -4,7 +4,6 @@ import ( "fmt" "os" - "github.com/derailed/tcell/v2" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -19,9 +18,7 @@ func (Dir) IsGeneric() bool { // ColorerFunc colors a resource row. func (Dir) ColorerFunc() ColorerFunc { - return func(ns string, _ Header, re RowEvent) tcell.Color { - return tcell.ColorCadetBlue - } + return DefaultColorer } // Header returns a header row. diff --git a/internal/render/helm.go b/internal/render/helm.go index 2d2e0d7707..62b6647fb8 100644 --- a/internal/render/helm.go +++ b/internal/render/helm.go @@ -5,7 +5,6 @@ import ( "strconv" "github.com/derailed/k9s/internal/client" - "github.com/derailed/tcell/v2" "helm.sh/helm/v3/pkg/release" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -22,13 +21,7 @@ func (Helm) IsGeneric() bool { // ColorerFunc colors a resource row. func (Helm) ColorerFunc() ColorerFunc { - return func(ns string, h Header, re RowEvent) tcell.Color { - if !Happy(ns, h, re.Row) { - return ErrColor - } - - return tcell.ColorMediumSpringGreen - } + return DefaultColorer } // Header returns a header row. diff --git a/internal/render/pod.go b/internal/render/pod.go index 984a9da92c..bfbb8c1759 100644 --- a/internal/render/pod.go +++ b/internal/render/pod.go @@ -5,6 +5,7 @@ import ( "strconv" "strings" + "github.com/derailed/k9s/internal/client" "github.com/derailed/tcell/v2" "github.com/derailed/tview" v1 "k8s.io/api/core/v1" @@ -13,8 +14,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" mv1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1" - - "github.com/derailed/k9s/internal/client" ) // Pod renders a K8s Pod to screen. @@ -107,7 +106,7 @@ func (p Pod) Render(o interface{}, ns string, row *Row) error { po.Namespace, po.ObjectMeta.Name, "●", - strconv.Itoa(cr) + "/" + strconv.Itoa(len(po.Spec.Containers)), + strconv.Itoa(cr) + "/" + strconv.Itoa(len(ss)), strconv.Itoa(rc), phase, toMc(c.cpu), diff --git a/internal/render/policy.go b/internal/render/policy.go index 9f3ff91941..19f7d9d211 100644 --- a/internal/render/policy.go +++ b/internal/render/policy.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/derailed/k9s/internal/client" - "github.com/derailed/tcell/v2" "github.com/rs/zerolog/log" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,9 +30,7 @@ type Policy struct { // ColorerFunc colors a resource row. func (Policy) ColorerFunc() ColorerFunc { - return func(ns string, _ Header, re RowEvent) tcell.Color { - return tcell.ColorMediumSpringGreen - } + return DefaultColorer } // Header returns a header row. diff --git a/internal/render/portforward.go b/internal/render/portforward.go index 2a039acf93..765f72c0da 100644 --- a/internal/render/portforward.go +++ b/internal/render/portforward.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/derailed/k9s/internal/client" - "github.com/derailed/tcell/v2" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -35,9 +34,7 @@ type PortForward struct { // ColorerFunc colors a resource row. func (PortForward) ColorerFunc() ColorerFunc { - return func(ns string, _ Header, re RowEvent) tcell.Color { - return tcell.ColorSkyblue - } + return DefaultColorer } // Header returns a header row. diff --git a/internal/render/reference.go b/internal/render/reference.go index 33b8493c09..52b3175b08 100644 --- a/internal/render/reference.go +++ b/internal/render/reference.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/derailed/k9s/internal/client" - "github.com/derailed/tcell/v2" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -16,9 +15,7 @@ type Reference struct { // ColorerFunc colors a resource row. func (Reference) ColorerFunc() ColorerFunc { - return func(ns string, _ Header, re RowEvent) tcell.Color { - return tcell.ColorCadetBlue - } + return DefaultColorer } // Header returns a header row. diff --git a/internal/render/screen_dump.go b/internal/render/screen_dump.go index 230303a1bf..d659e5186e 100644 --- a/internal/render/screen_dump.go +++ b/internal/render/screen_dump.go @@ -6,7 +6,6 @@ import ( "path/filepath" "time" - "github.com/derailed/tcell/v2" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -18,9 +17,7 @@ type ScreenDump struct { // ColorerFunc colors a resource row. func (ScreenDump) ColorerFunc() ColorerFunc { - return func(ns string, _ Header, re RowEvent) tcell.Color { - return tcell.ColorNavajoWhite - } + return DefaultColorer } // Header returns a header row. diff --git a/internal/render/subject.go b/internal/render/subject.go index 07b5c54867..c6d1ea4e36 100644 --- a/internal/render/subject.go +++ b/internal/render/subject.go @@ -3,7 +3,6 @@ package render import ( "fmt" - "github.com/derailed/tcell/v2" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -15,9 +14,7 @@ type Subject struct { // ColorerFunc colors a resource row. func (Subject) ColorerFunc() ColorerFunc { - return func(ns string, _ Header, re RowEvent) tcell.Color { - return tcell.ColorMediumSpringGreen - } + return DefaultColorer } // Header returns a header row. diff --git a/internal/ui/config.go b/internal/ui/config.go index c655be0f2d..23a6c195ca 100644 --- a/internal/ui/config.go +++ b/internal/ui/config.go @@ -2,9 +2,7 @@ package ui import ( "context" - "errors" "fmt" - "os" "path/filepath" "github.com/derailed/k9s/internal/config" @@ -133,22 +131,14 @@ func (c *Configurator) RefreshStyles(context string) { c.Styles.Reset() } if err := c.Styles.Load(clusterSkins); err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warn().Msgf("No context specific skin file found -- %s", clusterSkins) - } else { - log.Error().Msgf("Failed to parse context specific skin file -- %s. %s.", clusterSkins, err) - } + log.Warn().Msgf("No context specific skin file found -- %s", clusterSkins) } else { c.updateStyles(clusterSkins) return } if err := c.Styles.Load(config.K9sStylesFile); err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warn().Msgf("No skin file found -- %s. Loading stock skins.", config.K9sStylesFile) - } else { - log.Error().Msgf("Failed to parse skin file -- %s. %s. Loading stock skins.", config.K9sStylesFile, err) - } + log.Warn().Msgf("No skin file found -- %s. Loading stock skins.", config.K9sStylesFile) c.updateStyles("") return } diff --git a/internal/ui/dialog/error.go b/internal/ui/dialog/error.go index f39e31fd36..f746187fad 100644 --- a/internal/ui/dialog/error.go +++ b/internal/ui/dialog/error.go @@ -6,7 +6,6 @@ import ( "github.com/derailed/k9s/internal/config" "github.com/derailed/k9s/internal/ui" - "github.com/derailed/tcell/v2" "github.com/derailed/tview" ) @@ -18,7 +17,7 @@ func ShowError(styles config.Dialog, pages *ui.Pages, msg string) { SetButtonBackgroundColor(styles.ButtonBgColor.Color()). SetButtonTextColor(styles.ButtonFgColor.Color()). SetLabelColor(styles.LabelFgColor.Color()). - SetFieldTextColor(tcell.ColorIndianRed) + SetFieldTextColor(styles.FieldFgColor.Color()) f.AddButton("Dismiss", func() { dismiss(pages) }) @@ -29,7 +28,7 @@ func ShowError(styles config.Dialog, pages *ui.Pages, msg string) { f.SetFocus(0) modal := tview.NewModalForm("", f) modal.SetText(cowTalk(msg)) - modal.SetTextColor(tcell.ColorOrangeRed) + modal.SetTextColor(styles.ErrorColor.Color()) modal.SetDoneFunc(func(int, string) { dismiss(pages) }) diff --git a/internal/ui/flash.go b/internal/ui/flash.go index 7455a1321f..0bd767d621 100644 --- a/internal/ui/flash.go +++ b/internal/ui/flash.go @@ -30,7 +30,7 @@ func NewFlash(app *App) *Flash { app: app, TextView: tview.NewTextView(), } - f.SetTextColor(tcell.ColorAqua) + f.SetDynamicColors(true) f.SetTextAlign(tview.AlignCenter) f.SetBorderPadding(0, 0, 1, 1) @@ -70,7 +70,7 @@ func (f *Flash) SetMessage(m model.LevelMessage) { f.Clear() return } - f.SetTextColor(flashColor(m.Level)) + f.SetTextColor(f.flashColor(m.Level)) f.SetText(f.flashEmoji(m.Level) + " " + m.Text) } @@ -98,14 +98,16 @@ func (f *Flash) flashEmoji(l model.FlashLevel) string { // Helpers... -func flashColor(l model.FlashLevel) tcell.Color { +func (f *Flash) flashColor(l model.FlashLevel) tcell.Color { + styles := f.app.Styles + // nolint:exhaustive switch l { case model.FlashWarn: - return tcell.ColorOrange + return styles.FlashColorWarn() case model.FlashErr: - return tcell.ColorOrangeRed + return styles.FlashColorError() default: - return tcell.ColorNavajoWhite + return styles.FlashColorOk() } } diff --git a/internal/ui/indicator.go b/internal/ui/indicator.go index cdcabdb751..2f1ab837ca 100644 --- a/internal/ui/indicator.go +++ b/internal/ui/indicator.go @@ -8,7 +8,6 @@ import ( "github.com/derailed/k9s/internal/config" "github.com/derailed/k9s/internal/model" "github.com/derailed/k9s/internal/render" - "github.com/derailed/tcell/v2" "github.com/derailed/tview" ) @@ -30,7 +29,7 @@ func NewStatusIndicator(app *App, styles *config.Styles) *StatusIndicator { styles: styles, } s.SetTextAlign(tview.AlignCenter) - s.SetTextColor(tcell.ColorWhite) + s.SetTextColor(styles.FgColor()) s.SetBackgroundColor(styles.BgColor()) s.SetDynamicColors(true) styles.AddListener(&s) diff --git a/internal/ui/table.go b/internal/ui/table.go index ad0ea4b440..0148be1c7f 100644 --- a/internal/ui/table.go +++ b/internal/ui/table.go @@ -71,7 +71,6 @@ func (t *Table) Init(ctx context.Context) { t.SetBorderPadding(0, 0, 1, 1) t.SetSelectable(true, false) t.SetSelectionChangedFunc(t.selectionChanged) - t.SetBackgroundColor(tcell.ColorDefault) t.Select(1, 0) if cfg, ok := ctx.Value(internal.KeyViewConfig).(*config.CustomView); ok && cfg != nil { cfg.AddListener(t.GVR().String(), t) diff --git a/internal/ui/tree.go b/internal/ui/tree.go index c62416206c..0b03baefce 100644 --- a/internal/ui/tree.go +++ b/internal/ui/tree.go @@ -40,7 +40,6 @@ func (t *Tree) Init(ctx context.Context) error { t.SetBorderAttributes(tcell.AttrBold) t.SetBorderPadding(0, 0, 1, 1) t.SetGraphics(true) - t.SetGraphicsColor(tcell.ColorCadetBlue) t.SetInputCapture(t.keyboard) return nil diff --git a/internal/view/alias.go b/internal/view/alias.go index c31623e876..fc99b2fa8f 100644 --- a/internal/view/alias.go +++ b/internal/view/alias.go @@ -22,8 +22,6 @@ func NewAlias(gvr client.GVR) ResourceViewer { a := Alias{ ResourceViewer: NewBrowser(gvr), } - a.GetTable().SetBorderFocusColor(tcell.ColorAliceBlue) - a.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorAliceBlue).Attributes(tcell.AttrNone)) a.AddBindKeysFn(a.bindKeys) a.SetContextFn(a.aliasContext) diff --git a/internal/view/benchmark.go b/internal/view/benchmark.go index bd6a8b900b..7416658b2e 100644 --- a/internal/view/benchmark.go +++ b/internal/view/benchmark.go @@ -11,7 +11,6 @@ import ( "github.com/derailed/k9s/internal/config" "github.com/derailed/k9s/internal/perf" "github.com/derailed/k9s/internal/ui" - "github.com/derailed/tcell/v2" ) // Benchmark represents a service benchmark results view. @@ -24,8 +23,6 @@ func NewBenchmark(gvr client.GVR) ResourceViewer { b := Benchmark{ ResourceViewer: NewBrowser(gvr), } - b.GetTable().SetBorderFocusColor(tcell.ColorSeaGreen) - b.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorSeaGreen).Attributes(tcell.AttrNone)) b.GetTable().SetSortCol(ageCol, true) b.SetContextFn(b.benchContext) b.GetTable().SetEnterFn(b.viewBench) diff --git a/internal/view/context.go b/internal/view/context.go index fd57b741e4..c0e79dc901 100644 --- a/internal/view/context.go +++ b/internal/view/context.go @@ -78,22 +78,26 @@ func (c *Context) showRenameModal(a *App, name string, ok func(form *tview.Form, p.RemovePage(renamePage) }) m := tview.NewModalForm("", f) + m.SetText(fmt.Sprintf("Rename context %q?", name)) m.SetDoneFunc(func(int, string) { p.RemovePage(renamePage) }) + p.AddPage(renamePage, m, false, false) p.ShowPage(renamePage) } func (c *Context) makeStyledForm() *tview.Form { f := tview.NewForm() + styles := c.App().Styles.Dialog() + f.SetItemPadding(0) f.SetButtonsAlign(tview.AlignCenter). - SetButtonBackgroundColor(tview.Styles.PrimitiveBackgroundColor). - SetButtonTextColor(tview.Styles.PrimaryTextColor). - SetLabelColor(tcell.ColorAqua). - SetFieldTextColor(tcell.ColorOrange) + SetButtonBackgroundColor(styles.ButtonBgColor.Color()). + SetButtonTextColor(styles.ButtonFgColor.Color()). + SetLabelColor(styles.LabelFgColor.Color()). + SetFieldTextColor(styles.FieldFgColor.Color()) return f } @@ -124,6 +128,6 @@ func useContext(app *App, name string) error { log.Error().Err(err).Msgf("Context switch failed") return err } - + return app.switchContext(name) } diff --git a/internal/view/cow.go b/internal/view/cow.go index 140faf99bb..bde6568d89 100644 --- a/internal/view/cow.go +++ b/internal/view/cow.go @@ -36,8 +36,6 @@ func (c *Cow) Init(_ context.Context) error { c.SetBorder(true) c.SetScrollable(true).SetWrap(true).SetRegions(true) c.SetDynamicColors(true) - c.SetHighlightColor(tcell.ColorOrange) - c.SetTitleColor(tcell.ColorAqua) c.SetInputCapture(c.keyboard) c.SetBorderPadding(0, 0, 1, 1) c.updateTitle() diff --git a/internal/view/cronjob.go b/internal/view/cronjob.go index cb265a3500..90be5493dd 100644 --- a/internal/view/cronjob.go +++ b/internal/view/cronjob.go @@ -11,7 +11,6 @@ import ( "github.com/derailed/k9s/internal/ui" "github.com/derailed/k9s/internal/ui/dialog" "github.com/derailed/tcell/v2" - "github.com/derailed/tview" "github.com/rs/zerolog/log" batchv1 "k8s.io/api/batch/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -106,90 +105,53 @@ func (c *CronJob) triggerCmd(evt *tcell.EventKey) *tcell.EventKey { } func (c *CronJob) toggleSuspendCmd(evt *tcell.EventKey) *tcell.EventKey { - sel := c.GetTable().GetSelectedItem() - if sel == "" { + table := c.GetTable() + fqn := table.GetSelectedItem() + + if fqn == "" { return evt } - c.Stop() - defer c.Start() - c.showSuspendDialog(sel) - - return nil -} + cell := table.GetCell(c.GetTable().GetSelectedRowIndex(), c.GetTable().NameColIndex()+2) -func (c *CronJob) showSuspendDialog(sel string) { - cell := c.GetTable().GetCell(c.GetTable().GetSelectedRowIndex(), c.GetTable().NameColIndex()+2) if cell == nil { c.App().Flash().Errf("Unable to assert current status") - return + return nil } + suspended := strings.TrimSpace(cell.Text) == defaultSuspendStatus title := "Suspend" + if suspended { title = "Resume" } - confirm := tview.NewModalForm(fmt.Sprintf("<%s>", title), c.makeSuspendForm(sel, !suspended)) - confirm.SetText(fmt.Sprintf("%s CronJob %s?", title, sel)) - confirm.SetDoneFunc(func(int, string) { - c.dismissDialog() - }) - c.App().Content.AddPage(suspendDialogKey, confirm, false, false) - c.App().Content.ShowPage(suspendDialogKey) -} - -func (c *CronJob) makeSuspendForm(sel string, suspend bool) *tview.Form { - f := c.makeStyledForm() - action := "suspended" - if !suspend { - action = "resumed" - } + c.Stop() + defer c.Start() - f.AddButton("Cancel", func() { - c.dismissDialog() - }) - f.AddButton("OK", func() { - defer c.dismissDialog() + msg := fmt.Sprintf("%s %s?", title, fqn) + dialog.ShowConfirm(c.App().Styles.Dialog(), c.App().Content.Pages, title, msg, func() { ctx, cancel := context.WithTimeout(context.Background(), c.App().Conn().Config().CallTimeout()) defer cancel() - if err := c.toggleSuspend(ctx, sel); err != nil { - log.Error().Err(err).Msgf("CronJob %s %s failed", sel, action) - c.App().Flash().Err(err) - } else { - c.App().Flash().Infof("CronJob %s %s successfully!", sel, action) - } - }) - return f -} - -func (c *CronJob) toggleSuspend(ctx context.Context, path string) error { - res, err := dao.AccessorFor(c.App().factory, c.GVR()) - if err != nil { - return err - } - cronJob, ok := res.(*dao.CronJob) - if !ok { - return fmt.Errorf("expecting a scalable resource for %q", c.GVR()) - } - - return cronJob.ToggleSuspend(ctx, path) -} + res, err := dao.AccessorFor(c.App().factory, c.GVR()) + if err != nil { + c.App().Flash().Err(fmt.Errorf("no accessor for %q", c.GVR())) + return + } -func (c *CronJob) makeStyledForm() *tview.Form { - f := tview.NewForm() - f.SetItemPadding(0) - f.SetButtonsAlign(tview.AlignCenter). - SetButtonBackgroundColor(tview.Styles.PrimitiveBackgroundColor). - SetButtonTextColor(tview.Styles.PrimaryTextColor). - SetLabelColor(tcell.ColorAqua). - SetFieldTextColor(tcell.ColorOrange) + cronJob, ok := res.(*dao.CronJob) + if !ok { + c.App().Flash().Errf("expecting a cron job for %q", c.GVR()) + return + } - return f -} + if err := cronJob.ToggleSuspend(ctx, fqn); err != nil { + c.App().Flash().Errf("Cronjob %s failed for %v", strings.ToLower(title), err) + return + } + }, func() {}) -func (c *CronJob) dismissDialog() { - c.App().Content.RemovePage(suspendDialogKey) + return nil } diff --git a/internal/view/details.go b/internal/view/details.go index d65485a2dc..0d3acfbdb4 100644 --- a/internal/view/details.go +++ b/internal/view/details.go @@ -54,10 +54,9 @@ func (d *Details) Init(_ context.Context) error { if d.title != "" { d.SetBorder(true) } + d.text.SetScrollable(true).SetWrap(true).SetRegions(true) d.text.SetDynamicColors(true) - d.text.SetHighlightColor(tcell.ColorOrange) - d.SetTitleColor(tcell.ColorAqua) d.SetInputCapture(d.keyboard) d.SetBorderPadding(0, 0, 1, 1) d.updateTitle() diff --git a/internal/view/dir.go b/internal/view/dir.go index a16f91372e..a1e00068d8 100644 --- a/internal/view/dir.go +++ b/internal/view/dir.go @@ -37,8 +37,7 @@ func NewDir(path string) ResourceViewer { ResourceViewer: NewBrowser(client.NewGVR("dir")), path: path, } - d.GetTable().SetBorderFocusColor(tcell.ColorAliceBlue) - d.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorAliceBlue).Attributes(tcell.AttrNone)) + d.AddBindKeysFn(d.bindKeys) d.SetContextFn(d.dirContext) @@ -229,23 +228,13 @@ func (d *Dir) delCmd(evt *tcell.EventKey) *tcell.EventKey { return evt } - opts := []string{"-f"} - msgRessource := "manifest" - if containsDir(sel) { - opts = append(opts, "-R") - } - if isKustomized(sel) { - opts = []string{"-k"} - msgRessource = "kustomization" - } - d.Stop() defer d.Start() - msg := fmt.Sprintf("Delete resource(s) in %s %s", msgRessource, sel) + msg := fmt.Sprintf("Delete resource(s) in manifest %s", sel) dialog.ShowConfirm(d.App().Styles.Dialog(), d.App().Content.Pages, "Confirm Delete", msg, func() { args := make([]string, 0, 10) args = append(args, "delete") - args = append(args, opts...) + args = append(args, "-f") args = append(args, sel) res, err := runKu(d.App(), shellOpts{clear: false, args: args}) if err != nil { diff --git a/internal/view/helm.go b/internal/view/helm.go index 6e6e296880..4e055dc9fa 100644 --- a/internal/view/helm.go +++ b/internal/view/helm.go @@ -23,8 +23,7 @@ func NewHelm(gvr client.GVR) ResourceViewer { c := Helm{ ResourceViewer: NewBrowser(gvr), } - c.GetTable().SetBorderFocusColor(tcell.ColorMediumSpringGreen) - c.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorMediumSpringGreen).Attributes(tcell.AttrNone)) + c.AddBindKeysFn(c.bindKeys) c.SetContextFn(c.chartContext) diff --git a/internal/view/image_extender.go b/internal/view/image_extender.go index 64f953a948..88b3c42d86 100644 --- a/internal/view/image_extender.go +++ b/internal/view/image_extender.go @@ -94,7 +94,7 @@ func (s *ImageExtender) showImageDialog(path string) error { } func (s *ImageExtender) makeSetImageForm(sel string) (*tview.Form, error) { - f := s.makeStyledForm() + f := tview.NewForm() podSpec, err := s.getPodSpec(sel) if err != nil { return nil, err @@ -134,6 +134,24 @@ func (s *ImageExtender) makeSetImageForm(sel string) (*tview.Form, error) { s.dismissDialog() }) + styles := s.App().Styles.Dialog() + + f.SetItemPadding(0) + f.SetButtonsAlign(tview.AlignCenter). + SetButtonBackgroundColor(styles.ButtonBgColor.Color()). + SetButtonTextColor(styles.ButtonFgColor.Color()). + SetLabelColor(styles.LabelFgColor.Color()). + SetFieldTextColor(styles.FieldFgColor.Color()) + + for i := 0; i < 2; i++ { + b := f.GetButton(i) + if b == nil { + continue + } + b.SetBackgroundColorActivated(styles.ButtonFocusBgColor.Color()) + b.SetLabelColorActivated(styles.ButtonFocusFgColor.Color()) + } + return f, nil } @@ -141,17 +159,6 @@ func (s *ImageExtender) dismissDialog() { s.App().Content.RemovePage(imageKey) } -func (s *ImageExtender) makeStyledForm() *tview.Form { - f := tview.NewForm() - f.SetItemPadding(0) - f.SetButtonsAlign(tview.AlignCenter). - SetButtonBackgroundColor(tview.Styles.PrimitiveBackgroundColor). - SetButtonTextColor(tview.Styles.PrimaryTextColor). - SetLabelColor(tcell.ColorAqua). - SetFieldTextColor(tcell.ColorOrange) - return f -} - func (s *ImageExtender) getPodSpec(path string) (*corev1.PodSpec, error) { res, err := dao.AccessorFor(s.App().factory, s.GVR()) if err != nil { diff --git a/internal/view/live_view.go b/internal/view/live_view.go index aeefd9cb41..1dab771cf4 100644 --- a/internal/view/live_view.go +++ b/internal/view/live_view.go @@ -59,10 +59,9 @@ func (v *LiveView) Init(_ context.Context) error { if v.title != "" { v.SetBorder(true) } + v.text.SetScrollable(true).SetWrap(true).SetRegions(true) v.text.SetDynamicColors(true) - v.text.SetHighlightColor(tcell.ColorOrange) - v.SetTitleColor(tcell.ColorAqua) v.SetInputCapture(v.keyboard) v.SetBorderPadding(0, 0, 1, 1) v.updateTitle() diff --git a/internal/view/log.go b/internal/view/log.go index bf22e5b3d9..61c0a08ba0 100644 --- a/internal/view/log.go +++ b/internal/view/log.go @@ -173,8 +173,7 @@ func (l *Log) BufferActive(state bool, k model.BufferKind) { // StylesChanged reports skin changes. func (l *Log) StylesChanged(s *config.Styles) { l.SetBackgroundColor(s.Views().Log.BgColor.Color()) - l.logs.SetTextColor(s.Views().Log.FgColor.Color()) - l.logs.SetBackgroundColor(s.Views().Log.BgColor.Color()) + l.logs.StylesChanged(s) } // GetModel returns the log model. diff --git a/internal/view/logger.go b/internal/view/logger.go index 19446dea65..64cd27a735 100644 --- a/internal/view/logger.go +++ b/internal/view/logger.go @@ -37,8 +37,6 @@ func (l *Logger) Init(_ context.Context) error { } l.SetScrollable(true).SetWrap(true) l.SetDynamicColors(true) - l.SetHighlightColor(tcell.ColorOrange) - l.SetTitleColor(tcell.ColorAqua) l.SetInputCapture(l.keyboard) l.SetBorderPadding(0, 0, 1, 1) @@ -85,9 +83,9 @@ func (l *Logger) keyboard(evt *tcell.EventKey) *tcell.EventKey { // StylesChanged notifies the skin changed. func (l *Logger) StylesChanged(s *config.Styles) { - l.SetBackgroundColor(l.app.Styles.BgColor()) - l.SetTextColor(l.app.Styles.FgColor()) - l.SetBorderFocusColor(l.app.Styles.Frame().Border.FocusColor.Color()) + l.SetBackgroundColor(s.Views().Log.BgColor.Color()) + l.SetTextColor(s.Views().Log.FgColor.Color()) + l.SetBackgroundColor(s.Views().Log.BgColor.Color()) } // SetSubject updates the subject. diff --git a/internal/view/pf.go b/internal/view/pf.go index 0d268089b1..8688f02b8d 100644 --- a/internal/view/pf.go +++ b/internal/view/pf.go @@ -12,8 +12,8 @@ import ( "github.com/derailed/k9s/internal/model" "github.com/derailed/k9s/internal/perf" "github.com/derailed/k9s/internal/ui" + "github.com/derailed/k9s/internal/ui/dialog" "github.com/derailed/tcell/v2" - "github.com/derailed/tview" "github.com/rs/zerolog/log" ) @@ -31,8 +31,6 @@ func NewPortForward(gvr client.GVR) ResourceViewer { p := PortForward{ ResourceViewer: NewBrowser(gvr), } - p.GetTable().SetBorderFocusColor(tcell.ColorDodgerBlue) - p.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorDodgerBlue).Attributes(tcell.AttrNone)) p.GetTable().SetSortCol(ageCol, true) p.SetContextFn(p.portForwardContext) p.AddBindKeysFn(p.bindKeys) @@ -142,8 +140,6 @@ func (p *PortForward) deleteCmd(evt *tcell.EventKey) *tcell.EventKey { return evt } - p.Stop() - defer p.Start() var msg string if len(selections) > 1 { msg = fmt.Sprintf("Delete %d marked %s?", len(selections), p.GVR()) @@ -156,18 +152,21 @@ func (p *PortForward) deleteCmd(evt *tcell.EventKey) *tcell.EventKey { return nil } } - showModal(p.App(), msg, func() { + + dialog.ShowConfirm(p.App().Styles.Dialog(), p.App().Content.Pages, "", msg, func() { for _, s := range selections { var pf dao.PortForward pf.Init(p.App().factory, client.NewGVR("portforwards")) + if err := pf.Delete(context.Background(), s, nil, dao.DefaultGrace); err != nil { p.App().Flash().Err(err) return } } + p.App().Flash().Infof("Successfully deleted %d PortForward!", len(selections)) p.GetTable().Refresh() - }) + }, func() {}) return nil } @@ -185,26 +184,3 @@ func pfToHuman(s string) (string, error) { return fmt.Sprintf("%s::%s %s->%s", mm[2], mm[3], mm[4], mm[5]), nil } - -func showModal(a *App, msg string, ok func()) { - p := a.Content.Pages - styles := a.Styles.Dialog() - m := tview.NewModal(). - AddButtons([]string{"Cancel", "OK"}). - SetButtonBackgroundColor(styles.ButtonBgColor.Color()). - SetTextColor(tcell.ColorFuchsia). - SetText(msg). - SetDoneFunc(func(_ int, b string) { - if b == "OK" { - ok() - } - dismissModal(p) - }) - m.SetTitle("") - p.AddPage(promptPage, m, false, false) - p.ShowPage(promptPage) -} - -func dismissModal(p *ui.Pages) { - p.RemovePage(promptPage) -} diff --git a/internal/view/popeye.go b/internal/view/popeye.go index 8a92eb6d36..fd3e72ca68 100644 --- a/internal/view/popeye.go +++ b/internal/view/popeye.go @@ -23,8 +23,6 @@ func NewPopeye(gvr client.GVR) ResourceViewer { p := Popeye{ ResourceViewer: NewBrowser(gvr), } - p.GetTable().SetBorderFocusColor(tcell.ColorMediumSpringGreen) - p.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorMediumSpringGreen).Attributes(tcell.AttrNone)) p.GetTable().SetSortCol("SCORE%", true) p.GetTable().SetDecorateFn(p.decorateRows) p.AddBindKeysFn(p.bindKeys) diff --git a/internal/view/reference.go b/internal/view/reference.go index b8ed13bdf1..31221340fd 100644 --- a/internal/view/reference.go +++ b/internal/view/reference.go @@ -18,8 +18,7 @@ func NewReference(gvr client.GVR) ResourceViewer { r := Reference{ ResourceViewer: NewBrowser(gvr), } - r.GetTable().SetBorderFocusColor(tcell.ColorMediumSpringGreen) - r.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorMediumSpringGreen).Attributes(tcell.AttrNone)) + r.AddBindKeysFn(r.bindKeys) return &r diff --git a/internal/view/rs.go b/internal/view/rs.go index 14fd11ef54..9f0567007e 100644 --- a/internal/view/rs.go +++ b/internal/view/rs.go @@ -81,7 +81,7 @@ func (r *ReplicaSet) showModal(msg string, done func(int, string)) { confirm := tview.NewModal(). AddButtons([]string{"Cancel", "OK"}). SetButtonBackgroundColor(styles.ButtonBgColor.Color()). - SetTextColor(tcell.ColorFuchsia). + SetTextColor(styles.ButtonFgColor.Color()). SetText(msg). SetDoneFunc(done) r.App().Content.AddPage("confirm", confirm, false, false) diff --git a/internal/view/scale_extender.go b/internal/view/scale_extender.go index 15754d1c71..bb9ebc2419 100644 --- a/internal/view/scale_extender.go +++ b/internal/view/scale_extender.go @@ -59,6 +59,7 @@ func (s *ScaleExtender) showScaleDialog(paths []string) { if len(paths) > 1 { msg = fmt.Sprintf("Scale [%d] %s?", len(paths), s.GVR().R()) } + confirm.SetText(msg) confirm.SetDoneFunc(func(int, string) { s.dismissDialog() @@ -76,7 +77,15 @@ func (s *ScaleExtender) valueOf(col string) (string, error) { } func (s *ScaleExtender) makeScaleForm(sels []string) (*tview.Form, error) { - f := s.makeStyledForm() + f := tview.NewForm() + styles := s.App().Styles.Dialog() + + f.SetItemPadding(0) + f.SetButtonsAlign(tview.AlignCenter). + SetButtonBackgroundColor(styles.ButtonBgColor.Color()). + SetButtonTextColor(styles.ButtonFgColor.Color()). + SetLabelColor(styles.LabelFgColor.Color()). + SetFieldTextColor(styles.FieldFgColor.Color()) factor := "0" if len(sels) == 1 { @@ -124,6 +133,15 @@ func (s *ScaleExtender) makeScaleForm(sels []string) (*tview.Form, error) { s.dismissDialog() }) + for i := 0; i < f.GetButtonCount(); i++ { + b := f.GetButton(i) + if b == nil { + continue + } + b.SetBackgroundColorActivated(styles.ButtonFocusBgColor.Color()) + b.SetLabelColorActivated(styles.ButtonFocusFgColor.Color()) + } + return f, nil } @@ -131,18 +149,6 @@ func (s *ScaleExtender) dismissDialog() { s.App().Content.RemovePage(scaleDialogKey) } -func (s *ScaleExtender) makeStyledForm() *tview.Form { - f := tview.NewForm() - f.SetItemPadding(0) - f.SetButtonsAlign(tview.AlignCenter). - SetButtonBackgroundColor(tview.Styles.PrimitiveBackgroundColor). - SetButtonTextColor(tview.Styles.PrimaryTextColor). - SetLabelColor(tcell.ColorAqua). - SetFieldTextColor(tcell.ColorOrange) - - return f -} - func (s *ScaleExtender) scale(ctx context.Context, path string, replicas int) error { res, err := dao.AccessorFor(s.App().factory, s.GVR()) if err != nil { diff --git a/internal/view/screen_dump.go b/internal/view/screen_dump.go index 940588cb97..0fbc52fc2a 100644 --- a/internal/view/screen_dump.go +++ b/internal/view/screen_dump.go @@ -9,7 +9,6 @@ import ( "github.com/derailed/k9s/internal/client" "github.com/derailed/k9s/internal/config" "github.com/derailed/k9s/internal/ui" - "github.com/derailed/tcell/v2" "github.com/rs/zerolog/log" ) @@ -23,8 +22,6 @@ func NewScreenDump(gvr client.GVR) ResourceViewer { s := ScreenDump{ ResourceViewer: NewBrowser(gvr), } - s.GetTable().SetBorderFocusColor(tcell.ColorSteelBlue) - s.GetTable().SetSelectedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorRoyalBlue).Attributes(tcell.AttrNone)) s.GetTable().SetSortCol(ageCol, true) s.GetTable().SelectRow(1, true) s.GetTable().SetEnterFn(s.edit) diff --git a/internal/view/user.go b/internal/view/user.go index ab7d9bea50..aaa06a32ee 100644 --- a/internal/view/user.go +++ b/internal/view/user.go @@ -3,11 +3,10 @@ package view import ( "context" - "github.com/derailed/tcell/v2" - "github.com/derailed/k9s/internal" "github.com/derailed/k9s/internal/client" "github.com/derailed/k9s/internal/ui" + "github.com/derailed/tcell/v2" ) // User presents a user viewer. @@ -25,7 +24,7 @@ func NewUser(gvr client.GVR) ResourceViewer { } func (u *User) bindKeys(aa ui.KeyActions) { - aa.Delete(ui.KeyShiftA, ui.KeyShiftP, tcell.KeyCtrlSpace, ui.KeySpace, tcell.KeyCtrlD, ui.KeyE) + aa.Delete(ui.KeyShiftA, ui.KeyShiftP, tcell.KeyCtrlSpace, ui.KeySpace) aa.Add(ui.KeyActions{ tcell.KeyEnter: ui.NewKeyAction("Rules", u.policyCmd, true), ui.KeyShiftK: ui.NewKeyAction("Sort Kind", u.GetTable().SortColCmd("KIND", true), false), diff --git a/skins/dracula.yml b/skins/dracula.yml index 6df70e8a2f..41ca3b0a29 100644 --- a/skins/dracula.yml +++ b/skins/dracula.yml @@ -112,4 +112,4 @@ k9s: fgColor: *foreground bgColor: *purple toggleOnColor: *green - toggleOffColor: *cyan \ No newline at end of file + toggleOffColor: *blue \ No newline at end of file