Skip to content

Commit 31c870e

Browse files
authored
Merge pull request moby#3865 from jedevc/attestation-media-types
2 parents a9e8e39 + 86d89ac commit 31c870e

File tree

9 files changed

+26
-16
lines changed

9 files changed

+26
-16
lines changed

exporter/containerimage/export.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ import (
1414
"github.com/containerd/containerd/images"
1515
"github.com/containerd/containerd/leases"
1616
"github.com/containerd/containerd/platforms"
17-
"github.com/containerd/containerd/remotes"
1817
"github.com/containerd/containerd/remotes/docker"
1918
"github.com/containerd/containerd/rootfs"
20-
intoto "github.com/in-toto/in-toto-golang/in_toto"
2119
"github.com/moby/buildkit/cache"
2220
cacheconfig "github.com/moby/buildkit/cache/config"
2321
"github.com/moby/buildkit/exporter"
@@ -355,8 +353,6 @@ func (e *imageExporterInstance) pushImage(ctx context.Context, src *exporter.Sou
355353
}
356354
}
357355
}
358-
359-
ctx = remotes.WithMediaTypeKeyPrefix(ctx, intoto.PayloadType, "intoto")
360356
return push.Push(ctx, e.opt.SessionManager, sessionID, mprovider, e.opt.ImageWriter.ContentStore(), dgst, targetName, e.insecure, e.opt.RegistryHosts, e.pushByDigest, annotations)
361357
}
362358

