@@ -20,7 +20,6 @@ internal sealed class ImageBuilder
20
20
21
21
// the mutable internal manifest that we're building by modifying the base and applying customizations
22
22
private readonly ManifestV2 _manifest ;
23
- private readonly string _manifestMediaType ;
24
23
private readonly ImageConfig _baseImageConfig ;
25
24
private readonly ILogger _logger ;
26
25
@@ -33,15 +32,15 @@ internal sealed class ImageBuilder
33
32
public ImageConfig BaseImageConfig => _baseImageConfig ;
34
33
35
34
/// <summary>
36
- /// MediaType of the output manifest.
35
+ /// MediaType of the output manifest. By default, this will be the same as the base image manifest.
37
36
/// </summary>
38
- public string ManifestMediaType => _manifestMediaType ; // output the same media type as the base image manifest.
37
+ public string ManifestMediaType { get ; set ; }
39
38
40
39
internal ImageBuilder ( ManifestV2 manifest , string manifestMediaType , ImageConfig baseImageConfig , ILogger logger )
41
40
{
42
41
_baseImageManifest = manifest ;
43
42
_manifest = new ManifestV2 ( ) { SchemaVersion = manifest . SchemaVersion , Config = manifest . Config , Layers = new ( manifest . Layers ) , MediaType = manifest . MediaType } ;
44
- _manifestMediaType = manifestMediaType ;
43
+ ManifestMediaType = manifestMediaType ;
45
44
_baseImageConfig = baseImageConfig ;
46
45
_logger = logger ;
47
46
}
@@ -71,14 +70,20 @@ internal BuiltImage Build()
71
70
ManifestConfig newManifestConfig = _manifest . Config with
72
71
{
73
72
digest = imageDigest ,
74
- size = imageSize
73
+ size = imageSize ,
74
+ mediaType = ManifestMediaType switch
75
+ {
76
+ SchemaTypes . OciManifestV1 => SchemaTypes . OciImageConfigV1 ,
77
+ SchemaTypes . DockerManifestV2 => SchemaTypes . DockerContainerV1 ,
78
+ _ => SchemaTypes . OciImageConfigV1 // opinion - defaulting to modern here, but really this should never happen
79
+ }
75
80
} ;
76
81
77
82
ManifestV2 newManifest = new ManifestV2 ( )
78
83
{
79
84
Config = newManifestConfig ,
80
85
SchemaVersion = _manifest . SchemaVersion ,
81
- MediaType = _manifest . MediaType ,
86
+ MediaType = ManifestMediaType ,
82
87
Layers = _manifest . Layers
83
88
} ;
84
89
0 commit comments