Support GVR environment variables for plugin (#1213)

* Add resource name as plugin environment variable

* Add support of RESOURCE_GROUP & RESOURCE_VERSION too
mine
Takumasa Sakao 2021-08-06 20:18:48 +09:00 committed by GitHub
parent 274d841380
commit b232dacf3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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
}