From b232dacf3cdd0da0f16485c0e88e22117bd3ddc9 Mon Sep 17 00:00:00 2001 From: Takumasa Sakao Date: Fri, 6 Aug 2021 20:18:48 +0900 Subject: [PATCH] Support GVR environment variables for plugin (#1213) * Add resource name as plugin environment variable * Add support of RESOURCE_GROUP & RESOURCE_VERSION too --- README.md | 3 +++ internal/view/table.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 8f9bd6bd..a32e2acd 100644 --- a/README.md +++ b/README.md @@ -480,6 +480,9 @@ K9s allows you to extend your command line and tooling by defining your very own K9s does provide additional environment variables for you to customize your plugins arguments. Currently, the available environment variables are as follows: +* `$RESOURCE_GROUP` -- the selected resource group +* `$RESOURCE_VERSION` -- the selected resource api version +* `$RESOURCE_NAME` -- the selected resource name * `$NAMESPACE` -- the selected resource namespace * `$NAME` -- the selected resource name * `$CONTAINER` -- the current container if applicable diff --git a/internal/view/table.go b/internal/view/table.go index 422c2884..bb178625 100644 --- a/internal/view/table.go +++ b/internal/view/table.go @@ -107,6 +107,10 @@ func (t *Table) defaultEnv() Env { env["NAMESPACE"], env["FILTER"] = client.Namespaced(path) } + env["RESOURCE_GROUP"] = t.GVR().G() + env["RESOURCE_VERSION"] = t.GVR().V() + env["RESOURCE_NAME"] = t.GVR().R() + return env }