@@ -391,18 +391,14 @@ func downloadRestoreImage(ctx context.Context, url string, destPath string) (*pr
391391 return reader , nil
392392}
393393
394- // FetchLatestSupportedMacOSRestoreImage fetches the latest macOS restore image supported by this host from the network.
395- //
396- // After downloading the restore image, you can initialize a MacOSInstaller using LoadMacOSRestoreImageFromPath function
397- // with the local restore image file.
394+ // GetLatestSupportedMacOSRestoreImageURL get the latest macOS restore image url supported by this host from the network.
398395//
399396// This is only supported on macOS 12 and newer, error will
400397// be returned on older versions.
401- func FetchLatestSupportedMacOSRestoreImage ( ctx context. Context , destPath string ) (* progress. Reader , error ) {
398+ func GetLatestSupportedMacOSRestoreImageURL ( ) (string , error ) {
402399 if err := macOSAvailable (12 ); err != nil {
403- return nil , err
400+ return "" , err
404401 }
405-
406402 waitCh := make (chan struct {})
407403 var (
408404 url string
@@ -419,7 +415,22 @@ func FetchLatestSupportedMacOSRestoreImage(ctx context.Context, destPath string)
419415 )
420416 <- waitCh
421417 if fetchErr != nil {
422- return nil , fetchErr
418+ return "" , fetchErr
419+ }
420+ return url , nil
421+ }
422+
423+ // FetchLatestSupportedMacOSRestoreImage fetches the latest macOS restore image supported by this host from the network.
424+ //
425+ // After downloading the restore image, you can initialize a MacOSInstaller using LoadMacOSRestoreImageFromPath function
426+ // with the local restore image file.
427+ //
428+ // This is only supported on macOS 12 and newer, error will
429+ // be returned on older versions.
430+ func FetchLatestSupportedMacOSRestoreImage (ctx context.Context , destPath string ) (* progress.Reader , error ) {
431+ url , err := GetLatestSupportedMacOSRestoreImageURL ()
432+ if err != nil {
433+ return nil , err
423434 }
424435 progressReader , err := downloadRestoreImage (ctx , url , destPath )
425436 if err != nil {
0 commit comments