Skip to content

Commit 070bae4

Browse files
authored
Merge pull request #97 from rtCamp/fix/precedence
Give SLACK_WEBHOOK precedence over vault when both are present
2 parents 85f56f6 + 6899fd0 commit 070bae4

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

main.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@ if [[ -n "$user_slack_channel" ]]; then
2020
export SLACK_CHANNEL="$user_slack_channel"
2121
fi
2222

23-
# Login to vault using GH Token
24-
if [[ -n "$VAULT_GITHUB_TOKEN" ]]; then
25-
unset VAULT_TOKEN
26-
vault login -method=github token="$VAULT_GITHUB_TOKEN" > /dev/null
27-
fi
23+
# Check vault only if SLACK_WEBHOOK is empty.
24+
if [[ -z "$SLACK_WEBHOOK" ]]; then
25+
26+
# Login to vault using GH Token
27+
if [[ -n "$VAULT_GITHUB_TOKEN" ]]; then
28+
unset VAULT_TOKEN
29+
vault login -method=github token="$VAULT_GITHUB_TOKEN" > /dev/null
30+
fi
2831

29-
if [[ -n "$VAULT_GITHUB_TOKEN" ]] || [[ -n "$VAULT_TOKEN" ]]; then
30-
export SLACK_WEBHOOK=$(vault read -field=webhook secret/slack)
32+
if [[ -n "$VAULT_GITHUB_TOKEN" ]] || [[ -n "$VAULT_TOKEN" ]]; then
33+
export SLACK_WEBHOOK=$(vault read -field=webhook secret/slack)
34+
fi
3135
fi
3236

3337
if [[ -f "$hosts_file" ]]; then

0 commit comments

Comments
 (0)