1
0
Fork 0
mirror of https://github.com/docker/login-action.git synced 2025-05-12 00:19:29 +02:00

http_errors_to_retry -> http_codes_to_retry

Signed-off-by: Fedor Dikarev <fedor.dikarev@gmail.com>
This commit is contained in:
Fedor Dikarev 2025-01-23 09:33:07 +01:00
parent 1a78bc10dc
commit 75fdabcf85
5 changed files with 9 additions and 9 deletions

View file

@ -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'))
};

View file

@ -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<void> {
export async function login(registry: string, username: string, password: string, ecr: string, http_codes_to_retry: string[], max_attempts: number, retry_timeout: number): Promise<void> {
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<void> {
});
}
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;
}

View file

@ -8,7 +8,7 @@ export async function main(): Promise<void> {
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<void> {