Skip to content

Commit 65100b0

Browse files
authored
K9s/release v0.31.2 (#2452)
* [Bug] Fix #2428 * fix #2446 * fix #2449 * schemas updates * Add debug info * v0.31.2 rel notes
1 parent 98a7f3f commit 65100b0

File tree

14 files changed

+102
-28
lines changed

14 files changed

+102
-28
lines changed

Diff for: 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.31.1
14+
VERSION ?= v0.31.2
1515
IMG_NAME := derailed/k9s
1616
IMAGE := ${IMG_NAME}:${VERSION}
1717

Diff for: change_logs/release_v0.31.2.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s.png" align="center" width="800" height="auto"/>
2+
3+
# Release v0.31.2
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+
Yikes! The aftermath...
23+
24+
Thank you all for pitching in and helping flesh out issues!!
25+
26+
Please make sure to add gory details to issues ie relevant configs, debug logs, etc...
27+
28+
Comments like: `same here!` doesn't really help us zero in. Everyone has slightly different settings/platforms so every little bits of info helps with the resolves.
29+
Thank you!!
30+
31+
---
32+
33+
## Videos Are In The Can!
34+
35+
Please dial [K9s Channel](https://www.youtube.com/channel/UC897uwPygni4QIjkPCpgjmw) for up coming content...
36+
37+
* [K9s v0.31.0 Configs+Sneak peek](https://youtu.be/X3444KfjguE)
38+
* [K9s v0.30.0 Sneak peek](https://youtu.be/mVBc1XneRJ4)
39+
* [Vulnerability Scans](https://youtu.be/ULkl0MsaidU)
40+
41+
---
42+
43+
## Resolved Issues
44+
45+
* [#2449](https://github.com/derailed/k9s/issues/2449) [Bug]: views.yaml columns not respected on startup
46+
* [#2448](https://github.com/derailed/k9s/issues/2448) Missing '.thresholds' in config.yaml result in 'assignment to entry in nil map'
47+
* [#2446](https://github.com/derailed/k9s/issues/2446) Context Switch unreliable/not working
48+
49+
---
50+
51+
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2024 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

Diff for: internal/client/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (c *Config) CurrentContextName() (string, error) {
118118
}
119119
cfg, err := c.RawConfig()
120120
if err != nil {
121-
return "", err
121+
return "", fmt.Errorf("fail to load rawConfig: %w", err)
122122
}
123123

124124
return cfg.CurrentContext, nil

Diff for: internal/config/config.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,16 @@ func (c *Config) Refine(flags *genericclioptions.ConfigFlags, k9sFlags *Flags, c
6868
}
6969
if isStringSet(flags.Context) {
7070
if _, err := c.K9s.ActivateContext(*flags.Context); err != nil {
71-
return err
71+
return fmt.Errorf("k8sflags. unable to activate context %q: %w", *flags.Context, err)
7272
}
7373
} else {
7474
n, err := cfg.CurrentContextName()
7575
if err != nil {
76-
return err
76+
return fmt.Errorf("unable to retrieve kubeconfig current context %q: %w", n, err)
7777
}
7878
_, err = c.K9s.ActivateContext(n)
7979
if err != nil {
80-
return err
80+
return fmt.Errorf("unable to activate context %q: %w", *flags.Context, err)
8181
}
8282
}
8383
log.Debug().Msgf("Active Context %q", c.K9s.ActiveContextName())
@@ -220,7 +220,7 @@ func (c *Config) Load(path string) error {
220220

221221
var cfg Config
222222
if err := yaml.Unmarshal(bb, &cfg); err != nil {
223-
return err
223+
return fmt.Errorf("main config yaml load failed: %w", err)
224224
}
225225
c.Merge(&cfg)
226226

Diff for: internal/config/config_test.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package config_test
55

66
import (
7-
"errors"
87
"fmt"
98
"os"
109
"path/filepath"
@@ -407,7 +406,7 @@ func TestConfigRefine(t *testing.T) {
407406
uu := map[string]struct {
408407
flags *genericclioptions.ConfigFlags
409408
k9sFlags *config.Flags
410-
err error
409+
err string
411410
context string
412411
cluster string
413412
namespace string
@@ -488,7 +487,7 @@ func TestConfigRefine(t *testing.T) {
488487
KubeConfig: &cfgFile,
489488
Context: &ns1,
490489
},
491-
err: errors.New(`no context found for: "ns-1"`),
490+
err: `k8sflags. unable to activate context "ns-1": no context found for: "ns-1"`,
492491
},
493492
"use-current-context": {
494493
flags: &genericclioptions.ConfigFlags{
@@ -507,7 +506,7 @@ func TestConfigRefine(t *testing.T) {
507506

508507
err := cfg.Refine(u.flags, u.k9sFlags, client.NewConfig(u.flags))
509508
if err != nil {
510-
assert.Equal(t, u.err, err)
509+
assert.Equal(t, u.err, err.Error())
511510
} else {
512511
assert.Nil(t, err)
513512
assert.Equal(t, u.context, cfg.K9s.ActiveContextName())

Diff for: internal/config/data/dir.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (d *Dir) loadConfig(path string) (*Config, error) {
6868

6969
var cfg Config
7070
if err := yaml.Unmarshal(bb, &cfg); err != nil {
71-
return nil, err
71+
return nil, fmt.Errorf("context-config yaml load failed: %w\n%s", err, string(bb))
7272
}
7373

7474
return &cfg, nil

Diff for: internal/config/json/schemas/k9s.json

+16-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,17 @@
3030
},
3131
"shellPod": {
3232
"type": "object",
33-
"additionalProperties": false,
33+
"additionalProperties": true,
3434
"properties": {
3535
"image": { "type": "string" },
36+
"command": {
37+
"type": "array",
38+
"items": { "type": "string"}
39+
},
40+
"args": {
41+
"type": "array",
42+
"items": { "type": "string"}
43+
},
3644
"namespace": { "type": "string" },
3745
"limits": {
3846
"type": "object",
@@ -41,7 +49,13 @@
4149
"memory": { "type": "string" }
4250
},
4351
"required": ["cpu", "memory"]
44-
}
52+
},
53+
"labels": {
54+
"type": "object",
55+
"additionalProperties": { "type": "string" },
56+
"required": []
57+
},
58+
"tty": { "type": "boolean" }
4559
},
4660
"required": ["image", "namespace", "limits"]
4761
},

Diff for: internal/config/k9s.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/derailed/k9s/internal/client"
1212
"github.com/derailed/k9s/internal/config/data"
13+
"github.com/rs/zerolog/log"
1314
)
1415

1516
// K9s tracks K9s configuration options.
@@ -65,10 +66,11 @@ func (k *K9s) resetConnection(conn client.Connection) {
6566
k.conn = conn
6667
}
6768

68-
// Save saves the k9s config to dis.
69+
// Save saves the k9s config to disk.
6970
func (k *K9s) Save() error {
7071
if k.activeConfig == nil {
71-
return fmt.Errorf("save failed. no active config detected")
72+
log.Warn().Msgf("Save failed. no active config detected")
73+
return nil
7274
}
7375
path := filepath.Join(
7476
AppContextsDir,
@@ -97,7 +99,9 @@ func (k *K9s) Merge(k1 *K9s) {
9799
k.ShellPod = k1.ShellPod
98100
k.Logger = k1.Logger
99101
k.ImageScans = k1.ImageScans
100-
k.Thresholds = k1.Thresholds
102+
if k1.Thresholds != nil {
103+
k.Thresholds = k1.Thresholds
104+
}
101105
}
102106

103107
// AppScreenDumpDir fetch screen dumps dir.
@@ -193,6 +197,9 @@ func (k *K9s) ActivateContext(n string) (*data.Context, error) {
193197
if k.activeConfig.Context == nil {
194198
return nil, fmt.Errorf("context activation failed for: %s", n)
195199
}
200+
if k.activeConfig.Context == nil {
201+
return nil, fmt.Errorf("context activation failed for: %s", n)
202+
}
196203

197204
return k.activeConfig.Context, nil
198205
}

Diff for: internal/view/app.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,12 @@ func (a *App) isValidNS(ns string) (bool, error) {
453453
return true, nil
454454
}
455455

456-
func (a *App) switchContext(ci *cmd.Interpreter) error {
456+
func (a *App) switchContext(ci *cmd.Interpreter, force bool) error {
457457
name, ok := ci.HasContext()
458458
if !ok || a.Config.ActiveContextName() == name {
459-
return nil
459+
if !force {
460+
return nil
461+
}
460462
}
461463

462464
a.Halt()

Diff for: internal/view/browser.go

-7
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,6 @@ func (b *Browser) TableDataChanged(data *render.TableData) {
249249

250250
b.app.QueueUpdateDraw(func() {
251251
b.refreshActions()
252-
if !b.app.Config.K9s.UI.Reactive {
253-
if err := b.app.RefreshCustomViews(); err != nil {
254-
log.Warn().Err(err).Msg("CustomViews load failed")
255-
b.app.Logo().Warn("Views load failed!")
256-
}
257-
}
258-
259252
b.Update(data, b.app.Conn().HasMetrics())
260253
})
261254
}

Diff for: internal/view/command.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func (c *Command) run(p *cmd.Interpreter, fqn string, clearStack bool) error {
167167
return err
168168
}
169169

170-
if err := c.app.switchContext(p); err != nil {
170+
if err := c.app.switchContext(p, false); err != nil {
171171
return err
172172
}
173173
}

Diff for: internal/view/context.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,5 @@ func useContext(app *App, name string) error {
129129
return err
130130
}
131131

132-
return app.switchContext(cmd.NewInterpreter("ctx " + name))
132+
return app.switchContext(cmd.NewInterpreter("ctx "+name), true)
133133
}

Diff for: internal/view/table.go

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/derailed/k9s/internal/render"
1616
"github.com/derailed/k9s/internal/ui"
1717
"github.com/derailed/tcell/v2"
18+
"github.com/rs/zerolog/log"
1819
)
1920

2021
// Table represents a table viewer.
@@ -46,6 +47,13 @@ func (t *Table) Init(ctx context.Context) (err error) {
4647
ctx = context.WithValue(ctx, internal.KeyHasMetrics, t.app.Conn().HasMetrics())
4748
}
4849
ctx = context.WithValue(ctx, internal.KeyStyles, t.app.Styles)
50+
if !t.app.Config.K9s.UI.Reactive {
51+
if err := t.app.RefreshCustomViews(); err != nil {
52+
log.Warn().Err(err).Msg("CustomViews load failed")
53+
t.app.Logo().Warn("Views load failed!")
54+
}
55+
}
56+
4957
ctx = context.WithValue(ctx, internal.KeyViewConfig, t.app.CustomView)
5058
t.Table.Init(ctx)
5159
t.SetInputCapture(t.keyboard)

Diff for: 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.31.1'
3+
version: 'v0.31.2'
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)