Skip to content

Instantly share code, notes, and snippets.

@wshearn
Last active March 30, 2017 15:52
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 wshearn/dd5d62ba724f71e328f814bc18ca0482 to your computer and use it in GitHub Desktop.
Save wshearn/dd5d62ba724f71e328f814bc18ca0482 to your computer and use it in GitHub Desktop.
#!/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