exporter/containerimage/writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ func (ic *ImageWriter) commitAttestationsManifest(ctx context.Context, opts *Ima
437437
}
438438
digest := digest.FromBytes(data)
439439
desc := ocispecs.Descriptor{
440-
MediaType: attestationTypes.MediaTypeDockerSchema2AttestationType,
440+
MediaType: intoto.PayloadType,
441441
Digest: digest,
442442
Size: int64(len(data)),
443443
Annotations: map[string]string{

exporter/oci/export.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import (
1111

1212
archiveexporter "github.com/containerd/containerd/images/archive"
1313
"github.com/containerd/containerd/leases"
14-
"github.com/containerd/containerd/remotes"
1514
"github.com/docker/distribution/reference"
16-
intoto "github.com/in-toto/in-toto-golang/in_toto"
1715
"github.com/moby/buildkit/cache"
1816
cacheconfig "github.com/moby/buildkit/cache/config"
1917
"github.com/moby/buildkit/exporter"
@@ -266,7 +264,6 @@ func (e *imageExporterInstance) Export(ctx context.Context, src *exporter.Source
266264
}
267265
report(nil)
268266
} else {
269-
ctx = remotes.WithMediaTypeKeyPrefix(ctx, intoto.PayloadType, "intoto")
270267
store := sessioncontent.NewCallerStore(caller, "export")
271268
if err != nil {
272269
return nil, nil, err

solver/llbsolver/solver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"sync"
1010
"time"
1111

12+
intoto "github.com/in-toto/in-toto-golang/in_toto"
1213
slsa02 "github.com/in-toto/in-toto-golang/in_toto/slsa_provenance/v0.2"
1314
controlapi "github.com/moby/buildkit/api/services/control"
1415
"github.com/moby/buildkit/cache"
@@ -26,7 +27,6 @@ import (
2627
"github.com/moby/buildkit/solver/llbsolver/provenance"
2728
"github.com/moby/buildkit/solver/result"
2829
spb "github.com/moby/buildkit/sourcepolicy/pb"
29-
"github.com/moby/buildkit/util/attestation"
3030
"github.com/moby/buildkit/util/bklog"
3131
"github.com/moby/buildkit/util/compression"
3232
"github.com/moby/buildkit/util/entitlements"
@@ -210,7 +210,7 @@ func (s *Solver) recordBuildHistory(ctx context.Context, id string, req frontend
210210
if err != nil {
211211
return nil, nil, err
212212
}
213-
w, err := s.history.OpenBlobWriter(ctx, attestation.MediaTypeDockerSchema2AttestationType)
213+
w, err := s.history.OpenBlobWriter(ctx, intoto.PayloadType)
214214
if err != nil {
215215
return nil, nil, err
216216
}

util/attestation/types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package attestation
22

33
const (
4-
MediaTypeDockerSchema2AttestationType = "application/vnd.in-toto+json"
5-
64
DockerAnnotationReferenceType = "vnd.docker.reference.type"
75
DockerAnnotationReferenceDigest = "vnd.docker.reference.digest"
86
DockerAnnotationReferenceDescription = "vnd.docker.reference.description"

util/contentutil/copy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
func Copy(ctx context.Context, ingester content.Ingester, provider content.Provider, desc ocispecs.Descriptor, ref string, logger func([]byte)) error {
18+
ctx = RegisterContentPayloadTypes(ctx)
1819
if _, err := retryhandler.New(limited.FetchHandler(ingester, &localFetcher{provider}, ref), logger)(ctx, desc); err != nil {
1920
return err
2021
}
@@ -60,6 +61,7 @@ func (r *rc) Seek(offset int64, whence int) (int64, error) {
6061
}
6162

6263
func CopyChain(ctx context.Context, ingester content.Ingester, provider content.Provider, desc ocispecs.Descriptor) error {
64+
ctx = RegisterContentPayloadTypes(ctx)
6365
var m sync.Mutex
6466
manifestStack := []ocispecs.Descriptor{}
6567

util/contentutil/types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package contentutil
2+
3+
import (
4+
"context"
5+
6+
"github.com/containerd/containerd/remotes"
7+
intoto "github.com/in-toto/in-toto-golang/in_toto"
8+
)
9+
10+
// RegisterContentPayloadTypes registers content types that are not defined by
11+
// default but that we expect to find in registry images.
12+
func RegisterContentPayloadTypes(ctx context.Context) context.Context {
13+
ctx = remotes.WithMediaTypeKeyPrefix(ctx, intoto.PayloadType, "intoto")
14+
return ctx
15+
}

util/imageutil/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/containerd/containerd/reference"
1414
"github.com/containerd/containerd/remotes"
1515
"github.com/containerd/containerd/remotes/docker"
16-
"github.com/moby/buildkit/util/attestation"
16+
intoto "github.com/in-toto/in-toto-golang/in_toto"
1717
"github.com/moby/buildkit/util/contentutil"
1818
"github.com/moby/buildkit/util/leaseutil"
1919
"github.com/moby/buildkit/util/resolver/limited"
@@ -174,7 +174,7 @@ func childrenConfigHandler(provider content.Provider, platform platforms.MatchCo
174174
descs = append(descs, index.Manifests...)
175175
}
176176
case images.MediaTypeDockerSchema2Config, ocispecs.MediaTypeImageConfig, docker.LegacyConfigMediaType,
177-
attestation.MediaTypeDockerSchema2AttestationType:
177+
intoto.PayloadType:
178178
// childless data types.
179179
return nil, nil
180180
default:

util/push/push.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import (
1414
"github.com/containerd/containerd/remotes"
1515
"github.com/containerd/containerd/remotes/docker"
1616
"github.com/docker/distribution/reference"
17+
intoto "github.com/in-toto/in-toto-golang/in_toto"
1718
"github.com/moby/buildkit/session"
18-
"github.com/moby/buildkit/util/attestation"
1919
"github.com/moby/buildkit/util/bklog"
20+
"github.com/moby/buildkit/util/contentutil"
2021
"github.com/moby/buildkit/util/flightcontrol"
2122
"github.com/moby/buildkit/util/imageutil"
2223
"github.com/moby/buildkit/util/progress"
@@ -46,6 +47,7 @@ func Pusher(ctx context.Context, resolver remotes.Resolver, ref string) (remotes
4647
}
4748

4849
func Push(ctx context.Context, sm *session.Manager, sid string, provider content.Provider, manager content.Manager, dgst digest.Digest, ref string, insecure bool, hosts docker.RegistryHosts, byDigest bool, annotations map[digest.Digest]map[string]string) error {
50+
ctx = contentutil.RegisterContentPayloadTypes(ctx)
4951
desc := ocispecs.Descriptor{
5052
Digest: dgst,
5153
}
@@ -250,7 +252,7 @@ func childrenHandler(provider content.Provider) images.HandlerFunc {
250252
case images.MediaTypeDockerSchema2Layer, images.MediaTypeDockerSchema2LayerGzip,
251253
images.MediaTypeDockerSchema2Config, ocispecs.MediaTypeImageConfig,
252254
ocispecs.MediaTypeImageLayer, ocispecs.MediaTypeImageLayerGzip,
253-
attestation.MediaTypeDockerSchema2AttestationType:
255+
intoto.PayloadType:
254256
// childless data types.
255257
return nil, nil
256258
default:

0 commit comments

Comments
 (0)