Skip to content

Commit

Permalink
Remove read timeout from retry
Browse files Browse the repository at this point in the history
instead use the laziest keyword to make the reading of stdin explicit
  • Loading branch information
robotdana committed Sep 27, 2021
1 parent a04f08c commit 3ebf0ee
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hooks/environment
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ function retry() {
local -i attempt_num=1
local exit_code
local stdin_value
set +e
read -sr -t0.01 stdin_value
set -e

if [[ "$1" == "--with-stdin" ]]; then
read -sr stdin_value
shift
fi

while (( attempt_num <= max_attempts )); do
set +e
"$@" <<< "$stdin_value"
"$@" <<< "${stdin_value:-}"
exit_code=$?
set -e

Expand Down Expand Up @@ -154,7 +156,7 @@ function login_using_aws_ecr_get_login_password() {
echo "^^^ Authenticating with AWS ECR in $region for ${account_ids[*]} :ecr: :docker:"
local password; password="$(retry "${BUILDKITE_PLUGIN_ECR_RETRIES:-0}" aws --region "$region" ecr get-login-password)"
for account_id in "${account_ids[@]}"; do
retry "${BUILDKITE_PLUGIN_ECR_RETRIES:-0}" docker login --username AWS --password-stdin "$account_id.dkr.ecr.$region.amazonaws.com" <<< "$password"
retry "${BUILDKITE_PLUGIN_ECR_RETRIES:-0}" --with-stdin docker login --username AWS --password-stdin "$account_id.dkr.ecr.$region.amazonaws.com" <<< "$password"
done
}

Expand Down

0 comments on commit 3ebf0ee

Please sign in to comment.