Skip to content

Instantly share code, notes, and snippets.

@jewzaam
Created March 6, 2020 16:03
Show Gist options
  • Save jewzaam/d8d92a98b305add33255e39c9dff8522 to your computer and use it in GitHub Desktop.
Save jewzaam/d8d92a98b305add33255e39c9dff8522 to your computer and use it in GitHub Desktop.
Dump all Group/Resource/Verb in an OCP cluster
#!/bin/bash
# /api
GROUP=""
for VERSION in `oc get --raw /api | jq -r .versions[] | sort`;
do
echo "- apiGroups:"
echo " - $GROUP"
for RESOURCE in `oc get --raw /api/${VERSION} | jq -r .resources[].name | sort`;
do
echo " resources:"
echo " - $RESOURCE"
echo " verbs:"
for VERB in `oc get --raw /api/${VERSION} | jq -r ".resources[] | select(.name == \"$RE
SOURCE\") | .verbs[]" | sort`;
do
echo " - $VERB"
done
done
done
# /apis
for GROUP in `oc get --raw /apis | jq -r .groups[].name | sort`;
do
echo "- apiGroups:"
echo " - $GROUP"
for VERSION in `oc get --raw /apis/${GROUP} | jq -r .versions[].version | sort`;
do
for RESOURCE in `oc get --raw /apis/${GROUP}/${VERSION} | jq -r .resources[].name | sor
t`;
do
echo " resources:"
echo " - $RESOURCE"
echo " verbs:"
for VERB in `oc get --raw /apis/${GROUP}/${VERSION} | jq -r ".resources[] | select(
.name == \"$RESOURCE\") | .verbs[]" | sort`;
do
echo " - $VERB"
done
done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment