Skip to content

Commit 86d89ac

Browse files
committed
attestations: move containerd media type warnings
This moves the containerd suppressions for media type warnings from the exporter package into the push and copy packages which allow them to be used by all lower-level buildkit utilities, e.g. tests. Signed-off-by: Justin Chadwell <[email protected]>
1 parent 709b72a commit 86d89ac

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
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/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

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/push/push.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +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"
1819
"github.com/moby/buildkit/util/bklog"
20+
"github.com/moby/buildkit/util/contentutil"
1921
"github.com/moby/buildkit/util/flightcontrol"
2022
"github.com/moby/buildkit/util/imageutil"
2123
"github.com/moby/buildkit/util/progress"
@@ -45,6 +47,7 @@ func Pusher(ctx context.Context, resolver remotes.Resolver, ref string) (remotes
4547
}
4648

4749
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)
4851
desc := ocispecs.Descriptor{
4952
Digest: dgst,
5053
}

0 commit comments

Comments
 (0)