Skip to content

Commit d0f874e

Browse files
authored
K9s/release v0.30.8 (#2427)
* [Bug] Fix #2418 * cleaning up * rel notes
1 parent 1c19ef6 commit d0f874e

14 files changed

+98
-48
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ DATE ?= $(shell TZ=UTC date -j -f "%s" ${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:
1111
else
1212
DATE ?= $(shell date -u -d @${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:%M:%SZ")
1313
endif
14-
VERSION ?= v0.30.7
14+
VERSION ?= v0.30.8
1515
IMG_NAME := derailed/k9s
1616
IMAGE := ${IMG_NAME}:${VERSION}
1717

change_logs/release_v0.30.8.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s.png" align="center" width="800" height="auto"/>
2+
3+
# Release v0.30.8
4+
5+
## Notes
6+
7+
Thank you to all that contributed with flushing out issues and enhancements for K9s!
8+
I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev
9+
and see if we're happier with some of the fixes!
10+
If you've filed an issue please help me verify and close.
11+
12+
Your support, kindness and awesome suggestions to make K9s better are, as ever, very much noted and appreciated!
13+
Also big thanks to all that have allocated their own time to help others on both slack and on this repo!!
14+
15+
As you may know, K9s is not pimped out by corps with deep pockets, thus if you feel K9s is helping your Kubernetes journey,
16+
please consider joining our [sponsorship program](https://github.com/sponsors/derailed) and/or make some noise on social! [@kitesurfer](https://twitter.com/kitesurfer)
17+
18+
On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/enQtOTA5MDEyNzI5MTU0LWQ1ZGI3MzliYzZhZWEyNzYxYzA3NjE0YTk1YmFmNzViZjIyNzhkZGI0MmJjYzhlNjdlMGJhYzE2ZGU1NjkyNTM)
19+
20+
## Maintenance Release!
21+
22+
Thank you all for pitching in and helping flesh out issues!!
23+
24+
---
25+
26+
## Videos Are In The Can!
27+
28+
Please dial [K9s Channel](https://www.youtube.com/channel/UC897uwPygni4QIjkPCpgjmw) for up coming content...
29+
30+
* [K9s v0.30.0 Sneak peek](https://youtu.be/mVBc1XneRJ4)
31+
* [Vulnerability Scans](https://youtu.be/ULkl0MsaidU)
32+
33+
---
34+
35+
## Resolved Issues
36+
37+
* [#2423](https://github.com/derailed/k9s/issues/2423) CPU and MEM counters of AKS clusters show not available
38+
* [#2418](https://github.com/derailed/k9s/issues/2418) Boom! runtime error: invalid memory address or nil pointer dereference
39+
40+
---
41+
42+
## Contributed PRs
43+
44+
Please be sure to give `Big Thanks!` and `ATTA Girls/Boys!` to all the fine contributors for making K9s better for all of us!!
45+
46+
* [#2424](https://github.com/derailed/k9s/pull/2424) fix the check for whether the cluster supports metrics
47+
48+
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2023 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

internal/config/data/context.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (c *Context) Validate(conn client.Connection, ks KubeSettings) {
5454
if c.Namespace == nil {
5555
c.Namespace = NewNamespace()
5656
}
57-
c.Namespace.Validate(conn, ks)
57+
c.Namespace.Validate(conn)
5858

5959
if c.View == nil {
6060
c.View = NewView()

internal/config/data/ns.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ type Namespace struct {
2222

2323
// NewNamespace create a new namespace configuration.
2424
func NewNamespace() *Namespace {
25-
return &Namespace{
26-
Active: client.DefaultNamespace,
27-
Favorites: []string{client.DefaultNamespace},
28-
}
25+
return NewActiveNamespace(client.DefaultNamespace)
2926
}
3027

3128
func NewActiveNamespace(n string) *Namespace {
@@ -39,7 +36,7 @@ func NewActiveNamespace(n string) *Namespace {
3936
}
4037

4138
// Validate validates a namespace is setup correctly.
42-
func (n *Namespace) Validate(c client.Connection, ks KubeSettings) {
39+
func (n *Namespace) Validate(c client.Connection) {
4340
if c == nil || !c.IsValidNamespace(n.Active) {
4441
return
4542
}
@@ -56,7 +53,11 @@ func (n *Namespace) SetActive(ns string, ks KubeSettings) error {
5653
if ns == client.BlankNamespace {
5754
ns = client.NamespaceAll
5855
}
59-
n.Active = ns
56+
if n == nil {
57+
n = NewActiveNamespace(ns)
58+
} else {
59+
n.Active = ns
60+
}
6061
if ns != "" && !n.LockFavorites {
6162
n.addFavNS(ns)
6263
}

internal/config/data/ns_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ import (
1313

1414
func TestNSValidate(t *testing.T) {
1515
ns := data.NewNamespace()
16-
ns.Validate(mock.NewMockConnection(), mock.NewMockKubeSettings(makeFlags("cl-1", "ct-1")))
16+
ns.Validate(mock.NewMockConnection())
1717

1818
assert.Equal(t, "default", ns.Active)
1919
assert.Equal(t, []string{"default"}, ns.Favorites)
2020
}
2121

2222
func TestNSValidateMissing(t *testing.T) {
2323
ns := data.NewNamespace()
24-
ns.Validate(mock.NewMockConnection(), mock.NewMockKubeSettings(makeFlags("cl-1", "ct-1")))
24+
ns.Validate(mock.NewMockConnection())
2525

2626
assert.Equal(t, "default", ns.Active)
2727
assert.Equal(t, []string{"default"}, ns.Favorites)
2828
}
2929

3030
func TestNSValidateNoNS(t *testing.T) {
3131
ns := data.NewNamespace()
32-
ns.Validate(mock.NewMockConnection(), mock.NewMockKubeSettings(makeFlags("cl-1", "ct-1")))
32+
ns.Validate(mock.NewMockConnection())
3333

3434
assert.Equal(t, "default", ns.Active)
3535
assert.Equal(t, []string{"default"}, ns.Favorites)
@@ -61,7 +61,7 @@ func TestNSSetActive(t *testing.T) {
6161
func TestNSValidateRmFavs(t *testing.T) {
6262
ns := data.NewNamespace()
6363
ns.Favorites = []string{"default", "fred"}
64-
ns.Validate(mock.NewMockConnection(), mock.NewMockKubeSettings(makeFlags("cl-1", "ct-1")))
64+
ns.Validate(mock.NewMockConnection())
6565

6666
assert.Equal(t, []string{"default", "fred"}, ns.Favorites)
6767
}

internal/config/k9s.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ func (k *K9s) ActiveContextName() string {
163163
// ActiveContext returns the currently active context.
164164
func (k *K9s) ActiveContext() (*data.Context, error) {
165165
if k.activeConfig != nil {
166+
if k.activeConfig.Context == nil {
167+
ct, err := k.ks.CurrentContext()
168+
if err != nil {
169+
return nil, err
170+
}
171+
k.activeConfig.Context = data.NewContextFromConfig(ct)
172+
}
166173
return k.activeConfig.Context, nil
167174
}
168175

@@ -187,6 +194,7 @@ func (k *K9s) ActivateContext(n string) (*data.Context, error) {
187194
}
188195
// If the context specifies a default namespace, use it!
189196
if k.conn != nil {
197+
k.Validate(k.conn, k.ks)
190198
if ns := k.conn.ActiveNamespace(); ns != client.BlankNamespace {
191199
k.activeConfig.Context.Namespace.Active = ns
192200
} else {
@@ -328,17 +336,17 @@ func (k *K9s) Validate(c client.Connection, ks data.KubeSettings) {
328336
if k.ShellPod == nil {
329337
k.ShellPod = NewShellPod()
330338
}
331-
k.ShellPod.Validate(c, ks)
339+
k.ShellPod.Validate()
332340

333341
if k.Logger == nil {
334342
k.Logger = NewLogger()
335343
} else {
336-
k.Logger.Validate(c, ks)
344+
k.Logger.Validate()
337345
}
338346
if k.Thresholds == nil {
339347
k.Thresholds = NewThreshold()
340348
}
341-
k.Thresholds.Validate(c, ks)
349+
k.Thresholds.Validate()
342350

343351
if k.activeConfig != nil {
344352
k.activeConfig.Validate(c, ks)

internal/config/logger.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33

44
package config
55

6-
import (
7-
"github.com/derailed/k9s/internal/client"
8-
"github.com/derailed/k9s/internal/config/data"
9-
)
10-
116
const (
127
// DefaultLoggerTailCount tracks default log tail size.
138
DefaultLoggerTailCount = 100
@@ -39,7 +34,7 @@ func NewLogger() *Logger {
3934
}
4035

4136
// Validate checks thresholds and make sure we're cool. If not use defaults.
42-
func (l *Logger) Validate(_ client.Connection, _ data.KubeSettings) {
37+
func (l *Logger) Validate() {
4338
if l.TailCount <= 0 {
4439
l.TailCount = DefaultLoggerTailCount
4540
}

internal/config/logger_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import (
1212

1313
func TestNewLogger(t *testing.T) {
1414
l := config.NewLogger()
15-
l.Validate(nil, nil)
15+
l.Validate()
1616

1717
assert.Equal(t, int64(100), l.TailCount)
1818
assert.Equal(t, 5000, l.BufferSize)
1919
}
2020

2121
func TestLoggerValidate(t *testing.T) {
2222
var l config.Logger
23-
l.Validate(nil, nil)
23+
l.Validate()
2424

2525
assert.Equal(t, int64(100), l.TailCount)
2626
assert.Equal(t, 5000, l.BufferSize)

internal/config/shell_pod.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
package config
55

66
import (
7-
"github.com/derailed/k9s/internal/client"
8-
"github.com/derailed/k9s/internal/config/data"
97
v1 "k8s.io/api/core/v1"
108
)
119

@@ -37,7 +35,7 @@ func NewShellPod() *ShellPod {
3735
}
3836

3937
// Validate validates the configuration.
40-
func (s *ShellPod) Validate(client.Connection, data.KubeSettings) {
38+
func (s *ShellPod) Validate() {
4139
if s.Image == "" {
4240
s.Image = defaultDockerShellImage
4341
}

internal/config/styles.go

-4
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,6 @@ func (s *Styles) Reset() {
445445
s.K9s = newStyle()
446446
}
447447

448-
// DefaultSkin loads the default skin.
449-
func (s *Styles) DefaultSkin() {
450-
}
451-
452448
// FgColor returns the foreground color.
453449
func (s *Styles) FgColor() tcell.Color {
454450
return s.Body().FgColor.Color()

internal/config/threshold.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33

44
package config
55

6-
import (
7-
"github.com/derailed/k9s/internal/client"
8-
"github.com/derailed/k9s/internal/config/data"
9-
)
10-
116
const (
127
// SeverityLow tracks low severity.
138
SeverityLow SeverityLevel = iota
@@ -66,7 +61,7 @@ func NewThreshold() Threshold {
6661
}
6762

6863
// Validate a namespace is setup correctly.
69-
func (t Threshold) Validate(c client.Connection, ks data.KubeSettings) {
64+
func (t Threshold) Validate() {
7065
for _, k := range []string{"cpu", "memory"} {
7166
v, ok := t[k]
7267
if !ok {

internal/ui/config.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,12 @@ func (c *Configurator) activeConfig() (cluster string, context string, ok bool)
211211
func (c *Configurator) RefreshStyles() {
212212
if c.Styles == nil {
213213
c.Styles = config.NewStyles()
214-
} else {
215-
c.Styles.Reset()
216214
}
217215

218216
cl, ct, ok := c.activeConfig()
219217
if !ok {
218+
log.Debug().Msgf("No custom skin found. Using stock skin")
219+
c.updateStyles("")
220220
return
221221
}
222222

@@ -228,7 +228,7 @@ func (c *Configurator) RefreshStyles() {
228228

229229
skin, ok := c.activeSkin()
230230
if !ok {
231-
log.Debug().Msgf("No custom skin found. Loading default")
231+
log.Debug().Msgf("No custom skin found. Using stock skin")
232232
c.updateStyles("")
233233
return
234234
}
@@ -248,9 +248,6 @@ func (c *Configurator) RefreshStyles() {
248248

249249
func (c *Configurator) updateStyles(f string) {
250250
c.skinFile = f
251-
if !c.HasSkin() {
252-
c.Styles.DefaultSkin()
253-
}
254251
c.Styles.Update()
255252

256253
render.ModColor = c.Styles.Frame().Status.ModifyColor.Color()

internal/view/exec.go

+17-5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const (
3838
bannerFmt = "<<K9s-Shell>> Pod: %s | Container: %s \n"
3939
)
4040

41+
var editorEnvVars = []string{"KUBE_EDITOR", "K9S_EDITOR", "EDITOR"}
42+
4143
type shellOpts struct {
4244
clear, background bool
4345
pipes []string
@@ -115,14 +117,24 @@ func run(a *App, opts shellOpts) (bool, chan error, chan string) {
115117
}
116118

117119
func edit(a *App, opts shellOpts) bool {
118-
bin, err := exec.LookPath(os.Getenv("K9S_EDITOR"))
119-
if err != nil {
120-
bin, err = exec.LookPath(os.Getenv("EDITOR"))
120+
var (
121+
bin string
122+
err error
123+
)
124+
for _, e := range editorEnvVars {
125+
env := os.Getenv(e)
126+
if env != "" {
127+
continue
128+
}
129+
bin, err = exec.LookPath(env)
121130
if err != nil {
122-
log.Error().Err(err).Msgf("K9S_EDITOR|EDITOR not set")
123-
return false
131+
continue
124132
}
125133
}
134+
if bin == "" {
135+
a.Flash().Errf("You must set at least one of those env vars: %s", strings.Join(editorEnvVars, "|"))
136+
return false
137+
}
126138
opts.binary, opts.background = bin, false
127139

128140
suspended, errChan, _ := run(a, opts)

snap/snapcraft.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: k9s
22
base: core20
3-
version: 'v0.30.7'
3+
version: 'v0.30.8'
44
summary: K9s is a CLI to view and manage your Kubernetes clusters.
55
description: |
66
K9s is a CLI to view and manage your Kubernetes clusters. By leveraging a terminal UI, you can easily traverse Kubernetes resources and view the state of your clusters in a single powerful session.

0 commit comments

Comments
 (0)