@@ -22,9 +22,11 @@ import { resolve } from 'node:path';
2222import * as macadamJSPackage from '@crc-org/macadam.js' ;
2323import * as extensionApi from '@podman-desktop/api' ;
2424
25+ import { initAuthentication } from './authentication' ;
26+ import { getImageSha } from './images' ;
2527import { LoggerDelegator } from './logger' ;
2628import { ProviderConnectionShellAccessImpl } from './macadam-machine-stream' ;
27- import { getErrorMessage , verifyContainerProivder } from './utils' ;
29+ import { getErrorMessage , pullImageFromRedHatRegistry , verifyContainerProivder } from './utils' ;
2830import { isHyperVEnabled , isWSLEnabled } from './win/utils' ;
2931
3032const MACADAM_CLI_NAME = 'macadam' ;
@@ -476,6 +478,15 @@ async function createVM(
476478 if ( existsSync ( cachedImagePath ) ) {
477479 imagePath = cachedImagePath ;
478480 telemetryRecords . imagePath = 'cached' ;
481+ } else {
482+ const client = await initAuthentication ( ) ;
483+ if ( ! client ) {
484+ throw new Error ( 'unable to authenticate' ) ;
485+ }
486+ const imageSha = getImageSha ( provider ) ;
487+ await pullImageFromRedHatRegistry ( client , imageSha , cachedImagePath ) ;
488+ imagePath = cachedImagePath ;
489+ telemetryRecords . imagePath = 'downloaded' ;
479490 }
480491 }
481492
0 commit comments