@@ -364,7 +364,10 @@ private async Task UploadBlobAsync(string repository, string digest, Stream cont
364
364
365
365
}
366
366
367
- public async Task PushAsync ( BuiltImage builtImage , SourceImageReference source , DestinationImageReference destination , CancellationToken cancellationToken )
367
+ public Task PushAsync ( BuiltImage builtImage , SourceImageReference source , DestinationImageReference destination , CancellationToken cancellationToken )
368
+ => PushAsync ( builtImage , source , destination , pushTags : true , cancellationToken ) ;
369
+
370
+ private async Task PushAsync ( BuiltImage builtImage , SourceImageReference source , DestinationImageReference destination , bool pushTags , CancellationToken cancellationToken )
368
371
{
369
372
cancellationToken . ThrowIfCancellationRequested ( ) ;
370
373
Registry destinationRegistry = destination . RemoteRegistry ! ;
@@ -422,18 +425,25 @@ public async Task PushAsync(BuiltImage builtImage, SourceImageReference source,
422
425
_logger . LogInformation ( Strings . Registry_ConfigUploaded ) ;
423
426
}
424
427
425
- //manifest upload
426
- string manifestDigest = builtImage . Manifest . GetDigest ( ) ;
427
- _logger . LogInformation ( Strings . Registry_ManifestUploadStarted , RegistryName , manifestDigest ) ;
428
- await _registryAPI . Manifest . PutAsync ( destination . Repository , manifestDigest , builtImage . Manifest , cancellationToken ) . ConfigureAwait ( false ) ;
429
- _logger . LogInformation ( Strings . Registry_ManifestUploaded , RegistryName ) ;
430
-
431
- //tag upload
432
- foreach ( string tag in destination . Tags )
428
+ // Tags can refer to an image manifest or an image manifest list.
429
+ // In the first case, we push tags to the registry.
430
+ // In the second case, we push the manifest digest so the manifest list can refer to it.
431
+ if ( pushTags )
432
+ {
433
+ Debug . Assert ( destination . Tags . Length > 0 ) ;
434
+ foreach ( string tag in destination . Tags )
435
+ {
436
+ _logger . LogInformation ( Strings . Registry_TagUploadStarted , tag , RegistryName ) ;
437
+ await _registryAPI . Manifest . PutAsync ( destination . Repository , tag , builtImage . Manifest , cancellationToken ) . ConfigureAwait ( false ) ;
438
+ _logger . LogInformation ( Strings . Registry_TagUploaded , tag , RegistryName ) ;
439
+ }
440
+ }
441
+ else
433
442
{
434
- _logger . LogInformation ( Strings . Registry_TagUploadStarted , tag , RegistryName ) ;
435
- await _registryAPI . Manifest . PutAsync ( destination . Repository , tag , builtImage . Manifest , cancellationToken ) . ConfigureAwait ( false ) ;
436
- _logger . LogInformation ( Strings . Registry_TagUploaded , tag , RegistryName ) ;
443
+ string manifestDigest = builtImage . Manifest . GetDigest ( ) ;
444
+ _logger . LogInformation ( Strings . Registry_ManifestUploadStarted , RegistryName , manifestDigest ) ;
445
+ await _registryAPI . Manifest . PutAsync ( destination . Repository , manifestDigest , builtImage . Manifest , cancellationToken ) . ConfigureAwait ( false ) ;
446
+ _logger . LogInformation ( Strings . Registry_ManifestUploaded , RegistryName ) ;
437
447
}
438
448
}
439
449
}
0 commit comments