From 75fdabcf852c008c864b86281126aff401317e46 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Thu, 23 Jan 2025 09:33:07 +0100 Subject: [PATCH] http_errors_to_retry -> http_codes_to_retry Signed-off-by: Fedor Dikarev --- README.md | 2 +- action.yml | 2 +- src/context.ts | 4 ++-- src/docker.ts | 8 ++++---- src/main.ts | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0ea9923..246091c 100644 --- a/README.md +++ b/README.md @@ -507,7 +507,7 @@ The following inputs can be used as `step.with` keys: | `password` | String | | Password or personal access token for authenticating the Docker registry | | `ecr` | String | `auto` | Specifies whether the given registry is ECR (`auto`, `true` or `false`) | | `logout` | Bool | `true` | Log out from the Docker registry at the end of a job | -| `http_errors_to_retry` | String | `408,500,502,504` | Comma separated list of HTTP error codes we want to retry | +| `http_codes_to_retry` | String | `408,500,502,504` | Comma separated list of HTTP error codes we want to retry | | `max_attempts` | String | `1` | Overall maximum number of attempts we will make trying to login (1 means no retries) | | `retry_timeout` | String | `15` | Timeout between retries, in seconds | diff --git a/action.yml b/action.yml index a9a7954..532b6ad 100644 --- a/action.yml +++ b/action.yml @@ -24,7 +24,7 @@ inputs: description: 'Log out from the Docker registry at the end of a job' default: 'true' required: false - http_errors_to_retry: + http_codes_to_retry: description: 'Comma separated list of HTTP error codes we want to retry' default: '408,500,502,504' max_attempts: diff --git a/src/context.ts b/src/context.ts index 39662ca..ff95067 100644 --- a/src/context.ts +++ b/src/context.ts @@ -6,7 +6,7 @@ export interface Inputs { password: string; ecr: string; logout: boolean; - http_errors_to_retry: string[]; + http_codes_to_retry: string[]; max_attempts: number; retry_timeout: number; } @@ -18,7 +18,7 @@ export function getInputs(): Inputs { password: core.getInput('password'), ecr: core.getInput('ecr'), logout: core.getBooleanInput('logout'), - http_errors_to_retry: core.getInput('http_errors_to_retry').split(','), + http_codes_to_retry: core.getInput('http_codes_to_retry').split(','), max_attempts: Number.parseInt(core.getInput('max_attempts')), retry_timeout: Number.parseInt(core.getInput('retry_timeout')) }; diff --git a/src/docker.ts b/src/docker.ts index b53b9eb..4e476a2 100644 --- a/src/docker.ts +++ b/src/docker.ts @@ -3,7 +3,7 @@ import * as core from '@actions/core'; import {Docker} from '@docker/actions-toolkit/lib/docker/docker'; -export async function login(registry: string, username: string, password: string, ecr: string, http_errors_to_retry: string[], max_attempts: number, retry_timeout: number): Promise { +export async function login(registry: string, username: string, password: string, ecr: string, http_codes_to_retry: string[], max_attempts: number, retry_timeout: number): Promise { let succeeded: boolean = false; for (let attempt = 1; attempt <= max_attempts && !succeeded; attempt++) { try { @@ -14,7 +14,7 @@ export async function login(registry: string, username: string, password: string } succeeded = true; } catch (error) { - if (attempt < max_attempts && isRetriableError(error.message, http_errors_to_retry)) { + if (attempt < max_attempts && isRetriableError(error.message, http_codes_to_retry)) { core.info(`Attempt ${attempt} out of ${max_attempts} failed, retrying after ${retry_timeout} seconds`); await new Promise(r => setTimeout(r, retry_timeout * 1000)); } else { @@ -34,8 +34,8 @@ export async function logout(registry: string): Promise { }); } -function isRetriableError(error_message: string, http_errors_to_retry: string[]): boolean { - for (const err_code of http_errors_to_retry) { +function isRetriableError(error_message: string, http_codes_to_retry: string[]): boolean { + for (const err_code of http_codes_to_retry) { if (error_message.includes('failed with status: ' + err_code)) { return true; } diff --git a/src/main.ts b/src/main.ts index 6b07005..6c816ed 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,7 +8,7 @@ export async function main(): Promise { const input: context.Inputs = context.getInputs(); stateHelper.setRegistry(input.registry); stateHelper.setLogout(input.logout); - await docker.login(input.registry, input.username, input.password, input.ecr, input.http_errors_to_retry, input.max_attempts, input.retry_timeout); + await docker.login(input.registry, input.username, input.password, input.ecr, input.http_codes_to_retry, input.max_attempts, input.retry_timeout); } async function post(): Promise {