Skip to content

Instantly share code, notes, and snippets.

@dudash
Last active September 21, 2020 23:03
Show Gist options
  • Select an option

  • Save dudash/08352259340ad730eefaaa7e5acbd0cc to your computer and use it in GitHub Desktop.

Select an option

Save dudash/08352259340ad730eefaaa7e5acbd0cc to your computer and use it in GitHub Desktop.
istioctl version selector
#!/bin/bash
# Simple script to help configuring which istio CLI to use when you
# have a need to keep multiple versions and switch between them.
# Install and notes:
# 1. put this in /usr/local/bin and chmod +x
# 2. keep all the versions of istioctl in the /Applications directory
# 3. name istioctl executables with corresponding version - e.g. /Applications/istioctl-1.4.8
prompt="Please select an istioctl version:"
options=( $(ls /Applications/istioctl* | xargs -0) )
PS3="$prompt "
select opt in "${options[@]}" "Quit" ; do
if (( REPLY == 1 + ${#options[@]} )) ; then
exit
elif (( REPLY > 0 && REPLY <= ${#options[@]} )) ; then
echo "You picked $REPLY"
break
else
echo "Invalid option. Try another one."
fi
done
echo "Switching istio to version at $opt"
ln -sf $opt /usr/local/bin/istioctl
istioctl version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment