Skip to content

Commit

Permalink
USAGOV-1761-cf-components-audit: reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobaaronyeager committed Oct 1, 2024
1 parent 32ff5f9 commit ffadc18
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions bin/cloudgov/audit/cf-components
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ level6=" "
die() { echo "$*" >&2; exit 2; } # complain to STDERR and exit with error
needs_arg() { if [ -z "$OPTARG" ]; then die "No arg for --$OPT option"; fi; }

# Defaults (to be thorough, you could also assign alpha="" and charlie="")
all=false # Overridden by the value set by -b or --bravo
spaces="all" # Overridden by the value set by -s or --spaces

while getopts as: OPT; do # allow -a, -b with arg, and -- "with arg"
# support long options: https://stackoverflow.com/a/28466267/519360
if [ "$OPT" = "-" ]; then # long option: reformulate OPT and OPTARG
OPT="${OPTARG%%=*}" # extract long option name
OPTARG="${OPTARG#"$OPT"}" # extract long option argument (may be empty)
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
fi
case "$OPT" in
a | all ) all=true ;;
s | spaces ) needs_arg; spaces="$OPTARG" ;;
\? ) exit 2 ;; # bad short option (error reported via getopts)
* ) die "Illegal option --$OPT" ;; # bad long option
esac
done
shift $((OPTIND-1)) # remove parsed options and args from $@ list

getPaginationCount() { # $1 = resource, $2 = relationship, $3 = relationship id
PAGES=$(cf curl "/v3/$1" | jq -r '.pagination | .total_pages');
if [ -z "$2" ]; then
Expand All @@ -39,26 +59,6 @@ getPaginationCount() { # $1 = resource, $2 = relationship, $3 = relationship id
echo "$IDS"
}

# Defaults (to be thorough, you could also assign alpha="" and charlie="")
all=false # Overridden by the value set by -b or --bravo
spaces="all" # Overridden by the value set by -s or --spaces

while getopts as: OPT; do # allow -a, -b with arg, and -- "with arg"
# support long options: https://stackoverflow.com/a/28466267/519360
if [ "$OPT" = "-" ]; then # long option: reformulate OPT and OPTARG
OPT="${OPTARG%%=*}" # extract long option name
OPTARG="${OPTARG#"$OPT"}" # extract long option argument (may be empty)
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
fi
case "$OPT" in
a | all ) all=true ;;
s | spaces ) needs_arg; spaces="$OPTARG" ;;
\? ) exit 2 ;; # bad short option (error reported via getopts)
* ) die "Illegal option --$OPT" ;; # bad long option
esac
done
shift $((OPTIND-1)) # remove parsed options and args from $@ list

echo "${bold}${underline}CF Components${nounderline}${normal}"

# Orgs->Domains/Spaces->Apps/Services->Tasks/Sidecars
Expand Down

0 comments on commit ffadc18

Please sign in to comment.