summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@datawire.io>2020-07-27 14:31:06 -0600
committerLuke Shumaker <lukeshu@datawire.io>2020-07-27 14:31:53 -0600
commit14cd5da53289a76ccc50cc24e66f936c5bb19b61 (patch)
tree6e2ff24dc61b659a1cecc27bb2f40f48bd4ef1bc
parentff29f3a9a1be30c4cc1ea376a072ae93e3c72cb9 (diff)
kubectl-get-all: jq
-rwxr-xr-x.local/bin/kubectl-get-all9
1 files changed, 5 insertions, 4 deletions
diff --git a/.local/bin/kubectl-get-all b/.local/bin/kubectl-get-all
index f7d1692..ce66743 100755
--- a/.local/bin/kubectl-get-all
+++ b/.local/bin/kubectl-get-all
@@ -8,11 +8,12 @@ fi | while read -r type namespaced; do
if [[ $type != *.* ]]; then
type="${type}."
fi
+ export type
if [[ $namespaced == true ]]; then
- kubectl get --all-namespaces "$type" 2>/dev/null |
- sed 1d | awk -vtype="$type" '{print type "/" $2, "--namespace=" $1}'
+ kubectl get "$type" --all-namespaces --output=json 2>/dev/null |
+ jq -r '.items[]|($ENV.type + "/" + .metadata.name + " --namespace=" + .metadata.namespace)'
else
- kubectl get "$type" 2>/dev/null |
- sed 1d | awk -vtype="$type" '{print type "/" $1}'
+ kubectl get "$type" --output=json 2>/dev/null |
+ jq -r '.items[]|($ENV.type + "/" + .metadata.name)'
fi
done