Skip to content

Commit

Permalink
Merge pull request #23 from fmount/fix_crs
Browse files Browse the repository at this point in the history
Do not redefine the global $resources variable
  • Loading branch information
fmount authored Nov 27, 2023
2 parents 814bf86 + b929b8d commit b535eb2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
6 changes: 3 additions & 3 deletions collection-scripts/gather_apiservices
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ if [[ -z "$DIR_NAME" ]]; then
fi

# Resource list
resources=()
apiservices=()

# explicitly adding rabbitmq in the grep because we rely on the rabbitmq-cluster-operator
for i in $(/usr/bin/oc get apiservices --all-namespaces | grep -E "(openstack|rabbitmq)\.(org|com)" | awk '{ print $1 }')
do
resources+=("$i")
apiservices+=("$i")
done

for resource in "${resources[@]}"; do
for resource in "${apiservices[@]}"; do
mkdir -p "$BASE_COLLECTION_PATH"/apiservices/
run_bg /usr/bin/oc get apiservice "${resource}" -o yaml '>' "${BASE_COLLECTION_PATH}/apiservices/${resource}.yaml"
done
Expand Down
10 changes: 6 additions & 4 deletions collection-scripts/gather_crds
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ fi


# Resource list
resources=()
crds=()

for i in $(/usr/bin/oc get crd | grep openstack.org | awk '{print $1}')
do
resources+=("crd/$i")
crds+=("$i")
done

echo "Gathering CRDs"
mkdir -p "$BASE_COLLECTION_PATH"/crd

# Run the collection of resources using must-gather
for resource in "${resources[@]}"; do
run_bg /usr/bin/oc adm inspect --dest-dir must-gather "${resource}"
for resource in "${crds[@]}"; do
run_bg /usr/bin/oc get crd "$resource" -o yaml > "${BASE_COLLECTION_PATH}/crd/${resource}.yaml"
done

[[ $CALLED -eq 1 ]] && wait_bg
20 changes: 8 additions & 12 deletions collection-scripts/gather_crs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,29 @@ if [[ -z "$DIR_NAME" ]]; then
fi

# Resource list
resources=()
crs=()

# explictly adding rabbit in the grep because it's not part of the openstack
# umbrella and we rely on the upstream rabbitmq-cluster-operator
for i in $(/usr/bin/oc get crd | grep -E "(openstack|rabbitmq)\.(org|com)" | awk '{print $1}')
do
resources+=("$i")
crs+=("$i")
done

# explicitly adding Metal3 BareMetalHosts
resources+=("baremetalhosts.metal3.io")
crs+=("baremetalhosts.metal3.io")

# we use nested loops to nicely output objects partitioned per namespace, kind
echo "Gathering CRs"
for resource in "${resources[@]}"; do
/usr/bin/oc get "${resource}" --all-namespaces -o custom-columns=NAME:.metadata.name,NAMESPACE:.metadata.namespace --no-headers 2> /dev/null | \
for res in "${crs[@]}"; do
/usr/bin/oc get "${res}" --all-namespaces -o custom-columns=NAME:.metadata.name,NAMESPACE:.metadata.namespace --no-headers 2> /dev/null | \
while read -r ocresource; do
ocobject=$(echo "$ocresource" | awk '{print $1}')
ocproject=$(echo "$ocresource" | awk '{print $2}')
if [ -z "${ocproject}" ]||[ "${ocproject}" == "<none>" ]; then
object_collection_path=${BASE_COLLECTION_PATH}/cluster-scoped-resources/${resource}
if [ -n "${ocproject}" ] && [ "${ocproject}" != "<none>" ]; then
object_collection_path=${BASE_COLLECTION_PATH}/namespaces/${ocproject}/crs/${res}
mkdir -p "${object_collection_path}"
run_bg /usr/bin/oc get "${resource}" -o yaml "${ocobject}" '>' "${object_collection_path}/${ocobject}.yaml"
else
object_collection_path=${BASE_COLLECTION_PATH}/namespaces/${ocproject}/crs/${resource}
mkdir -p "${object_collection_path}"
run_bg /usr/bin/oc get "${resource}" -n "${ocproject}" -o yaml "${ocobject}" '>' "${object_collection_path}/${ocobject}.yaml"
run_bg /usr/bin/oc get "${res}" -n "${ocproject}" -o yaml "${ocobject}" '>' "${object_collection_path}/${ocobject}.yaml"
fi
done
done
Expand Down

0 comments on commit b535eb2

Please sign in to comment.