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`
mine
fredericvl 2022-09-26 22:32:41 +02:00 committed by GitHub
parent 56ab42db54
commit d0f4fa5b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -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") return nil, errors.New("no screendump dir found in context")
} }
ff, err := os.ReadDir(SanitizeFilename(dir)) ff, err := os.ReadDir(dir)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -8,6 +8,7 @@ import (
"github.com/derailed/k9s/internal" "github.com/derailed/k9s/internal"
"github.com/derailed/k9s/internal/client" "github.com/derailed/k9s/internal/client"
"github.com/derailed/k9s/internal/config" "github.com/derailed/k9s/internal/config"
"github.com/derailed/k9s/internal/dao"
"github.com/derailed/k9s/internal/ui" "github.com/derailed/k9s/internal/ui"
"github.com/gdamore/tcell/v2" "github.com/gdamore/tcell/v2"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
@ -34,7 +35,7 @@ func NewScreenDump(gvr client.GVR) ResourceViewer {
} }
func (s *ScreenDump) dirContext(ctx context.Context) context.Context { 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) log.Debug().Msgf("SD-DIR %q", dir)
config.EnsureFullPath(dir, config.DefaultDirMod) config.EnsureFullPath(dir, config.DefaultDirMod)

View File

@ -167,7 +167,7 @@ func (t *Table) BufferActive(state bool, k model.BufferKind) {
} }
func (t *Table) saveCmd(evt *tcell.EventKey) *tcell.EventKey { 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) t.app.Flash().Err(err)
} else { } else {
t.app.Flash().Infof("File %s saved successfully!", path) t.app.Flash().Infof("File %s saved successfully!", path)