diff options
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/kubectl-get-all | 9 |
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 |