diff --git a/change_logs/release_v0.13.2.md b/change_logs/release_v0.13.2.md index da00fb8a..9223a79a 100644 --- a/change_logs/release_v0.13.2.md +++ b/change_logs/release_v0.13.2.md @@ -17,6 +17,8 @@ Also if you dig this tool, please make some noise on social! [@kitesurfer](https Found a waffle thin issue in the Beryllium(Be) core causing K9s xray vision to only operate on one eye ;) Should be all betta' now... +The `xray` command now takes an **optional** third argument for the target namespace ie `:xray dp fred` will show the Xray view for deployments in the `fred` namespace. + Supported resources: * Pods @@ -26,7 +28,7 @@ Supported resources: * DaemonSets * ReplicaSets -Still watch out for that overbite!! so please proceed with caution... +Still watch out for that overbite!! hence please proceed with caution... --- diff --git a/internal/view/command.go b/internal/view/command.go index bb06c57b..99c97344 100644 --- a/internal/view/command.go +++ b/internal/view/command.go @@ -74,7 +74,18 @@ func (c *Command) xrayCmd(cmd string) error { if !allowedXRay(gvr) { return fmt.Errorf("Huh? `%s` Command not found", cmd) } - return c.exec(cmd, "xrays", NewXray(gvr), true) + + x := NewXray(gvr) + ns := c.app.Config.ActiveNamespace() + if len(tokens) == 3 { + ns = tokens[2] + } + c.app.Config.SetActiveNamespace(client.CleanseNamespace(ns)) + if err := c.app.Config.Save(); err != nil { + return err + } + + return c.exec(cmd, "xrays", x, true) } // Exec the Command by showing associated display. diff --git a/internal/view/xray.go b/internal/view/xray.go index 9db79abd..4045892f 100644 --- a/internal/view/xray.go +++ b/internal/view/xray.go @@ -83,7 +83,7 @@ func (x *Xray) Init(ctx context.Context) error { x.SetInputCapture(x.keyboard) x.model.SetRefreshRate(time.Duration(x.app.Config.K9s.GetRefreshRate()) * time.Second) - x.model.SetNamespace(client.AllNamespaces) + x.model.SetNamespace(client.CleanseNamespace(x.app.Config.ActiveNamespace())) x.model.AddListener(x) x.SetChangedFunc(func(n *tview.TreeNode) {