@@ -453,6 +453,52 @@ private static async Task WriteManifestForOciImage(
453
453
}
454
454
}
455
455
456
+ private static async Task WriteIndexJsonForOciImage (
457
+ TarWriter writer ,
458
+ BuiltImage image ,
459
+ DestinationImageReference destinationReference ,
460
+ CancellationToken cancellationToken )
461
+ {
462
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
463
+
464
+ var manifests = new PlatformSpecificOciManifest [ destinationReference . Tags . Length ] ;
465
+ for ( int i = 0 ; i < destinationReference . Tags . Length ; i ++ )
466
+ {
467
+ var tag = destinationReference . Tags [ i ] ;
468
+ manifests [ i ] = new PlatformSpecificOciManifest
469
+ {
470
+ mediaType = SchemaTypes . OciManifestV1 ,
471
+ size = image . Manifest . Length ,
472
+ digest = image . ManifestDigest ,
473
+ annotations = new Dictionary < string , string >
474
+ {
475
+ { "io.containerd.image.name" , $ "{ destinationReference . Repository } :{ tag } " } ,
476
+ { "org.opencontainers.image.ref.name" , tag }
477
+ }
478
+ } ;
479
+ }
480
+
481
+ var index = new ImageIndexV1
482
+ {
483
+ schemaVersion = 2 ,
484
+ mediaType = SchemaTypes . OciImageIndexV1 ,
485
+ manifests = manifests
486
+ } ;
487
+
488
+ var options = new JsonSerializerOptions
489
+ {
490
+ DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingNull
491
+ } ;
492
+ using ( MemoryStream indexStream = new ( Encoding . UTF8 . GetBytes ( JsonSerializer . SerializeToNode ( index , options ) ! . ToJsonString ( ) ) ) )
493
+ {
494
+ PaxTarEntry indexEntry = new ( TarEntryType . RegularFile , "index.json" )
495
+ {
496
+ DataStream = indexStream
497
+ } ;
498
+ await writer . WriteEntryAsync ( indexEntry , cancellationToken ) . ConfigureAwait ( false ) ;
499
+ }
500
+ }
501
+
456
502
private static async Task WriteOciImageToBlobs (
457
503
TarWriter writer ,
458
504
BuiltImage image ,
@@ -577,52 +623,6 @@ private static async Task WriteIndexJsonForMultiArchOciImage(
577
623
}
578
624
}
579
625
580
- private static async Task WriteIndexJsonForOciImage (
581
- TarWriter writer ,
582
- BuiltImage image ,
583
- DestinationImageReference destinationReference ,
584
- CancellationToken cancellationToken )
585
- {
586
- cancellationToken . ThrowIfCancellationRequested ( ) ;
587
-
588
- var manifests = new PlatformSpecificOciManifest [ destinationReference . Tags . Length ] ;
589
- for ( int i = 0 ; i < destinationReference . Tags . Length ; i ++ )
590
- {
591
- var tag = destinationReference . Tags [ i ] ;
592
- manifests [ i ] = new PlatformSpecificOciManifest
593
- {
594
- mediaType = SchemaTypes . OciManifestV1 ,
595
- size = image . Manifest . Length ,
596
- digest = image . ManifestDigest ,
597
- annotations = new Dictionary < string , string >
598
- {
599
- { "io.containerd.image.name" , $ "{ destinationReference . Repository } :{ tag } " } ,
600
- { "org.opencontainers.image.ref.name" , tag }
601
- }
602
- } ;
603
- }
604
-
605
- var index = new ImageIndexV1
606
- {
607
- schemaVersion = 2 ,
608
- mediaType = SchemaTypes . OciImageIndexV1 ,
609
- manifests = manifests
610
- } ;
611
-
612
- var options = new JsonSerializerOptions
613
- {
614
- DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingNull
615
- } ;
616
- using ( MemoryStream indexStream = new ( Encoding . UTF8 . GetBytes ( JsonSerializer . SerializeToNode ( index , options ) ! . ToJsonString ( ) ) ) )
617
- {
618
- PaxTarEntry indexEntry = new ( TarEntryType . RegularFile , "index.json" )
619
- {
620
- DataStream = indexStream
621
- } ;
622
- await writer . WriteEntryAsync ( indexEntry , cancellationToken ) . ConfigureAwait ( false ) ;
623
- }
624
- }
625
-
626
626
private async ValueTask < string ? > GetCommandAsync ( CancellationToken cancellationToken )
627
627
{
628
628
if ( _command != null )
0 commit comments