(params: DockerResolverParameters | DockerCLIParameters, imageName: string, pullImageOnError: boolean)
| 276 | } |
| 277 | |
| 278 | export async function inspectDockerImage(params: DockerResolverParameters | DockerCLIParameters, imageName: string, pullImageOnError: boolean) { |
| 279 | try { |
| 280 | return await inspectImage(params, imageName); |
| 281 | } catch (inspectErr) { |
| 282 | const output = 'cliHost' in params ? params.output : params.common.output; |
| 283 | if (!pullImageOnError) { |
| 284 | logErrorStdoutStderr(inspectErr, output); |
| 285 | throw inspectErr; |
| 286 | } |
| 287 | try { |
| 288 | return await inspectImageInRegistry(output, params.targetPlatformInfo, imageName); |
| 289 | } catch (inspectErr2) { |
| 290 | output.write(`Error fetching image details: ${inspectErr2?.message}`, LogLevel.Info); |
| 291 | } |
| 292 | try { |
| 293 | await retry(async () => dockerPtyCLI(params, 'pull', imageName), { maxRetries: 5, retryIntervalMilliseconds: 1000, output }); |
| 294 | } catch (pullErr) { |
| 295 | logErrorStdoutStderr(inspectErr, output); |
| 296 | logErrorStdoutStderr(pullErr, output); |
| 297 | throw pullErr; |
| 298 | } |
| 299 | try { |
| 300 | return await inspectImage(params, imageName); |
| 301 | } catch (inspectErr3) { |
| 302 | logErrorStdoutStderr(inspectErr3, output); |
| 303 | throw inspectErr3; |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | function logErrorStdoutStderr(err: any, output: Log) { |
| 309 | if (err?.message) { |
no test coverage detected