Skip to content

Commit

Permalink
Enables users to select which provider os they want to use in the gen…
Browse files Browse the repository at this point in the history
…erate-yaml script (openshift#90)

Referencing: openshift#88

:)
  • Loading branch information
iamemilio authored and flaper87 committed Nov 29, 2018
1 parent 42b8318 commit 6c6e507
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions cmd/clusterctl/examples/openstack/generate-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ print_help()
echo "-h, --help show brief help"
echo "-f, --force-overwrite if file to be generated already exists, force script to overwrite it"
echo "-c, --clouds [File] specifies an existing clouds.yaml file to use rather than generating one interactively"
echo "--provider-os [os name] Required: select the operating system of your provider environment"
echo " Supported Operating Systems: ubuntu, centos"
echo ""
}

# Supported Operating Systems
declare -a arr=("centos" "ubuntu")
SUPPORTED_PROVIDER_OS=""

SCRIPT=$(basename $0)
while test $# -gt 0; do
case "$1" in
Expand All @@ -35,7 +42,7 @@ while test $# -gt 0; do
shift
;;
-c|--clouds)
if [[ $2 == -* ]] || [[ $2 == --* ]];then
if [[ -z "$2" ]] || [[ $2 == -* ]] || [[ $2 == --* ]];then
echo "Error: No cloud path was provided!"
print_help
exit 1
Expand All @@ -44,15 +51,43 @@ while test $# -gt 0; do
shift
shift
;;
--provider-os)
if [[ -z "$2" ]] || [[ $2 == -* ]] || [[ $2 == --* ]];then
echo "provider-os error: No operating system was provided!"
print_help
exit 1
fi
PROVIDER_OS=$(echo $2 | tr '[:upper:]' '[:lower:]')
for i in "${arr[@]}"
do
if test "$PROVIDER_OS" = "$i"; then
SUPPORTED_PROVIDER_OS=$i
break
fi
done
if test -z "$SUPPORTED_PROVIDER_OS"; then
echo "provider-os error: $PROVIDER_OS is not one of the supported operating systems!"
print_help
exit 1
fi
shift
shift
;;
*)
break
;;
esac
done

if test -z "$SUPPORTED_PROVIDER_OS"; then
echo "Missing argument: provider-os is a required argument"
print_help
exit 1
fi

# Define global variables
PWD=$(cd `dirname $0`; pwd)
TEMPLATES_PATH=${TEMPLATES_PATH:-$PWD/ubuntu/}
TEMPLATES_PATH=${TEMPLATES_PATH:-$PWD/$SUPPORTED_PROVIDER_OS/}
HOME_DIR=${PWD%%/cmd/clusterctl/examples/*}
OUTPUT_DIR="${TEMPLATES_PATH}/out"
PROVIDER_CRD_DIR="${HOME_DIR}/config/crd"
Expand Down

0 comments on commit 6c6e507

Please sign in to comment.