mirror of
				https://github.com/docker/login-action.git
				synced 2025-10-31 10:10:09 +08:00 
			
		
		
		
	http_errors_to_retry -> http_codes_to_retry
Signed-off-by: Fedor Dikarev <fedor.dikarev@gmail.com>
This commit is contained in:
		
							parent
							
								
									1a78bc10dc
								
							
						
					
					
						commit
						75fdabcf85
					
				| @ -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 | | ||||
| 
 | ||||
|  | ||||
| @ -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: | ||||
|  | ||||
| @ -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')) | ||||
|   }; | ||||
|  | ||||
| @ -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; | ||||
|     } | ||||
|  | ||||
| @ -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> { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Fedor Dikarev
						Fedor Dikarev