From f130ed98373e851b472ca6c8edd7d3f00c6795a6 Mon Sep 17 00:00:00 2001 From: Jonas Tingeborn Date: Tue, 7 Nov 2017 19:07:58 +0100 Subject: [PATCH] Fix namespace support in kubectl aging plugin The example plugin's comments mentioned the namespace support limitation, awaiting kubectl to implement environment variable propagation. Now that 1.8 is out, the requirement is satisfied. This commit adds use of the conveyed namespace information to the plugin example. Fixes #55255 --- pkg/kubectl/plugins/examples/aging/aging.rb | 3 ++- pkg/kubectl/plugins/examples/aging/plugin.yaml | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/kubectl/plugins/examples/aging/aging.rb b/pkg/kubectl/plugins/examples/aging/aging.rb index ed9a87fffc6..3a60e94c431 100755 --- a/pkg/kubectl/plugins/examples/aging/aging.rb +++ b/pkg/kubectl/plugins/examples/aging/aging.rb @@ -22,7 +22,8 @@ class Numeric end end -pods_json = `kubectl get pods -o json` +namespace = ENV['KUBECTL_PLUGINS_CURRENT_NAMESPACE'] || 'default' +pods_json = `kubectl --namespace #{namespace} get pods -o json` pods_parsed = JSON.parse(pods_json) puts "The Magnificent Aging Plugin." diff --git a/pkg/kubectl/plugins/examples/aging/plugin.yaml b/pkg/kubectl/plugins/examples/aging/plugin.yaml index 07dc2022a68..87275dc095b 100644 --- a/pkg/kubectl/plugins/examples/aging/plugin.yaml +++ b/pkg/kubectl/plugins/examples/aging/plugin.yaml @@ -2,7 +2,4 @@ name: "aging" shortDesc: "Aging shows pods by age" longDesc: > Aging shows pods from the current namespace by age. - Once we have plugin support for global flags through - env vars (planned for V1) we'll be able to switch - between namespaces using the --namespace flag. command: ./aging.rb