Last active
March 30, 2017 15:52
-
-
Save wshearn/dd5d62ba724f71e328f814bc18ca0482 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
valid_phases=("pre" "controlplane" "postcontrolplane" "nodescaleup" "migrations" "metrics" "logging" "post") | |
function phase_is_valid () { | |
for e in "${valid_phases[@]}"; do | |
[[ "$e" == "$1" ]] && return 0; | |
done | |
return 1 | |
} | |
function phase_is_valid_fixed () { | |
for e in "${valid_phases[@]}"; do | |
[[ "$e" == "$@" ]] && return 0; | |
done | |
return 1 | |
} | |
OPTARG="pre controlplane" | |
echo "Testing $OPTARG" | |
phase_is_valid $OPTARG && echo "worked" || echo "failed" | |
phase_is_valid_fixed $OPTARG && echo "worked" || echo "failed" | |
OPTARG="pre" | |
echo "Testing $OPTARG" | |
phase_is_valid $OPTARG && echo "worked" || echo "failed" | |
phase_is_valid_fixed $OPTARG && echo "worked" || echo "failed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment