Skip to content

Commit

Permalink
Merge pull request #7 from LinkUp/fix-creds-extraction
Browse files Browse the repository at this point in the history
Better handle creds extraction
  • Loading branch information
byrnedo committed Nov 30, 2018
2 parents 50726bc + 7e6b028 commit 8d54250
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docker_reg_tool
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ CREDS=""
DOCKER_CONFIG="$HOME/.docker/config.json"

if [[ -f "$DOCKER_CONFIG" ]]; then
CREDS="Authorization: Basic $(jq -r '.auths."'$REG'".auth' < "$DOCKER_CONFIG")"
AUTH_INFO=$(jq -r '.auths."'$REG'".auth' < "$DOCKER_CONFIG")
if [ "$AUTH_INFO" = "null" ]; then
AUTH_INFO=$(jq -r '.auths."'$PROTO$REG'".auth' < "$DOCKER_CONFIG")
if [ "$AUTH_INFO" = "null" ]; then
echo "ERROR: Failed to retrieve credentials from $DOCKER_CONFIG for ${REG}!"
exit 4
fi
fi
CREDS="Authorization: Basic $AUTH_INFO"
elif [[ -v "BASIC_AUTH" ]]; then
CREDS="Authorization: Basic $(echo -n $BASIC_AUTH|base64)"
fi
Expand Down

0 comments on commit 8d54250

Please sign in to comment.