Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added spin vault
Browse files Browse the repository at this point in the history
jaydrogers committed Dec 15, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 8cce7de commit c15c311
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions bin/spin
Original file line number Diff line number Diff line change
@@ -130,6 +130,10 @@ main() {
source "$SPIN_HOME/lib/actions/update.sh"
action_update
;;
vault)
source "$SPIN_HOME/lib/actions/vault.sh"
action_vault "$@"
;;
version)
source "$SPIN_HOME/lib/actions/version.sh"
action_version
2 changes: 1 addition & 1 deletion lib/actions/init.sh
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ action_init() {
echo "${BOLD}${BLUE}⚡️ Running Ansible Vault to encrypt \"$project_directory/.spin.yml\"...${RESET}"
echo "${BOLD}${YELLOW}⚠️ NOTE: This password will be required anytime someone needs to change the \".spin.yml\" file.${RESET}"
echo "${BOLD}${YELLOW}We recommend using a RANDOM PASSWORD.${RESET}"
docker run --name spin-ansible --rm --pull always -it -v "$(pwd)/$project_directory":/project -w /project $DEFAULT_ANSIBLE_IMAGE ansible-vault encrypt .spin.yml
docker run --name spin-ansible --rm -it -v "$(pwd)/$project_directory":/ansible $DEFAULT_ANSIBLE_IMAGE ansible-vault encrypt .spin.yml
echo "${BOLD}${GREEN}\"$project_directory/.spin.yml\" has been encrypted.${RESET}"
echo "${BOLD}${YELLOW}👉 NOTE: You can save this password in \".vault_password\" in the root of your project if you want your secret to be remembered.${RESET}"
elif [[ $encrypt_response =~ ^[Nn]$ ]]; then
15 changes: 15 additions & 0 deletions lib/actions/vault.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
action_vault(){
if [[ $1 == "edit" ]]; then

if [[ -z $2 ]];then
echo "${BOLD}${RED}❌ Please specify a file to edit.${RESET}"
return 1
fi

echo "${BOLD}${YELLOW}ℹ️ We're using ansible-vault within the container to edit your file, which uses \"vi\".${RESET}"
echo "${BOLD}${YELLOW}👉 To edit the file, press i.${RESET}"
echo "${BOLD}${YELLOW}💾 To save your changes and exit, press ESC, then type \":wq\" and press ENTER.${RESET}"
fi
docker run --name spin-ansible --rm -it -v "$(pwd)":/ansible $DEFAULT_ANSIBLE_IMAGE ansible-vault "$@"
}

0 comments on commit c15c311

Please sign in to comment.