Skip to content

Commit c15c311

Browse files
committed
Added spin vault
1 parent 8cce7de commit c15c311

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

bin/spin

+4
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ main() {
130130
source "$SPIN_HOME/lib/actions/update.sh"
131131
action_update
132132
;;
133+
vault)
134+
source "$SPIN_HOME/lib/actions/vault.sh"
135+
action_vault "$@"
136+
;;
133137
version)
134138
source "$SPIN_HOME/lib/actions/version.sh"
135139
action_version

lib/actions/init.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ action_init() {
116116
echo "${BOLD}${BLUE}⚡️ Running Ansible Vault to encrypt \"$project_directory/.spin.yml\"...${RESET}"
117117
echo "${BOLD}${YELLOW}⚠️ NOTE: This password will be required anytime someone needs to change the \".spin.yml\" file.${RESET}"
118118
echo "${BOLD}${YELLOW}We recommend using a RANDOM PASSWORD.${RESET}"
119-
docker run --name spin-ansible --rm --pull always -it -v "$(pwd)/$project_directory":/project -w /project $DEFAULT_ANSIBLE_IMAGE ansible-vault encrypt .spin.yml
119+
docker run --name spin-ansible --rm -it -v "$(pwd)/$project_directory":/ansible $DEFAULT_ANSIBLE_IMAGE ansible-vault encrypt .spin.yml
120120
echo "${BOLD}${GREEN}\"$project_directory/.spin.yml\" has been encrypted.${RESET}"
121121
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}"
122122
elif [[ $encrypt_response =~ ^[Nn]$ ]]; then

lib/actions/vault.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
action_vault(){
3+
if [[ $1 == "edit" ]]; then
4+
5+
if [[ -z $2 ]];then
6+
echo "${BOLD}${RED}❌ Please specify a file to edit.${RESET}"
7+
return 1
8+
fi
9+
10+
echo "${BOLD}${YELLOW}ℹ️ We're using ansible-vault within the container to edit your file, which uses \"vi\".${RESET}"
11+
echo "${BOLD}${YELLOW}👉 To edit the file, press i.${RESET}"
12+
echo "${BOLD}${YELLOW}💾 To save your changes and exit, press ESC, then type \":wq\" and press ENTER.${RESET}"
13+
fi
14+
docker run --name spin-ansible --rm -it -v "$(pwd)":/ansible $DEFAULT_ANSIBLE_IMAGE ansible-vault "$@"
15+
}

0 commit comments

Comments
 (0)