Skip to content

Instantly share code, notes, and snippets.

@freyes
Last active September 28, 2022 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freyes/e672b22e2fda0a2559edeadbf1e567cd to your computer and use it in GitHub Desktop.
Save freyes/e672b22e2fda0a2559edeadbf1e567cd to your computer and use it in GitHub Desktop.
#!/bin/bash -eu
CHANNELS=()
ARCH=amd64
SERIES=()
CONFIG=
DEBUG=0
CHARMS=()
while (($# > 0))
do
case "$1" in
--series)
SERIES+=( $2 )
shift
;;
--charm)
CHARMS+=( $2 )
shift
;;
--arch)
ARCH=$2
shift
;;
--channel)
CHANNELS+=( $2 )
shift
;;
--config)
CONFIG=$2
shift
;;
--debug)
DEBUG=1
;;
*)
echo "ERROR: invalid input '$1'"
_usage
exit 1
;;
esac
shift
done
if [ -z $CONFIG ] && [[ ${#CHARMS[@]} == 0 ]] ; then
echo "Please provide a configuration:"
echo "Usage example:"
echo " charm-check-channels [--series <SERIES>] [--arch <ARCH>] [--channel <CHANNEL>] --config lp-builder-config/openstack.yaml"
exit 1
fi
if [[ $DEBUG > 0 ]]; then
set -x
fi
if [[ ${#CHARMS[@]} == 0 ]]; then
CHARMS=( $(grep charmhub $CONFIG | grep -v -P '^\s*#.*' | awk '{print $2}' | sort | uniq) )
fi
for CHARM in $CHARMS; do
for CHANNEL in "${CHANNELS[@]}";do
for SERIES_ in "${SERIES[@]}";do
TUPLE=$(juju info --format json --channel $CHANNEL --arch $ARCH --series $SERIES_ $CHARM | jq -r '."channel-map" | .[] | [(.track + "/" + .risk),.revision,.version]|@tsv')
echo -e "$CHARM(${SERIES_})\t$TUPLE"
done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment