Skip to content

Set vault password file via environment variable #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v0.5.0-wip
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions bin/git-diff-ansible-vault
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,14 @@ git_diff_ansible_vault() {
done
}

#
# Read environment variables.
#

if [ -f "$ANSIBLE_VAULT_PASSWORD_FILE" ]; then
VAULT_PASSWORD_FILE="$ANSIBLE_VAULT_PASSWORD_FILE"
fi

#
# parse argv
#
Expand Down
8 changes: 8 additions & 0 deletions test/git-diff-ansible-vault.bats
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ EOF
assert_failure "[ERROR] Not a git repository"
}

@test "Setting vault password file via environment variable unlocks vault" {
ANSIBLE_VAULT_PASSWORD_FILE=.alternate-vault-pass run git diff-ansible-vault --verbose
assert_success
assert_line "[INFO] VAULT_PASSWORD_FILE: .alternate-vault-pass"
assert_line "diff --git a/vault.yml b/vault.yml"
assert_line "+ - bash"
}

@test "--vault-password-file with specified path unlocks vault" {
run git diff-ansible-vault --vault-password-file .alternate-vault-pass --verbose
assert_success
Expand Down