blob: ce66743f52ec490cde19e8d9f1eb34bb9021faef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#!/usr/bin/env bash
if [[ $# -eq 0 ]]; then
kubectl api-resources --namespaced=true -o name | xargs printf '%s true\n'
kubectl api-resources --namespaced=false -o name | xargs printf '%s false\n'
else
printf '%s %s\n' "$@"
fi | while read -r type namespaced; do
if [[ $type != *.* ]]; then
type="${type}."
fi
export type
if [[ $namespaced == true ]]; then
kubectl get "$type" --all-namespaces --output=json 2>/dev/null |
jq -r '.items[]|($ENV.type + "/" + .metadata.name + " --namespace=" + .metadata.namespace)'
else
kubectl get "$type" --output=json 2>/dev/null |
jq -r '.items[]|($ENV.type + "/" + .metadata.name)'
fi
done
|