Skip to content

Commit a89f482

Browse files
committed
exporter: remove wrappers for oci data types
opencontainers/image-spec now contains the MediaType field for all of its structs. With this update, we can avoid manually wrapping the internal data types to present this field. This requires updating the expected digest for source-date-epoch, since the ordering of JSON fields is now slightly different :) Signed-off-by: Justin Chadwell <[email protected]>
1 parent 0ccfe62 commit a89f482

File tree

2 files changed

+24
-48
lines changed

2 files changed

+24
-48
lines changed

exporter/containerimage/writer.go

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,11 @@ func (ic *ImageWriter) Commit(ctx context.Context, inp *exporter.Source, session
178178
return nil, err
179179
}
180180

181-
idx := struct {
182-
// MediaType is reserved in the OCI spec but
183-
// excluded from go types.
184-
MediaType string `json:"mediaType,omitempty"`
185-
186-
ocispecs.Index
187-
}{
188-
MediaType: ocispecs.MediaTypeImageIndex,
189-
Index: ocispecs.Index{
190-
Annotations: opts.Annotations.Platform(nil).Index,
191-
Versioned: specs.Versioned{
192-
SchemaVersion: 2,
193-
},
181+
idx := ocispecs.Index{
182+
MediaType: ocispecs.MediaTypeImageIndex,
183+
Annotations: opts.Annotations.Platform(nil).Index,
184+
Versioned: specs.Versioned{
185+
SchemaVersion: 2,
194186
},
195187
}
196188

@@ -386,24 +378,16 @@ func (ic *ImageWriter) commitDistributionManifest(ctx context.Context, opts *Ima
386378
configType = images.MediaTypeDockerSchema2Config
387379
}
388380

389-
mfst := struct {
390-
// MediaType is reserved in the OCI spec but
391-
// excluded from go types.
392-
MediaType string `json:"mediaType,omitempty"`
393-
394-
ocispecs.Manifest
395-
}{
396-
MediaType: manifestType,
397-
Manifest: ocispecs.Manifest{
398-
Annotations: annotations.Manifest,
399-
Versioned: specs.Versioned{
400-
SchemaVersion: 2,
401-
},
402-
Config: ocispecs.Descriptor{
403-
Digest: configDigest,
404-
Size: int64(len(config)),
405-
MediaType: configType,
406-
},
381+
mfst := ocispecs.Manifest{
382+
MediaType: manifestType,
383+
Annotations: annotations.Manifest,
384+
Versioned: specs.Versioned{
385+
SchemaVersion: 2,
386+
},
387+
Config: ocispecs.Descriptor{
388+
Digest: configDigest,
389+
Size: int64(len(config)),
390+
MediaType: configType,
407391
},
408392
}
409393

@@ -499,23 +483,15 @@ func (ic *ImageWriter) commitAttestationsManifest(ctx context.Context, opts *Ima
499483
MediaType: configType,
500484
}
501485

502-
mfst := struct {
503-
// MediaType is reserved in the OCI spec but
504-
// excluded from go types.
505-
MediaType string `json:"mediaType,omitempty"`
506-
507-
ocispecs.Manifest
508-
}{
486+
mfst := ocispecs.Manifest{
509487
MediaType: manifestType,
510-
Manifest: ocispecs.Manifest{
511-
Versioned: specs.Versioned{
512-
SchemaVersion: 2,
513-
},
514-
Config: ocispecs.Descriptor{
515-
Digest: configDigest,
516-
Size: int64(len(config)),
517-
MediaType: configType,
518-
},
488+
Versioned: specs.Versioned{
489+
SchemaVersion: 2,
490+
},
491+
Config: ocispecs.Descriptor{
492+
Digest: configDigest,
493+
Size: int64(len(config)),
494+
MediaType: configType,
519495
},
520496
}
521497

frontend/dockerfile/dockerfile_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6518,7 +6518,7 @@ FROM scratch
65186518
COPY --from=0 / /
65196519
`)
65206520

6521-
const expectedDigest = "sha256:9e36395384d073e711102b13bd0ba4b779ef6afbaf5cadeb77fe77dba8967d1f"
6521+
const expectedDigest = "sha256:23bfe9c494f4b4ae9368d989035c70b3a34aa0bfc991618b3e54dcce2eee4bf8"
65226522

65236523
dir, err := integration.Tmpdir(
65246524
t,

0 commit comments

Comments
 (0)