Skip to content

Commit

Permalink
Add user prompt for multiple profile
Browse files Browse the repository at this point in the history
If a user has multiple profiles running they can be asked to select from
which they want files copied from

Signed-off-by: knrt10 <[email protected]>
  • Loading branch information
knrt10 committed Jul 12, 2020
1 parent 2338b20 commit 9371d4a
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,29 @@ USERNAME=`id -un`
cd ~/.kube
mkdir -p keys

profile=$(minikube profile list -o json | jq '.valid' | jq -r '.[].Name')
profiles=$(minikube profile list -o json | jq -r '.valid | .[] | select(.Status=="Running") | .Name')

profiles_count=$(echo "$profiles" | wc -l | tr -d '[:space:]')

if [ "$profiles_count" != 1 ]; then
options=($profiles)
echo "Select running cluster you want to copy files from?"
select opt in "${options[@]}"
do
profile_name=$opt
if [ "$profile_name" == "" ]; then
echo "Wrong option"
continue
fi
break
done
else
profile_name=$profiles
fi

cp /Users/${USERNAME}/.minikube/ca.crt keys/
cp /Users/${USERNAME}/.minikube/profiles/$profile/client.crt keys/
cp /Users/${USERNAME}/.minikube/profiles/$profile/client.key keys/
cp /Users/${USERNAME}/.minikube/profiles/$profile_name/client.crt keys/
cp /Users/${USERNAME}/.minikube/profiles/$profile_name/client.key keys/

gsed -i "s/\/Users\/${USERNAME}\/.minikube\/profiles\/minikube/.\/keys/g" config
gsed -i "s/\/Users\/${USERNAME}\/.minikube/.\/keys/g" config

0 comments on commit 9371d4a

Please sign in to comment.