Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Allow users to abort before pushing to origin #44

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,27 @@ $sudo footloose status -o json > $status
jk generate -f config.yaml -f $status setup.js
rm -f $status

GIT_ORIGIN = `git config --get remote.origin.url`
GIT_BRANCH = `git rev-parse --abbrev-ref HEAD`
Comment on lines +401 to +402
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't valid in bash/zsh. Can you elaborate on how you tested your changes?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are, what isn’t valid about them?


log "Updating container images and git parameters"
wksctl init --git-url=$(git_http_url $(git config --get remote.origin.url)) --git-branch=$(git rev-parse --abbrev-ref HEAD)
wksctl init --git-url=$(git_http_url $GIT_ORIGIN) --git-branch=$GIT_BRANCH

log "Pushing initial cluster configuration"
git add config.yaml footloose.yaml machines.yaml flux.yaml wks-controller.yaml

git diff-index --quiet HEAD || git commit -m "Initial cluster configuration"

# Confirm it works
read -p "Would you like to push to origin/$GIT_BRANCH ($GIT_ORIGIN)? (y/n) " -n 1 -r
echo
# Checks if it is not a yes.. if so exit
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "To continue: push to origin, run `wksctl apply' against the origin repo, then execute `wksctl kubeconfig'." && [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
git push

log "Installing Kubernetes cluster"
wksctl apply --git-url=$(git_http_url $(git config --get remote.origin.url)) --git-branch=$(git rev-parse --abbrev-ref HEAD) $git_deploy_key
wksctl apply --git-url=$(git_http_url $GIT_ORIGIN) --git-branch=$GIT_BRANCH $git_deploy_key
wksctl kubeconfig