Skip to content
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