From 489b8412951794fa0fa03b8989dd5c9789c684a8 Mon Sep 17 00:00:00 2001 From: Richard Hull Date: Sun, 25 Sep 2022 15:35:29 +0100 Subject: [PATCH 1/4] Add a closing tag when showing timestamp in log view (#1776) --- internal/dao/log_item.go | 1 + internal/dao/log_item_test.go | 2 +- internal/dao/log_items_test.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/dao/log_item.go b/internal/dao/log_item.go index bdce7b08..a66e1748 100644 --- a/internal/dao/log_item.go +++ b/internal/dao/log_item.go @@ -73,6 +73,7 @@ func (l *LogItem) Render(paint string, showTime bool, bb *bytes.Buffer) { for i := len(l.Bytes[:index]); i < 30; i++ { bb.WriteByte(' ') } + bb.WriteString("[-::]") } if l.Pod != "" { diff --git a/internal/dao/log_item_test.go b/internal/dao/log_item_test.go index ac9632b7..1eeacc54 100644 --- a/internal/dao/log_item_test.go +++ b/internal/dao/log_item_test.go @@ -63,7 +63,7 @@ func TestLogItemRender(t *testing.T) { ShowTimestamp: true, }, log: fmt.Sprintf("%s %s\n", "2018-12-14T10:36:43.326972-07:00", "Testing 1,2,3..."), - e: "[gray::b]2018-12-14T10:36:43.326972-07:00 [yellow::]fred [yellow::b]blee[-::-] Testing 1,2,3...\n", + e: "[gray::b]2018-12-14T10:36:43.326972-07:00 [-::][yellow::]fred [yellow::b]blee[-::-] Testing 1,2,3...\n", }, "log-level": { opts: dao.LogOptions{ diff --git a/internal/dao/log_items_test.go b/internal/dao/log_items_test.go index ec491c10..e4e2742e 100644 --- a/internal/dao/log_items_test.go +++ b/internal/dao/log_items_test.go @@ -108,7 +108,7 @@ func TestLogItemsRender(t *testing.T) { Container: "blee", ShowTimestamp: true, }, - e: "[gray::b]2018-12-14T10:36:43.326972-07:00 [teal::]fred [teal::b]blee[-::-] Testing 1,2,3...\n", + e: "[gray::b]2018-12-14T10:36:43.326972-07:00 [-::][teal::]fred [teal::b]blee[-::-] Testing 1,2,3...\n", }, } From cc52c71c5201be2d1d5420f0775babeb613a2cf0 Mon Sep 17 00:00:00 2001 From: Richard Hull Date: Sun, 25 Sep 2022 15:37:29 +0100 Subject: [PATCH 2/4] Log toggles: add a space after "On" in logs view (#1775) Toggling any of the log commands on and off causes the log indicator to dance around - I assume this is because the line is centered, and when on it is N characters long, when off N+1 characters, and so on centering, the x-offset gets rounded. This commit just adds an extra space after each "On" string so that it occupies the same width as the "Off" string ... and the when furiously toggling, the line remains blissfully static. --- internal/view/log_indicator.go | 10 +++++----- internal/view/log_indicator_test.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/view/log_indicator.go b/internal/view/log_indicator.go index 959b51aa..ff360b58 100644 --- a/internal/view/log_indicator.go +++ b/internal/view/log_indicator.go @@ -113,32 +113,32 @@ func (l *LogIndicator) Refresh() { if l.shouldDisplayAllContainers { if l.allContainers { - l.indicator = append(l.indicator, "[::b]AllContainers:[limegreen::b]On[-::]"+spacer...) + l.indicator = append(l.indicator, "[::b]AllContainers:[limegreen::b]On[-::] "+spacer...) } else { l.indicator = append(l.indicator, "[::b]AllContainers:[gray::d]Off[-::]"+spacer...) } } if l.AutoScroll() { - l.indicator = append(l.indicator, "[::b]Autoscroll:[limegreen::b]On[-::]"+spacer...) + l.indicator = append(l.indicator, "[::b]Autoscroll:[limegreen::b]On[-::] "+spacer...) } else { l.indicator = append(l.indicator, "[::b]Autoscroll:[gray::d]Off[-::]"+spacer...) } if l.FullScreen() { - l.indicator = append(l.indicator, "[::b]FullScreen:[limegreen::b]On[-::]"+spacer...) + l.indicator = append(l.indicator, "[::b]FullScreen:[limegreen::b]On[-::] "+spacer...) } else { l.indicator = append(l.indicator, "[::b]FullScreen:[gray::d]Off[-::]"+spacer...) } if l.Timestamp() { - l.indicator = append(l.indicator, "[::b]Timestamps:[limegreen::b]On[-::]"+spacer...) + l.indicator = append(l.indicator, "[::b]Timestamps:[limegreen::b]On[-::] "+spacer...) } else { l.indicator = append(l.indicator, "[::b]Timestamps:[gray::d]Off[-::]"+spacer...) } if l.TextWrap() { - l.indicator = append(l.indicator, "[::b]Wrap:[limegreen::b]On[-::]"...) + l.indicator = append(l.indicator, "[::b]Wrap:[limegreen::b]On[-::] "...) } else { l.indicator = append(l.indicator, "[::b]Wrap:[gray::d]Off[-::]"...) } diff --git a/internal/view/log_indicator_test.go b/internal/view/log_indicator_test.go index 92649d7b..2432a938 100644 --- a/internal/view/log_indicator_test.go +++ b/internal/view/log_indicator_test.go @@ -15,10 +15,10 @@ func TestLogIndicatorRefresh(t *testing.T) { e string }{ "all-containers": { - view.NewLogIndicator(config.NewConfig(nil), defaults, true), "[::b]AllContainers:[gray::d]Off[-::] [::b]Autoscroll:[limegreen::b]On[-::] [::b]FullScreen:[gray::d]Off[-::] [::b]Timestamps:[gray::d]Off[-::] [::b]Wrap:[gray::d]Off[-::]\n", + view.NewLogIndicator(config.NewConfig(nil), defaults, true), "[::b]AllContainers:[gray::d]Off[-::] [::b]Autoscroll:[limegreen::b]On[-::] [::b]FullScreen:[gray::d]Off[-::] [::b]Timestamps:[gray::d]Off[-::] [::b]Wrap:[gray::d]Off[-::]\n", }, "plain": { - view.NewLogIndicator(config.NewConfig(nil), defaults, false), "[::b]Autoscroll:[limegreen::b]On[-::] [::b]FullScreen:[gray::d]Off[-::] [::b]Timestamps:[gray::d]Off[-::] [::b]Wrap:[gray::d]Off[-::]\n", + view.NewLogIndicator(config.NewConfig(nil), defaults, false), "[::b]Autoscroll:[limegreen::b]On[-::] [::b]FullScreen:[gray::d]Off[-::] [::b]Timestamps:[gray::d]Off[-::] [::b]Wrap:[gray::d]Off[-::]\n", }, } From 56ab42db540056d7a1b34c814b41eb3537d51e12 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Sun, 25 Sep 2022 10:37:54 -0400 Subject: [PATCH 3/4] docs: update homebrew installation note (#1772) Linuxbrew has been merged into Homebrew See https://github.com/Linuxbrew/brew/issues/612 and https://github.com/Homebrew/brew/issues/7028 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b6fb3f1..c69e38f4 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ K9s is available on Linux, macOS and Windows platforms. * Binaries for Linux, Windows and Mac are available as tarballs in the [release](https://github.com/derailed/k9s/releases) page. -* Via Homebrew for macOS or LinuxBrew for Linux +* Via [Homebrew](https://brew.sh/) for macOS or Linux ```shell brew install k9s From d0f4fa5b9058d1cbe008dbec5cef51dfcabbd5f2 Mon Sep 17 00:00:00 2001 From: fredericvl <34839323+fredericvl@users.noreply.github.com> Date: Mon, 26 Sep 2022 22:32:41 +0200 Subject: [PATCH 4/4] Fix directory path when viewing ScreenDump (#1777) * Fix path when viewing ScreenDump * Log save should use `CurrentCluster` iso `CurrentContext` * Remove sanitizing of dir in ScreenDump dao * Switch `CurrentCluster` to `CurrentContext` for SD * Revert log saving to `CurrentContext` * Save tables to `CurrentContext` iso `CurrentCluster` --- internal/dao/screen_dump.go | 2 +- internal/view/screen_dump.go | 3 ++- internal/view/table.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/dao/screen_dump.go b/internal/dao/screen_dump.go index 6a9ab91e..1fc00caf 100644 --- a/internal/dao/screen_dump.go +++ b/internal/dao/screen_dump.go @@ -37,7 +37,7 @@ func (d *ScreenDump) List(ctx context.Context, _ string) ([]runtime.Object, erro return nil, errors.New("no screendump dir found in context") } - ff, err := os.ReadDir(SanitizeFilename(dir)) + ff, err := os.ReadDir(dir) if err != nil { return nil, err } diff --git a/internal/view/screen_dump.go b/internal/view/screen_dump.go index 5a975ae7..43eee754 100644 --- a/internal/view/screen_dump.go +++ b/internal/view/screen_dump.go @@ -8,6 +8,7 @@ import ( "github.com/derailed/k9s/internal" "github.com/derailed/k9s/internal/client" "github.com/derailed/k9s/internal/config" + "github.com/derailed/k9s/internal/dao" "github.com/derailed/k9s/internal/ui" "github.com/gdamore/tcell/v2" "github.com/rs/zerolog/log" @@ -34,7 +35,7 @@ func NewScreenDump(gvr client.GVR) ResourceViewer { } func (s *ScreenDump) dirContext(ctx context.Context) context.Context { - dir := filepath.Join(s.App().Config.K9s.GetScreenDumpDir(), s.App().Config.K9s.CurrentCluster) + dir := filepath.Join(s.App().Config.K9s.GetScreenDumpDir(), dao.SanitizeFilename(s.App().Config.K9s.CurrentContext)) log.Debug().Msgf("SD-DIR %q", dir) config.EnsureFullPath(dir, config.DefaultDirMod) diff --git a/internal/view/table.go b/internal/view/table.go index 8cfd90cc..989a3f9a 100644 --- a/internal/view/table.go +++ b/internal/view/table.go @@ -167,7 +167,7 @@ func (t *Table) BufferActive(state bool, k model.BufferKind) { } func (t *Table) saveCmd(evt *tcell.EventKey) *tcell.EventKey { - if path, err := saveTable(t.app.Config.K9s.GetScreenDumpDir(), t.app.Config.K9s.CurrentCluster, t.GVR().R(), t.Path, t.GetFilteredData()); err != nil { + if path, err := saveTable(t.app.Config.K9s.GetScreenDumpDir(), t.app.Config.K9s.CurrentContext, t.GVR().R(), t.Path, t.GetFilteredData()); err != nil { t.app.Flash().Err(err) } else { t.app.Flash().Infof("File %s saved successfully!", path)