Skip to content

Commit

Permalink
Merge pull request #97 from rtCamp/fix/precedence
Browse files Browse the repository at this point in the history
Give SLACK_WEBHOOK precedence over vault when both are present
  • Loading branch information
mrrobot47 authored Jun 4, 2021
2 parents 85f56f6 + 6899fd0 commit 070bae4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ if [[ -n "$user_slack_channel" ]]; then
export SLACK_CHANNEL="$user_slack_channel"
fi

# Login to vault using GH Token
if [[ -n "$VAULT_GITHUB_TOKEN" ]]; then
unset VAULT_TOKEN
vault login -method=github token="$VAULT_GITHUB_TOKEN" > /dev/null
fi
# Check vault only if SLACK_WEBHOOK is empty.
if [[ -z "$SLACK_WEBHOOK" ]]; then

# Login to vault using GH Token
if [[ -n "$VAULT_GITHUB_TOKEN" ]]; then
unset VAULT_TOKEN
vault login -method=github token="$VAULT_GITHUB_TOKEN" > /dev/null
fi

if [[ -n "$VAULT_GITHUB_TOKEN" ]] || [[ -n "$VAULT_TOKEN" ]]; then
export SLACK_WEBHOOK=$(vault read -field=webhook secret/slack)
if [[ -n "$VAULT_GITHUB_TOKEN" ]] || [[ -n "$VAULT_TOKEN" ]]; then
export SLACK_WEBHOOK=$(vault read -field=webhook secret/slack)
fi
fi

if [[ -f "$hosts_file" ]]; then
Expand Down

0 comments on commit 070bae4

Please sign in to comment.