fixing consistent aliases for OCI spec imports

Signed-off-by: Jeyanthinath Muthuram <jeyanthinath10@gmail.com>
This commit is contained in:
Jeyanthinath Muthuram 2023-05-08 15:27:52 +05:30
parent c651a53558
commit 307b09e7eb
No known key found for this signature in database
GPG key ID: 62E0D5314659FB80
45 changed files with 210 additions and 211 deletions

View file

@ -21,7 +21,7 @@ import (
containerpkg "github.com/docker/docker/container" containerpkg "github.com/docker/docker/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/ioutils"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"
@ -566,7 +566,7 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
hostConfig.Annotations = nil hostConfig.Annotations = nil
} }
var platform *specs.Platform var platform *ocispec.Platform
if versions.GreaterThanOrEqualTo(version, "1.41") { if versions.GreaterThanOrEqualTo(version, "1.41") {
if v := r.Form.Get("platform"); v != "" { if v := r.Form.Get("platform"); v != "" {
p, err := platforms.Parse(v) p, err := platforms.Parse(v)

View file

@ -12,7 +12,7 @@ import (
"github.com/docker/docker/api/server/httputils" "github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
v1 "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -61,7 +61,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
if err != nil { if err != nil {
return err return err
} }
distributionInspect.Descriptor = v1.Descriptor{ distributionInspect.Descriptor = ocispec.Descriptor{
MediaType: descriptor.MediaType, MediaType: descriptor.MediaType,
Digest: descriptor.Digest, Digest: descriptor.Digest,
Size: descriptor.Size, Size: descriptor.Size,
@ -107,7 +107,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
switch mnfstObj := mnfst.(type) { switch mnfstObj := mnfst.(type) {
case *manifestlist.DeserializedManifestList: case *manifestlist.DeserializedManifestList:
for _, m := range mnfstObj.Manifests { for _, m := range mnfstObj.Manifests {
distributionInspect.Platforms = append(distributionInspect.Platforms, v1.Platform{ distributionInspect.Platforms = append(distributionInspect.Platforms, ocispec.Platform{
Architecture: m.Platform.Architecture, Architecture: m.Platform.Architecture,
OS: m.Platform.OS, OS: m.Platform.OS,
OSVersion: m.Platform.OSVersion, OSVersion: m.Platform.OSVersion,
@ -117,7 +117,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
} }
case *schema2.DeserializedManifest: case *schema2.DeserializedManifest:
configJSON, err := blobsrvc.Get(ctx, mnfstObj.Config.Digest) configJSON, err := blobsrvc.Get(ctx, mnfstObj.Config.Digest)
var platform v1.Platform var platform ocispec.Platform
if err == nil { if err == nil {
err := json.Unmarshal(configJSON, &platform) err := json.Unmarshal(configJSON, &platform)
if err == nil && (platform.OS != "" || platform.Architecture != "") { if err == nil && (platform.OS != "" || platform.Architecture != "") {
@ -125,7 +125,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
} }
} }
case *schema1.SignedManifest: case *schema1.SignedManifest:
platform := v1.Platform{ platform := ocispec.Platform{
Architecture: mnfstObj.Architecture, Architecture: mnfstObj.Architecture,
OS: "linux", OS: "linux",
} }

View file

@ -10,7 +10,7 @@ import (
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
dockerimage "github.com/docker/docker/image" dockerimage "github.com/docker/docker/image"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// Backend is all the methods that need to be implemented // Backend is all the methods that need to be implemented
@ -32,12 +32,12 @@ type imageBackend interface {
type importExportBackend interface { type importExportBackend interface {
LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error
ImportImage(ctx context.Context, ref reference.Named, platform *specs.Platform, msg string, layerReader io.Reader, changes []string) (dockerimage.ID, error) ImportImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (dockerimage.ID, error)
ExportImage(ctx context.Context, names []string, outStream io.Writer) error ExportImage(ctx context.Context, names []string, outStream io.Writer) error
} }
type registryBackend interface { type registryBackend interface {
PullImage(ctx context.Context, image, tag string, platform *specs.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error PullImage(ctx context.Context, image, tag string, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
PushImage(ctx context.Context, ref reference.Named, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error PushImage(ctx context.Context, ref reference.Named, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
} }

View file

@ -24,7 +24,7 @@ import (
"github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/progress" "github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/pkg/streamformatter"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -41,7 +41,7 @@ func (ir *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrit
comment = r.Form.Get("message") comment = r.Form.Get("message")
progressErr error progressErr error
output = ioutils.NewWriteFlusher(w) output = ioutils.NewWriteFlusher(w)
platform *specs.Platform platform *ocispec.Platform
) )
defer output.Close() defer output.Close()

View file

@ -6,7 +6,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/pkg/streamformatter"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// PullOption defines different modes for accessing images // PullOption defines different modes for accessing images
@ -42,5 +42,5 @@ type GetImageAndLayerOptions struct {
PullOption PullOption PullOption PullOption
AuthConfig map[string]registry.AuthConfig AuthConfig map[string]registry.AuthConfig
Output io.Writer Output io.Writer
Platform *specs.Platform Platform *ocispec.Platform
} }

View file

@ -3,7 +3,7 @@ package types // import "github.com/docker/docker/api/types"
import ( import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// configs holds structs used for internal communication between the // configs holds structs used for internal communication between the
@ -16,7 +16,7 @@ type ContainerCreateConfig struct {
Config *container.Config Config *container.Config
HostConfig *container.HostConfig HostConfig *container.HostConfig
NetworkingConfig *network.NetworkingConfig NetworkingConfig *network.NetworkingConfig
Platform *specs.Platform Platform *ocispec.Platform
AdjustCPUShares bool AdjustCPUShares bool
} }

View file

@ -1,9 +1,9 @@
package image package image
import specs "github.com/opencontainers/image-spec/specs-go/v1" import ocispec "github.com/opencontainers/image-spec/specs-go/v1"
// GetImageOpts holds parameters to inspect an image. // GetImageOpts holds parameters to inspect an image.
type GetImageOpts struct { type GetImageOpts struct {
Platform *specs.Platform Platform *ocispec.Platform
Details bool Details bool
} }

View file

@ -4,7 +4,7 @@ import (
"encoding/json" "encoding/json"
"net" "net"
v1 "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// ServiceConfig stores daemon registry services configuration. // ServiceConfig stores daemon registry services configuration.
@ -113,8 +113,8 @@ type SearchResults struct {
type DistributionInspect struct { type DistributionInspect struct {
// Descriptor contains information about the manifest, including // Descriptor contains information about the manifest, including
// the content addressable digest // the content addressable digest
Descriptor v1.Descriptor Descriptor ocispec.Descriptor
// Platforms contains the list of platforms supported by the image, // Platforms contains the list of platforms supported by the image,
// obtained by parsing the manifest // obtained by parsing the manifest
Platforms []v1.Platform Platforms []ocispec.Platform
} }

View file

@ -18,7 +18,7 @@ import (
"github.com/moby/buildkit/solver" "github.com/moby/buildkit/solver"
"github.com/moby/buildkit/worker" "github.com/moby/buildkit/worker"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -26,9 +26,9 @@ import (
func ResolveCacheImporterFunc(sm *session.Manager, resolverFunc docker.RegistryHosts, cs content.Store, rs reference.Store, is imagestore.Store) remotecache.ResolveCacheImporterFunc { func ResolveCacheImporterFunc(sm *session.Manager, resolverFunc docker.RegistryHosts, cs content.Store, rs reference.Store, is imagestore.Store) remotecache.ResolveCacheImporterFunc {
upstream := registryremotecache.ResolveCacheImporterFunc(sm, cs, resolverFunc) upstream := registryremotecache.ResolveCacheImporterFunc(sm, cs, resolverFunc)
return func(ctx context.Context, group session.Group, attrs map[string]string) (remotecache.Importer, specs.Descriptor, error) { return func(ctx context.Context, group session.Group, attrs map[string]string) (remotecache.Importer, ocispec.Descriptor, error) {
if dt, err := tryImportLocal(rs, is, attrs["ref"]); err == nil { if dt, err := tryImportLocal(rs, is, attrs["ref"]); err == nil {
return newLocalImporter(dt), specs.Descriptor{}, nil return newLocalImporter(dt), ocispec.Descriptor{}, nil
} }
return upstream(ctx, group, attrs) return upstream(ctx, group, attrs)
} }
@ -59,7 +59,7 @@ type localImporter struct {
dt []byte dt []byte
} }
func (li *localImporter) Resolve(ctx context.Context, _ specs.Descriptor, id string, w worker.Worker) (solver.CacheManager, error) { func (li *localImporter) Resolve(ctx context.Context, _ ocispec.Descriptor, id string, w worker.Worker) (solver.CacheManager, error) {
cc := v1.NewCacheChains() cc := v1.NewCacheChains()
if err := li.importInlineCache(ctx, li.dt, cc); err != nil { if err := li.importInlineCache(ctx, li.dt, cc); err != nil {
return nil, err return nil, err
@ -96,7 +96,7 @@ func (li *localImporter) importInlineCache(ctx context.Context, dt []byte, cc so
layers := v1.DescriptorProvider{} layers := v1.DescriptorProvider{}
for i, diffID := range img.Rootfs.DiffIDs { for i, diffID := range img.Rootfs.DiffIDs {
dgst := digest.Digest(diffID.String()) dgst := digest.Digest(diffID.String())
desc := specs.Descriptor{ desc := ocispec.Descriptor{
Digest: dgst, Digest: dgst,
Size: -1, Size: -1,
MediaType: images.MediaTypeDockerSchema2Layer, MediaType: images.MediaTypeDockerSchema2Layer,
@ -157,6 +157,6 @@ func parseCreatedLayerInfo(img image) ([]string, []string, error) {
type emptyProvider struct { type emptyProvider struct {
} }
func (p *emptyProvider) ReaderAt(ctx context.Context, dec specs.Descriptor) (content.ReaderAt, error) { func (p *emptyProvider) ReaderAt(ctx context.Context, dec ocispec.Descriptor) (content.ReaderAt, error) {
return nil, errors.Errorf("ReaderAt not implemented for empty provider") return nil, errors.Errorf("ReaderAt not implemented for empty provider")
} }

View file

@ -21,7 +21,7 @@ import (
"github.com/moby/buildkit/frontend/dockerfile/instructions" "github.com/moby/buildkit/frontend/dockerfile/instructions"
"github.com/moby/buildkit/frontend/dockerfile/parser" "github.com/moby/buildkit/frontend/dockerfile/parser"
"github.com/moby/buildkit/frontend/dockerfile/shell" "github.com/moby/buildkit/frontend/dockerfile/shell"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/sync/syncmap" "golang.org/x/sync/syncmap"
@ -125,7 +125,7 @@ type Builder struct {
pathCache pathCache pathCache pathCache
containerManager *containerManager containerManager *containerManager
imageProber ImageProber imageProber ImageProber
platform *specs.Platform platform *ocispec.Platform
} }
// newBuilder creates a new Dockerfile builder from an optional dockerfile and a Options. // newBuilder creates a new Dockerfile builder from an optional dockerfile and a Options.

View file

@ -24,7 +24,7 @@ import (
"github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/pkg/streamformatter"
"github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/system"
"github.com/moby/buildkit/frontend/dockerfile/instructions" "github.com/moby/buildkit/frontend/dockerfile/instructions"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -74,7 +74,7 @@ type copier struct {
source builder.Source source builder.Source
pathCache pathCache pathCache pathCache
download sourceDownloader download sourceDownloader
platform *specs.Platform platform *ocispec.Platform
// for cleanup. TODO: having copier.cleanup() is error prone and hard to // for cleanup. TODO: having copier.cleanup() is error prone and hard to
// follow. Code calling performCopy should manage the lifecycle of its params. // follow. Code calling performCopy should manage the lifecycle of its params.
// Copier should take override source as input, not imageMount. // Copier should take override source as input, not imageMount.
@ -86,7 +86,7 @@ func copierFromDispatchRequest(req dispatchRequest, download sourceDownloader, i
platform := req.builder.platform platform := req.builder.platform
if platform == nil { if platform == nil {
// May be nil if not explicitly set in API/dockerfile // May be nil if not explicitly set in API/dockerfile
platform = &specs.Platform{} platform = &ocispec.Platform{}
} }
if platform.OS == "" { if platform.OS == "" {
// Default to the dispatch requests operating system if not explicit in API/dockerfile // Default to the dispatch requests operating system if not explicit in API/dockerfile

View file

@ -28,7 +28,7 @@ import (
"github.com/moby/buildkit/frontend/dockerfile/parser" "github.com/moby/buildkit/frontend/dockerfile/parser"
"github.com/moby/buildkit/frontend/dockerfile/shell" "github.com/moby/buildkit/frontend/dockerfile/shell"
"github.com/moby/sys/signal" "github.com/moby/sys/signal"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -158,7 +158,7 @@ func initializeStage(ctx context.Context, d dispatchRequest, cmd *instructions.S
return err return err
} }
var platform *specs.Platform var platform *ocispec.Platform
if v := cmd.Platform; v != "" { if v := cmd.Platform; v != "" {
v, err := d.getExpandedString(d.shlex, v) v, err := d.getExpandedString(d.shlex, v)
if err != nil { if err != nil {
@ -232,7 +232,7 @@ func (d *dispatchRequest) getExpandedString(shlex *shell.Lex, str string) (strin
return name, nil return name, nil
} }
func (d *dispatchRequest) getImageOrStage(ctx context.Context, name string, platform *specs.Platform) (builder.Image, error) { func (d *dispatchRequest) getImageOrStage(ctx context.Context, name string, platform *ocispec.Platform) (builder.Image, error) {
var localOnly bool var localOnly bool
if im, ok := d.stages.getByName(name); ok { if im, ok := d.stages.getByName(name); ok {
name = im.Image name = im.Image
@ -266,7 +266,7 @@ func (d *dispatchRequest) getImageOrStage(ctx context.Context, name string, plat
return imageMount.Image(), nil return imageMount.Image(), nil
} }
func (d *dispatchRequest) getFromImage(ctx context.Context, shlex *shell.Lex, basename string, platform *specs.Platform) (builder.Image, error) { func (d *dispatchRequest) getFromImage(ctx context.Context, shlex *shell.Lex, basename string, platform *ocispec.Platform) (builder.Image, error) {
name, err := d.getExpandedString(shlex, basename) name, err := d.getExpandedString(shlex, basename)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -8,12 +8,12 @@ import (
"github.com/docker/docker/api/types/backend" "github.com/docker/docker/api/types/backend"
"github.com/docker/docker/builder" "github.com/docker/docker/builder"
dockerimage "github.com/docker/docker/image" dockerimage "github.com/docker/docker/image"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
type getAndMountFunc func(context.Context, string, bool, *specs.Platform) (builder.Image, builder.ROLayer, error) type getAndMountFunc func(context.Context, string, bool, *ocispec.Platform) (builder.Image, builder.ROLayer, error)
// imageSources mounts images and provides a cache for mounted images. It tracks // imageSources mounts images and provides a cache for mounted images. It tracks
// all images so they can be unmounted at the end of the build. // all images so they can be unmounted at the end of the build.
@ -24,7 +24,7 @@ type imageSources struct {
} }
func newImageSources(options builderOptions) *imageSources { func newImageSources(options builderOptions) *imageSources {
getAndMount := func(ctx context.Context, idOrRef string, localOnly bool, platform *specs.Platform) (builder.Image, builder.ROLayer, error) { getAndMount := func(ctx context.Context, idOrRef string, localOnly bool, platform *ocispec.Platform) (builder.Image, builder.ROLayer, error) {
pullOption := backend.PullOptionNoPull pullOption := backend.PullOptionNoPull
if !localOnly { if !localOnly {
if options.Options.PullParent { if options.Options.PullParent {
@ -47,7 +47,7 @@ func newImageSources(options builderOptions) *imageSources {
} }
} }
func (m *imageSources) Get(ctx context.Context, idOrRef string, localOnly bool, platform *specs.Platform) (*imageMount, error) { func (m *imageSources) Get(ctx context.Context, idOrRef string, localOnly bool, platform *ocispec.Platform) (*imageMount, error) {
if im, ok := m.byImageID[idOrRef]; ok { if im, ok := m.byImageID[idOrRef]; ok {
return im, nil return im, nil
} }
@ -71,7 +71,7 @@ func (m *imageSources) Unmount() (retErr error) {
return return
} }
func (m *imageSources) Add(im *imageMount, platform *specs.Platform) { func (m *imageSources) Add(im *imageMount, platform *ocispec.Platform) {
switch im.image { switch im.image {
case nil: case nil:
// Set the platform for scratch images // Set the platform for scratch images

View file

@ -19,7 +19,7 @@ import (
"github.com/docker/docker/pkg/chrootarchive" "github.com/docker/docker/pkg/chrootarchive"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -74,7 +74,7 @@ func (b *Builder) exportImage(state *dispatchState, layer builder.RWLayer, paren
return errors.Errorf("unexpected image type") return errors.Errorf("unexpected image type")
} }
platform := &specs.Platform{ platform := &ocispec.Platform{
OS: parentImage.OS, OS: parentImage.OS,
Architecture: parentImage.Architecture, Architecture: parentImage.Architecture,
Variant: parentImage.Variant, Variant: parentImage.Variant,

View file

@ -9,7 +9,7 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
type configWrapper struct { type configWrapper struct {
@ -20,7 +20,7 @@ type configWrapper struct {
// ContainerCreate creates a new container based on the given configuration. // ContainerCreate creates a new container based on the given configuration.
// It can be associated with a name, but it's not mandatory. // It can be associated with a name, but it's not mandatory.
func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error) { func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) {
var response container.CreateResponse var response container.CreateResponse
if err := cli.NewVersionError("1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil { if err := cli.NewVersionError("1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil {
@ -75,7 +75,7 @@ func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config
// Similar to containerd's platforms.Format(), but does allow components to be // Similar to containerd's platforms.Format(), but does allow components to be
// omitted (e.g. pass "architecture" only, without "os": // omitted (e.g. pass "architecture" only, without "os":
// https://github.com/containerd/containerd/blob/v1.5.2/platforms/platforms.go#L243-L263 // https://github.com/containerd/containerd/blob/v1.5.2/platforms/platforms.go#L243-L263
func formatPlatform(platform *specs.Platform) string { func formatPlatform(platform *ocispec.Platform) string {
if platform == nil { if platform == nil {
return "" return ""
} }

View file

@ -15,7 +15,7 @@ import (
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// CommonAPIClient is the common methods between stable and experimental versions of APIClient. // CommonAPIClient is the common methods between stable and experimental versions of APIClient.
@ -47,7 +47,7 @@ type CommonAPIClient interface {
type ContainerAPIClient interface { type ContainerAPIClient interface {
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, error) ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, error)
ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)

View file

@ -15,7 +15,7 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
v1 "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -91,10 +91,10 @@ func TestServiceCreateCompatiblePlatforms(t *testing.T) {
}, nil }, nil
} else if strings.HasPrefix(req.URL.Path, "/v1.30/distribution/") { } else if strings.HasPrefix(req.URL.Path, "/v1.30/distribution/") {
b, err := json.Marshal(registrytypes.DistributionInspect{ b, err := json.Marshal(registrytypes.DistributionInspect{
Descriptor: v1.Descriptor{ Descriptor: ocispec.Descriptor{
Digest: "sha256:c0537ff6a5218ef531ece93d4984efc99bbf3f7497c0a7726c88e2bb7584dc96", Digest: "sha256:c0537ff6a5218ef531ece93d4984efc99bbf3f7497c0a7726c88e2bb7584dc96",
}, },
Platforms: []v1.Platform{ Platforms: []ocispec.Platform{
{ {
Architecture: "amd64", Architecture: "amd64",
OS: "linux", OS: "linux",
@ -171,7 +171,7 @@ func TestServiceCreateDigestPinning(t *testing.T) {
} else if strings.HasPrefix(req.URL.Path, "/v1.30/distribution/") { } else if strings.HasPrefix(req.URL.Path, "/v1.30/distribution/") {
// resolvable images // resolvable images
b, err := json.Marshal(registrytypes.DistributionInspect{ b, err := json.Marshal(registrytypes.DistributionInspect{
Descriptor: v1.Descriptor{ Descriptor: ocispec.Descriptor{
Digest: digest.Digest(dgst), Digest: digest.Digest(dgst),
}, },
}) })

View file

@ -27,7 +27,7 @@ import (
"github.com/docker/docker/plugin" "github.com/docker/docker/plugin"
volumeopts "github.com/docker/docker/volume/service/opts" volumeopts "github.com/docker/docker/volume/service/opts"
"github.com/moby/swarmkit/v2/agent/exec" "github.com/moby/swarmkit/v2/agent/exec"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// Backend defines the executor component for a swarm agent. // Backend defines the executor component for a swarm agent.
@ -75,7 +75,7 @@ type VolumeBackend interface {
// ImageBackend is used by an executor to perform image operations // ImageBackend is used by an executor to perform image operations
type ImageBackend interface { type ImageBackend interface {
PullImage(ctx context.Context, image, tag string, platform *specs.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error PullImage(ctx context.Context, image, tag string, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
GetRepository(context.Context, reference.Named, *registry.AuthConfig) (distribution.Repository, error) GetRepository(context.Context, reference.Named, *registry.AuthConfig) (distribution.Repository, error)
GetImage(ctx context.Context, refOrID string, options opts.GetImageOpts) (*image.Image, error) GetImage(ctx context.Context, refOrID string, options opts.GetImageOpts) (*image.Image, error)
} }

View file

@ -19,7 +19,7 @@ import (
"github.com/moby/buildkit/util/attestation" "github.com/moby/buildkit/util/attestation"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/identity" "github.com/opencontainers/image-spec/identity"
v1 "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -87,7 +87,7 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions)
continue continue
} }
err := images.Walk(ctx, images.HandlerFunc(func(ctx context.Context, desc v1.Descriptor) ([]v1.Descriptor, error) { err := images.Walk(ctx, images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
if images.IsIndexType(desc.MediaType) { if images.IsIndexType(desc.MediaType) {
return images.Children(ctx, contentStore, desc) return images.Children(ctx, contentStore, desc)
} }
@ -418,7 +418,7 @@ func setupLabelFilter(store content.Store, fltrs filters.Args) (func(image image
// processing more content (otherwise it will run for all children). // processing more content (otherwise it will run for all children).
// It will be returned once a matching config is found. // It will be returned once a matching config is found.
errFoundConfig := errors.New("success, found matching config") errFoundConfig := errors.New("success, found matching config")
err := images.Dispatch(ctx, presentChildrenHandler(store, images.HandlerFunc(func(ctx context.Context, desc v1.Descriptor) (subdescs []v1.Descriptor, err error) { err := images.Dispatch(ctx, presentChildrenHandler(store, images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error) {
if !images.IsConfigType(desc.MediaType) { if !images.IsConfigType(desc.MediaType) {
return nil, nil return nil, nil
} }
@ -511,8 +511,8 @@ func computeSharedSize(chainIDs []digest.Digest, layers map[digest.Digest]int, s
// getManifestPlatform returns a platform specified by the manifest descriptor // getManifestPlatform returns a platform specified by the manifest descriptor
// or reads it from its config. // or reads it from its config.
func getManifestPlatform(ctx context.Context, store content.Provider, manifestDesc, configDesc v1.Descriptor) (v1.Platform, error) { func getManifestPlatform(ctx context.Context, store content.Provider, manifestDesc, configDesc ocispec.Descriptor) (ocispec.Platform, error) {
var platform v1.Platform var platform ocispec.Platform
if manifestDesc.Platform != nil { if manifestDesc.Platform != nil {
platform = *manifestDesc.Platform platform = *manifestDesc.Platform
} else { } else {
@ -527,7 +527,7 @@ func getManifestPlatform(ctx context.Context, store content.Provider, manifestDe
// isImageManifest returns true if the manifest has any layer that is a known image layer. // isImageManifest returns true if the manifest has any layer that is a known image layer.
// Some manifests use the image media type for compatibility, even if they are not a real image. // Some manifests use the image media type for compatibility, even if they are not a real image.
func isImageManifest(mfst v1.Manifest) bool { func isImageManifest(mfst ocispec.Manifest) bool {
for _, l := range mfst.Layers { for _, l := range mfst.Layers {
if images.IsLayerType(l.MediaType) { if images.IsLayerType(l.MediaType) {
return true return true
@ -537,7 +537,7 @@ func isImageManifest(mfst v1.Manifest) bool {
} }
// readConfig reads content pointed by the descriptor and unmarshals it into a specified output. // readConfig reads content pointed by the descriptor and unmarshals it into a specified output.
func readConfig(ctx context.Context, store content.Provider, desc v1.Descriptor, out interface{}) error { func readConfig(ctx context.Context, store content.Provider, desc ocispec.Descriptor, out interface{}) error {
data, err := content.ReadBlob(ctx, store, desc) data, err := content.ReadBlob(ctx, store, desc)
if err != nil { if err != nil {
return errors.Wrapf(err, "failed to read config content") return errors.Wrapf(err, "failed to read config content")

View file

@ -14,13 +14,13 @@ import (
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/pkg/streamformatter"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
// PullImage initiates a pull operation. image is the repository name to pull, and // PullImage initiates a pull operation. image is the repository name to pull, and
// tagOrDigest may be either empty, or indicate a specific tag or digest to pull. // tagOrDigest may be either empty, or indicate a specific tag or digest to pull.
func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string, platform *specs.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error { func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error {
var opts []containerd.RemoteOpt var opts []containerd.RemoteOpt
if platform != nil { if platform != nil {
opts = append(opts, containerd.WithPlatform(platforms.Format(*platform))) opts = append(opts, containerd.WithPlatform(platforms.Format(*platform)))
@ -49,7 +49,7 @@ func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string,
opts = append(opts, containerd.WithResolver(resolver)) opts = append(opts, containerd.WithResolver(resolver))
jobs := newJobs() jobs := newJobs()
h := images.HandlerFunc(func(ctx context.Context, desc specs.Descriptor) ([]specs.Descriptor, error) { h := images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
if desc.MediaType != images.MediaTypeDockerSchema1Manifest { if desc.MediaType != images.MediaTypeDockerSchema1Manifest {
jobs.Add(desc) jobs.Add(desc)
} }

View file

@ -7,11 +7,11 @@ import (
"github.com/containerd/containerd/leases" "github.com/containerd/containerd/leases"
"github.com/containerd/containerd/platforms" "github.com/containerd/containerd/platforms"
"github.com/opencontainers/image-spec/identity" "github.com/opencontainers/image-spec/identity"
v1 "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// PrepareSnapshot prepares a snapshot from a parent image for a container // PrepareSnapshot prepares a snapshot from a parent image for a container
func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *v1.Platform) error { func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *ocispec.Platform) error {
desc, err := i.resolveDescriptor(ctx, parentImage) desc, err := i.resolveDescriptor(ctx, parentImage)
if err != nil { if err != nil {
return err return err

View file

@ -19,7 +19,7 @@ import (
"github.com/docker/docker/image" "github.com/docker/docker/image"
"github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/runconfig" "github.com/docker/docker/runconfig"
v1 "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/opencontainers/selinux/go-selinux" "github.com/opencontainers/selinux/go-selinux"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -74,7 +74,7 @@ func (daemon *Daemon) containerCreate(ctx context.Context, opts createOpts) (con
} }
if img != nil { if img != nil {
p := maximumSpec() p := maximumSpec()
imgPlat := v1.Platform{ imgPlat := ocispec.Platform{
OS: img.OS, OS: img.OS,
Architecture: img.Architecture, Architecture: img.Architecture,
Variant: img.Variant, Variant: img.Variant,
@ -117,7 +117,7 @@ func (daemon *Daemon) create(ctx context.Context, opts createOpts) (retC *contai
var ( var (
ctr *container.Container ctr *container.Container
img *image.Image img *image.Image
imgManifest *v1.Descriptor imgManifest *ocispec.Descriptor
imgID image.ID imgID image.ID
err error err error
os = runtime.GOOS os = runtime.GOOS
@ -345,7 +345,7 @@ func verifyNetworkingConfig(nwConfig *networktypes.NetworkingConfig) error {
} }
// maximumSpec returns the distribution platform with maximum compatibility for the current node. // maximumSpec returns the distribution platform with maximum compatibility for the current node.
func maximumSpec() v1.Platform { func maximumSpec() ocispec.Platform {
p := platforms.DefaultSpec() p := platforms.DefaultSpec()
if p.Architecture == "amd64" { if p.Architecture == "amd64" {
p.Variant = archvariant.AMD64Variant() p.Variant = archvariant.AMD64Variant()

View file

@ -16,7 +16,7 @@ import (
"github.com/docker/docker/image" "github.com/docker/docker/image"
"github.com/docker/docker/layer" "github.com/docker/docker/layer"
"github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/archive"
v1 "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// ImageService is a temporary interface to assist in the migration to the // ImageService is a temporary interface to assist in the migration to the
@ -25,7 +25,7 @@ import (
type ImageService interface { type ImageService interface {
// Images // Images
PullImage(ctx context.Context, name, tag string, platform *v1.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error PullImage(ctx context.Context, name, tag string, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
PushImage(ctx context.Context, ref reference.Named, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error PushImage(ctx context.Context, ref reference.Named, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
CreateImage(config []byte, parent string) (builder.Image, error) CreateImage(config []byte, parent string) (builder.Image, error)
ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error) ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)
@ -36,7 +36,7 @@ type ImageService interface {
LogImageEvent(imageID, refName, action string) LogImageEvent(imageID, refName, action string)
CountImages() int CountImages() int
ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error)
ImportImage(ctx context.Context, ref reference.Named, platform *v1.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error) ImportImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error)
TagImage(ctx context.Context, imageID image.ID, newTag reference.Named) error TagImage(ctx context.Context, imageID image.ID, newTag reference.Named) error
GetImage(ctx context.Context, refOrID string, options imagetype.GetImageOpts) (*image.Image, error) GetImage(ctx context.Context, refOrID string, options imagetype.GetImageOpts) (*image.Image, error)
ImageHistory(ctx context.Context, name string) ([]*imagetype.HistoryResponseItem, error) ImageHistory(ctx context.Context, name string) ([]*imagetype.HistoryResponseItem, error)
@ -45,8 +45,8 @@ type ImageService interface {
// Containerd related methods // Containerd related methods
PrepareSnapshot(ctx context.Context, id string, image string, platform *v1.Platform) error PrepareSnapshot(ctx context.Context, id string, image string, platform *ocispec.Platform) error
GetImageManifest(ctx context.Context, refOrID string, options imagetype.GetImageOpts) (*v1.Descriptor, error) GetImageManifest(ctx context.Context, refOrID string, options imagetype.GetImageOpts) (*ocispec.Descriptor, error)
// Layers // Layers

View file

@ -17,8 +17,7 @@ import (
"github.com/docker/docker/image" "github.com/docker/docker/image"
"github.com/docker/docker/layer" "github.com/docker/docker/layer"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -40,19 +39,19 @@ func (e ErrImageDoesNotExist) Error() string {
func (e ErrImageDoesNotExist) NotFound() {} func (e ErrImageDoesNotExist) NotFound() {}
type manifestList struct { type manifestList struct {
Manifests []specs.Descriptor `json:"manifests"` Manifests []ocispec.Descriptor `json:"manifests"`
} }
type manifest struct { type manifest struct {
Config specs.Descriptor `json:"config"` Config ocispec.Descriptor `json:"config"`
} }
func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, image string, platform *v1.Platform) error { func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, image string, platform *ocispec.Platform) error {
// Only makes sense when conatinerd image store is used // Only makes sense when conatinerd image store is used
panic("not implemented") panic("not implemented")
} }
func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.Image, platform specs.Platform) (bool, error) { func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.Image, platform ocispec.Platform) (bool, error) {
logger := logrus.WithField("image", img.ID).WithField("desiredPlatform", platforms.Format(platform)) logger := logrus.WithField("image", img.ID).WithField("desiredPlatform", platforms.Format(platform))
ls, leaseErr := i.leases.ListResources(ctx, leases.Lease{ID: imageKey(img.ID().String())}) ls, leaseErr := i.leases.ListResources(ctx, leases.Lease{ID: imageKey(img.ID().String())})
@ -81,7 +80,7 @@ func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.I
continue continue
} }
ra, err := i.content.ReaderAt(ctx, specs.Descriptor{Digest: digest.Digest(r.ID)}) ra, err := i.content.ReaderAt(ctx, ocispec.Descriptor{Digest: digest.Digest(r.ID)})
if err != nil { if err != nil {
if cerrdefs.IsNotFound(err) { if cerrdefs.IsNotFound(err) {
continue continue
@ -107,12 +106,12 @@ func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.I
for _, md := range ml.Manifests { for _, md := range ml.Manifests {
switch md.MediaType { switch md.MediaType {
case specs.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest: case ocispec.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest:
default: default:
continue continue
} }
p := specs.Platform{ p := ocispec.Platform{
Architecture: md.Platform.Architecture, Architecture: md.Platform.Architecture,
OS: md.Platform.OS, OS: md.Platform.OS,
Variant: md.Platform.Variant, Variant: md.Platform.Variant,
@ -124,7 +123,7 @@ func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.I
// Here we have a platform match for the referenced manifest, let's make sure the manifest is actually for the image config we are using. // Here we have a platform match for the referenced manifest, let's make sure the manifest is actually for the image config we are using.
ra, err := i.content.ReaderAt(ctx, specs.Descriptor{Digest: md.Digest}) ra, err := i.content.ReaderAt(ctx, ocispec.Descriptor{Digest: md.Digest})
if err != nil { if err != nil {
logger.WithField("otherDigest", md.Digest).WithError(err).Error("Could not get reader for manifest") logger.WithField("otherDigest", md.Digest).WithError(err).Error("Could not get reader for manifest")
continue continue
@ -192,7 +191,7 @@ func (i *ImageService) GetImage(ctx context.Context, refOrID string, options ima
return img, nil return img, nil
} }
func (i *ImageService) GetImageManifest(ctx context.Context, refOrID string, options imagetypes.GetImageOpts) (*v1.Descriptor, error) { func (i *ImageService) GetImageManifest(ctx context.Context, refOrID string, options imagetypes.GetImageOpts) (*ocispec.Descriptor, error) {
panic("not implemented") panic("not implemented")
} }
@ -202,7 +201,7 @@ func (i *ImageService) getImage(ctx context.Context, refOrID string, options ima
return return
} }
imgPlat := specs.Platform{ imgPlat := ocispec.Platform{
OS: retImg.OS, OS: retImg.OS,
Architecture: retImg.Architecture, Architecture: retImg.Architecture,
Variant: retImg.Variant, Variant: retImg.Variant,
@ -272,16 +271,16 @@ func (i *ImageService) getImage(ctx context.Context, refOrID string, options ima
// The reason for this is that CPU variant is not even if the official image config spec as of this writing. // The reason for this is that CPU variant is not even if the official image config spec as of this writing.
// See: https://github.com/opencontainers/image-spec/pull/809 // See: https://github.com/opencontainers/image-spec/pull/809
// Since Docker tends to compare platforms from the image config, we need to handle this case. // Since Docker tends to compare platforms from the image config, we need to handle this case.
func OnlyPlatformWithFallback(p specs.Platform) platforms.Matcher { func OnlyPlatformWithFallback(p ocispec.Platform) platforms.Matcher {
return &onlyFallbackMatcher{only: platforms.Only(p), p: platforms.Normalize(p)} return &onlyFallbackMatcher{only: platforms.Only(p), p: platforms.Normalize(p)}
} }
type onlyFallbackMatcher struct { type onlyFallbackMatcher struct {
only platforms.Matcher only platforms.Matcher
p specs.Platform p ocispec.Platform
} }
func (m *onlyFallbackMatcher) Match(other specs.Platform) bool { func (m *onlyFallbackMatcher) Match(other ocispec.Platform) bool {
if m.only.Match(other) { if m.only.Match(other) {
// It matches, no reason to fallback // It matches, no reason to fallback
return true return true

View file

@ -19,7 +19,7 @@ import (
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/system"
registrypkg "github.com/docker/docker/registry" registrypkg "github.com/docker/docker/registry"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -144,7 +144,7 @@ func newROLayerForImage(img *image.Image, layerStore layer.Store) (builder.ROLay
} }
// TODO: could this use the regular daemon PullImage ? // TODO: could this use the regular daemon PullImage ?
func (i *ImageService) pullForBuilder(ctx context.Context, name string, authConfigs map[string]registry.AuthConfig, output io.Writer, platform *specs.Platform) (*image.Image, error) { func (i *ImageService) pullForBuilder(ctx context.Context, name string, authConfigs map[string]registry.AuthConfig, output io.Writer, platform *ocispec.Platform) (*image.Image, error) {
ref, err := reference.ParseNormalizedNamed(name) ref, err := reference.ParseNormalizedNamed(name)
if err != nil { if err != nil {
return nil, err return nil, err
@ -169,7 +169,7 @@ func (i *ImageService) pullForBuilder(ctx context.Context, name string, authConf
img, err := i.GetImage(ctx, name, imagetypes.GetImageOpts{Platform: platform}) img, err := i.GetImage(ctx, name, imagetypes.GetImageOpts{Platform: platform})
if errdefs.IsNotFound(err) && img != nil && platform != nil { if errdefs.IsNotFound(err) && img != nil && platform != nil {
imgPlat := specs.Platform{ imgPlat := ocispec.Platform{
OS: img.OS, OS: img.OS,
Architecture: img.BaseImgArch(), Architecture: img.BaseImgArch(),
Variant: img.BaseImgVariant(), Variant: img.BaseImgVariant(),

View file

@ -16,7 +16,7 @@ import (
"github.com/docker/docker/layer" "github.com/docker/docker/layer"
"github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/system"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// ImportImage imports an image, getting the archived layer data from layerReader. // ImportImage imports an image, getting the archived layer data from layerReader.
@ -26,7 +26,7 @@ import (
// If the platform is nil, the default host platform is used. // If the platform is nil, the default host platform is used.
// Message is used as the image's history comment. // Message is used as the image's history comment.
// Image configuration is derived from the dockerfile instructions in changes. // Image configuration is derived from the dockerfile instructions in changes.
func (i *ImageService) ImportImage(ctx context.Context, newRef reference.Named, platform *specs.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error) { func (i *ImageService) ImportImage(ctx context.Context, newRef reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error) {
if platform == nil { if platform == nil {
def := platforms.DefaultSpec() def := platforms.DefaultSpec()
platform = &def platform = &def

View file

@ -17,14 +17,14 @@ import (
"github.com/docker/docker/pkg/progress" "github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/pkg/streamformatter"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
// PullImage initiates a pull operation. image is the repository name to pull, and // PullImage initiates a pull operation. image is the repository name to pull, and
// tag may be either empty, or indicate a specific tag to pull. // tag may be either empty, or indicate a specific tag to pull.
func (i *ImageService) PullImage(ctx context.Context, image, tag string, platform *specs.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error { func (i *ImageService) PullImage(ctx context.Context, image, tag string, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error {
start := time.Now() start := time.Now()
// Special case: "pull -a" may send an image name with a // Special case: "pull -a" may send an image name with a
// trailing :. This is ugly, but let's not break API // trailing :. This is ugly, but let's not break API
@ -79,7 +79,7 @@ func (i *ImageService) PullImage(ctx context.Context, image, tag string, platfor
return nil return nil
} }
func (i *ImageService) pullImageWithReference(ctx context.Context, ref reference.Named, platform *specs.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error { func (i *ImageService) pullImageWithReference(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error {
// Include a buffer so that slow client connections don't affect // Include a buffer so that slow client connections don't affect
// transfer performance. // transfer performance.
progressChan := make(chan progress.Progress, 100) progressChan := make(chan progress.Progress, 100)

View file

@ -3,30 +3,30 @@ package images
import ( import (
"testing" "testing"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
func TestOnlyPlatformWithFallback(t *testing.T) { func TestOnlyPlatformWithFallback(t *testing.T) {
p := specs.Platform{ p := ocispec.Platform{
OS: "linux", OS: "linux",
Architecture: "arm", Architecture: "arm",
Variant: "v8", Variant: "v8",
} }
// Check no variant // Check no variant
assert.Assert(t, OnlyPlatformWithFallback(p).Match(specs.Platform{ assert.Assert(t, OnlyPlatformWithFallback(p).Match(ocispec.Platform{
OS: p.OS, OS: p.OS,
Architecture: p.Architecture, Architecture: p.Architecture,
})) }))
// check with variant // check with variant
assert.Assert(t, OnlyPlatformWithFallback(p).Match(specs.Platform{ assert.Assert(t, OnlyPlatformWithFallback(p).Match(ocispec.Platform{
OS: p.OS, OS: p.OS,
Architecture: p.Architecture, Architecture: p.Architecture,
Variant: p.Variant, Variant: p.Variant,
})) }))
// Make sure non-matches are false. // Make sure non-matches are false.
assert.Assert(t, !OnlyPlatformWithFallback(p).Match(specs.Platform{ assert.Assert(t, !OnlyPlatformWithFallback(p).Match(ocispec.Platform{
OS: p.OS, OS: p.OS,
Architecture: "amd64", Architecture: "amd64",
})) }))

View file

@ -14,7 +14,7 @@ import (
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/docker/docker/image" "github.com/docker/docker/image"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
v1 "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
@ -96,7 +96,7 @@ func TestContentStoreForPull(t *testing.T) {
} }
data := []byte(`{}`) data := []byte(`{}`)
desc := v1.Descriptor{ desc := ocispec.Descriptor{
Digest: digest.Canonical.FromBytes(data), Digest: digest.Canonical.FromBytes(data),
Size: int64(len(data)), Size: int64(len(data)),
} }

View file

@ -19,7 +19,7 @@ import (
refstore "github.com/docker/docker/reference" refstore "github.com/docker/docker/reference"
registrypkg "github.com/docker/docker/registry" registrypkg "github.com/docker/docker/registry"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -60,7 +60,7 @@ type ImagePullConfig struct {
// types is used. // types is used.
Schema2Types []string Schema2Types []string
// Platform is the requested platform of the image being pulled // Platform is the requested platform of the image being pulled
Platform *specs.Platform Platform *ocispec.Platform
} }
// ImagePushConfig stores push configuration. // ImagePushConfig stores push configuration.
@ -141,7 +141,7 @@ func rootFSFromConfig(c []byte) (*image.RootFS, error) {
return unmarshalledConfig.RootFS, nil return unmarshalledConfig.RootFS, nil
} }
func platformFromConfig(c []byte) (*specs.Platform, error) { func platformFromConfig(c []byte) (*ocispec.Platform, error) {
var unmarshalledConfig image.Image var unmarshalledConfig image.Image
if err := json.Unmarshal(c, &unmarshalledConfig); err != nil { if err := json.Unmarshal(c, &unmarshalledConfig); err != nil {
return nil, err return nil, err
@ -154,7 +154,7 @@ func platformFromConfig(c []byte) (*specs.Platform, error) {
if !system.IsOSSupported(os) { if !system.IsOSSupported(os) {
return nil, errors.Wrapf(system.ErrNotSupportedOperatingSystem, "image operating system %q cannot be used on this platform", os) return nil, errors.Wrapf(system.ErrNotSupportedOperatingSystem, "image operating system %q cannot be used on this platform", os)
} }
return &specs.Platform{ return &ocispec.Platform{
OS: os, OS: os,
Architecture: unmarshalledConfig.Architecture, Architecture: unmarshalledConfig.Architecture,
Variant: unmarshalledConfig.Variant, Variant: unmarshalledConfig.Variant,

View file

@ -18,7 +18,7 @@ import (
"github.com/docker/distribution/reference" "github.com/docker/distribution/reference"
"github.com/docker/docker/registry" "github.com/docker/docker/registry"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -97,7 +97,7 @@ func hasDistributionSource(label, repo string) bool {
return false return false
} }
func (m *manifestStore) getLocal(ctx context.Context, desc specs.Descriptor, ref reference.Named) (distribution.Manifest, error) { func (m *manifestStore) getLocal(ctx context.Context, desc ocispec.Descriptor, ref reference.Named) (distribution.Manifest, error) {
ra, err := m.local.ReaderAt(ctx, desc) ra, err := m.local.ReaderAt(ctx, desc)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "error getting content store reader") return nil, errors.Wrap(err, "error getting content store reader")
@ -153,7 +153,7 @@ func (m *manifestStore) getLocal(ctx context.Context, desc specs.Descriptor, ref
return manifest, nil return manifest, nil
} }
func (m *manifestStore) getMediaType(ctx context.Context, desc specs.Descriptor) (string, error) { func (m *manifestStore) getMediaType(ctx context.Context, desc ocispec.Descriptor) (string, error) {
ra, err := m.local.ReaderAt(ctx, desc) ra, err := m.local.ReaderAt(ctx, desc)
if err != nil { if err != nil {
return "", errors.Wrap(err, "error getting reader to detect media type") return "", errors.Wrap(err, "error getting reader to detect media type")
@ -167,7 +167,7 @@ func (m *manifestStore) getMediaType(ctx context.Context, desc specs.Descriptor)
return mt, nil return mt, nil
} }
func (m *manifestStore) Get(ctx context.Context, desc specs.Descriptor, ref reference.Named) (distribution.Manifest, error) { func (m *manifestStore) Get(ctx context.Context, desc ocispec.Descriptor, ref reference.Named) (distribution.Manifest, error) {
l := log.G(ctx) l := log.G(ctx)
if desc.MediaType == "" { if desc.MediaType == "" {
@ -227,7 +227,7 @@ func (m *manifestStore) Get(ctx context.Context, desc specs.Descriptor, ref refe
return manifest, nil return manifest, nil
} }
func (m *manifestStore) Put(ctx context.Context, manifest distribution.Manifest, desc specs.Descriptor, w content.Writer, ref reference.Named) error { func (m *manifestStore) Put(ctx context.Context, manifest distribution.Manifest, desc ocispec.Descriptor, w content.Writer, ref reference.Named) error {
mt, payload, err := manifest.Payload() mt, payload, err := manifest.Payload()
if err != nil { if err != nil {
return err return err
@ -282,12 +282,12 @@ func detectManifestBlobMediaType(dt []byte) (string, error) {
// So pretty much if we don't have a media type we can fall back to OCI. // So pretty much if we don't have a media type we can fall back to OCI.
// This does have a special fallback for schema1 manifests just because it is easy to detect. // This does have a special fallback for schema1 manifests just because it is easy to detect.
switch mfst.MediaType { switch mfst.MediaType {
case schema2.MediaTypeManifest, specs.MediaTypeImageManifest: case schema2.MediaTypeManifest, ocispec.MediaTypeImageManifest:
if mfst.Manifests != nil || mfst.FSLayers != nil { if mfst.Manifests != nil || mfst.FSLayers != nil {
return "", fmt.Errorf(`media-type: %q should not have "manifests" or "fsLayers"`, mfst.MediaType) return "", fmt.Errorf(`media-type: %q should not have "manifests" or "fsLayers"`, mfst.MediaType)
} }
return mfst.MediaType, nil return mfst.MediaType, nil
case manifestlist.MediaTypeManifestList, specs.MediaTypeImageIndex: case manifestlist.MediaTypeManifestList, ocispec.MediaTypeImageIndex:
if mfst.Config != nil || mfst.Layers != nil || mfst.FSLayers != nil { if mfst.Config != nil || mfst.Layers != nil || mfst.FSLayers != nil {
return "", fmt.Errorf(`media-type: %q should not have "config", "layers", or "fsLayers"`, mfst.MediaType) return "", fmt.Errorf(`media-type: %q should not have "config", "layers", or "fsLayers"`, mfst.MediaType)
} }
@ -307,10 +307,10 @@ func detectManifestBlobMediaType(dt []byte) (string, error) {
return schema1.MediaTypeManifest, nil return schema1.MediaTypeManifest, nil
case mfst.Config != nil && mfst.Manifests == nil && mfst.FSLayers == nil, case mfst.Config != nil && mfst.Manifests == nil && mfst.FSLayers == nil,
mfst.Layers != nil && mfst.Manifests == nil && mfst.FSLayers == nil: mfst.Layers != nil && mfst.Manifests == nil && mfst.FSLayers == nil:
return specs.MediaTypeImageManifest, nil return ocispec.MediaTypeImageManifest, nil
case mfst.Config == nil && mfst.Layers == nil && mfst.FSLayers == nil: case mfst.Config == nil && mfst.Layers == nil && mfst.FSLayers == nil:
// fallback to index // fallback to index
return specs.MediaTypeImageIndex, nil return ocispec.MediaTypeImageIndex, nil
} }
return "", errors.New("media-type: cannot determine") return "", errors.New("media-type: cannot determine")
} }

View file

@ -20,7 +20,7 @@ import (
"github.com/docker/distribution/reference" "github.com/docker/distribution/reference"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/assert/cmp" "gotest.tools/v3/assert/cmp"
@ -128,12 +128,12 @@ func (w *testingContentWriterWrapper) Commit(ctx context.Context, size int64, dg
} }
func TestManifestStore(t *testing.T) { func TestManifestStore(t *testing.T) {
ociManifest := &specs.Manifest{} ociManifest := &ocispec.Manifest{}
serialized, err := json.Marshal(ociManifest) serialized, err := json.Marshal(ociManifest)
assert.NilError(t, err) assert.NilError(t, err)
dgst := digest.Canonical.FromBytes(serialized) dgst := digest.Canonical.FromBytes(serialized)
setupTest := func(t *testing.T) (reference.Named, specs.Descriptor, *mockManifestGetter, *manifestStore, content.Store, func(*testing.T)) { setupTest := func(t *testing.T) (reference.Named, ocispec.Descriptor, *mockManifestGetter, *manifestStore, content.Store, func(*testing.T)) {
root, err := os.MkdirTemp("", strings.ReplaceAll(t.Name(), "/", "_")) root, err := os.MkdirTemp("", strings.ReplaceAll(t.Name(), "/", "_"))
assert.NilError(t, err) assert.NilError(t, err)
defer func() { defer func() {
@ -147,7 +147,7 @@ func TestManifestStore(t *testing.T) {
mg := &mockManifestGetter{manifests: make(map[digest.Digest]distribution.Manifest)} mg := &mockManifestGetter{manifests: make(map[digest.Digest]distribution.Manifest)}
store := &manifestStore{local: cs, remote: mg} store := &manifestStore{local: cs, remote: mg}
desc := specs.Descriptor{Digest: dgst, MediaType: specs.MediaTypeImageManifest, Size: int64(len(serialized))} desc := ocispec.Descriptor{Digest: dgst, MediaType: ocispec.MediaTypeImageManifest, Size: int64(len(serialized))}
ref, err := reference.Parse("foo/bar") ref, err := reference.Parse("foo/bar")
assert.NilError(t, err) assert.NilError(t, err)
@ -159,10 +159,10 @@ func TestManifestStore(t *testing.T) {
ctx := context.Background() ctx := context.Background()
m, _, err := distribution.UnmarshalManifest(specs.MediaTypeImageManifest, serialized) m, _, err := distribution.UnmarshalManifest(ocispec.MediaTypeImageManifest, serialized)
assert.NilError(t, err) assert.NilError(t, err)
writeManifest := func(t *testing.T, cs ContentStore, desc specs.Descriptor, opts ...content.Opt) { writeManifest := func(t *testing.T, cs ContentStore, desc ocispec.Descriptor, opts ...content.Opt) {
ingestKey := remotes.MakeRefKey(ctx, desc) ingestKey := remotes.MakeRefKey(ctx, desc)
w, err := cs.Writer(ctx, content.WithDescriptor(desc), content.WithRef(ingestKey)) w, err := cs.Writer(ctx, content.WithDescriptor(desc), content.WithRef(ingestKey))
assert.NilError(t, err) assert.NilError(t, err)
@ -185,7 +185,7 @@ func TestManifestStore(t *testing.T) {
} }
// All tests should end up with no active ingest // All tests should end up with no active ingest
checkIngest := func(t *testing.T, cs content.Store, desc specs.Descriptor) { checkIngest := func(t *testing.T, cs content.Store, desc ocispec.Descriptor) {
ingestKey := remotes.MakeRefKey(ctx, desc) ingestKey := remotes.MakeRefKey(ctx, desc)
_, err := cs.Status(ctx, ingestKey) _, err := cs.Status(ctx, ingestKey)
assert.Check(t, cerrdefs.IsNotFound(err), err) assert.Check(t, cerrdefs.IsNotFound(err), err)
@ -354,9 +354,9 @@ func TestDetectManifestBlobMediaType(t *testing.T) {
} }
cases := map[string]testCase{ cases := map[string]testCase{
"mediaType is set": {[]byte(`{"mediaType": "bananas"}`), "bananas"}, "mediaType is set": {[]byte(`{"mediaType": "bananas"}`), "bananas"},
"oci manifest": {[]byte(`{"config": {}}`), specs.MediaTypeImageManifest}, "oci manifest": {[]byte(`{"config": {}}`), ocispec.MediaTypeImageManifest},
"schema1": {[]byte(`{"fsLayers": []}`), schema1.MediaTypeManifest}, "schema1": {[]byte(`{"fsLayers": []}`), schema1.MediaTypeManifest},
"oci index fallback": {[]byte(`{}`), specs.MediaTypeImageIndex}, "oci index fallback": {[]byte(`{}`), ocispec.MediaTypeImageIndex},
// Make sure we prefer mediaType // Make sure we prefer mediaType
"mediaType and config set": {[]byte(`{"mediaType": "bananas", "config": {}}`), "bananas"}, "mediaType and config set": {[]byte(`{"mediaType": "bananas", "config": {}}`), "bananas"},
"mediaType and fsLayers set": {[]byte(`{"mediaType": "bananas", "fsLayers": []}`), "bananas"}, "mediaType and fsLayers set": {[]byte(`{"mediaType": "bananas", "fsLayers": []}`), "bananas"},
@ -394,7 +394,7 @@ func TestDetectManifestBlobMediaTypeInvalid(t *testing.T) {
`media-type: "application/vnd.docker.distribution.manifest.v2+json" should not have "manifests" or "fsLayers"`, `media-type: "application/vnd.docker.distribution.manifest.v2+json" should not have "manifests" or "fsLayers"`,
}, },
"oci manifest mediaType with manifests": { "oci manifest mediaType with manifests": {
[]byte(`{"mediaType": "` + specs.MediaTypeImageManifest + `","manifests":[]}`), []byte(`{"mediaType": "` + ocispec.MediaTypeImageManifest + `","manifests":[]}`),
`media-type: "application/vnd.oci.image.manifest.v1+json" should not have "manifests" or "fsLayers"`, `media-type: "application/vnd.oci.image.manifest.v1+json" should not have "manifests" or "fsLayers"`,
}, },
"manifest list mediaType with fsLayers": { "manifest list mediaType with fsLayers": {
@ -402,11 +402,11 @@ func TestDetectManifestBlobMediaTypeInvalid(t *testing.T) {
`media-type: "application/vnd.docker.distribution.manifest.list.v2+json" should not have "config", "layers", or "fsLayers"`, `media-type: "application/vnd.docker.distribution.manifest.list.v2+json" should not have "config", "layers", or "fsLayers"`,
}, },
"index mediaType with layers": { "index mediaType with layers": {
[]byte(`{"mediaType": "` + specs.MediaTypeImageIndex + `","layers":[]}`), []byte(`{"mediaType": "` + ocispec.MediaTypeImageIndex + `","layers":[]}`),
`media-type: "application/vnd.oci.image.index.v1+json" should not have "config", "layers", or "fsLayers"`, `media-type: "application/vnd.oci.image.index.v1+json" should not have "config", "layers", or "fsLayers"`,
}, },
"index mediaType with config": { "index mediaType with config": {
[]byte(`{"mediaType": "` + specs.MediaTypeImageIndex + `","config":{}}`), []byte(`{"mediaType": "` + ocispec.MediaTypeImageIndex + `","config":{}}`),
`media-type: "application/vnd.oci.image.index.v1+json" should not have "config", "layers", or "fsLayers"`, `media-type: "application/vnd.oci.image.index.v1+json" should not have "config", "layers", or "fsLayers"`,
}, },
"config and manifests": { "config and manifests": {

View file

@ -31,7 +31,7 @@ import (
refstore "github.com/docker/docker/reference" refstore "github.com/docker/docker/reference"
"github.com/docker/docker/registry" "github.com/docker/docker/registry"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
archvariant "github.com/tonistiigi/go-archvariant" archvariant "github.com/tonistiigi/go-archvariant"
@ -348,7 +348,7 @@ func (ld *layerDescriptor) Registered(diffID layer.DiffID) {
_ = ld.metadataService.Add(diffID, metadata.V2Metadata{Digest: ld.digest, SourceRepository: ld.repoInfo.Name.Name()}) _ = ld.metadataService.Add(diffID, metadata.V2Metadata{Digest: ld.digest, SourceRepository: ld.repoInfo.Name.Name()})
} }
func (p *puller) pullTag(ctx context.Context, ref reference.Named, platform *specs.Platform) (tagUpdated bool, err error) { func (p *puller) pullTag(ctx context.Context, ref reference.Named, platform *ocispec.Platform) (tagUpdated bool, err error) {
var ( var (
tagOrDigest string // Used for logging/progress only tagOrDigest string // Used for logging/progress only
dgst digest.Digest dgst digest.Digest
@ -381,7 +381,7 @@ func (p *puller) pullTag(ctx context.Context, ref reference.Named, platform *spe
"remote": ref, "remote": ref,
})) }))
desc := specs.Descriptor{ desc := ocispec.Descriptor{
MediaType: mt, MediaType: mt,
Digest: dgst, Digest: dgst,
Size: size, Size: size,
@ -519,7 +519,7 @@ func (p *puller) validateMediaType(mediaType string) error {
return invalidManifestClassError{mediaType, configClass} return invalidManifestClassError{mediaType, configClass}
} }
func (p *puller) pullSchema1(ctx context.Context, ref reference.Reference, unverifiedManifest *schema1.SignedManifest, platform *specs.Platform) (id digest.Digest, manifestDigest digest.Digest, err error) { func (p *puller) pullSchema1(ctx context.Context, ref reference.Reference, unverifiedManifest *schema1.SignedManifest, platform *ocispec.Platform) (id digest.Digest, manifestDigest digest.Digest, err error) {
if platform != nil { if platform != nil {
// Early bath if the requested OS doesn't match that of the configuration. // Early bath if the requested OS doesn't match that of the configuration.
// This avoids doing the download, only to potentially fail later. // This avoids doing the download, only to potentially fail later.
@ -616,7 +616,7 @@ func checkSupportedMediaType(mediaType string) error {
return unsupportedMediaTypeError{MediaType: mediaType} return unsupportedMediaTypeError{MediaType: mediaType}
} }
func (p *puller) pullSchema2Layers(ctx context.Context, target distribution.Descriptor, layers []distribution.Descriptor, platform *specs.Platform) (id digest.Digest, err error) { func (p *puller) pullSchema2Layers(ctx context.Context, target distribution.Descriptor, layers []distribution.Descriptor, platform *ocispec.Platform) (id digest.Digest, err error) {
if _, err := p.config.ImageStore.Get(ctx, target.Digest); err == nil { if _, err := p.config.ImageStore.Get(ctx, target.Digest); err == nil {
// If the image already exists locally, no need to pull // If the image already exists locally, no need to pull
// anything. // anything.
@ -673,7 +673,7 @@ func (p *puller) pullSchema2Layers(ctx context.Context, target distribution.Desc
downloadedRootFS *image.RootFS // rootFS from registered layers downloadedRootFS *image.RootFS // rootFS from registered layers
configRootFS *image.RootFS // rootFS from configuration configRootFS *image.RootFS // rootFS from configuration
release func() // release resources from rootFS download release func() // release resources from rootFS download
configPlatform *specs.Platform // for LCOW when registering downloaded layers configPlatform *ocispec.Platform // for LCOW when registering downloaded layers
) )
layerStoreOS := runtime.GOOS layerStoreOS := runtime.GOOS
@ -798,7 +798,7 @@ func (p *puller) pullSchema2Layers(ctx context.Context, target distribution.Desc
return imageID, nil return imageID, nil
} }
func (p *puller) pullSchema2(ctx context.Context, ref reference.Named, mfst *schema2.DeserializedManifest, platform *specs.Platform) (id digest.Digest, manifestDigest digest.Digest, err error) { func (p *puller) pullSchema2(ctx context.Context, ref reference.Named, mfst *schema2.DeserializedManifest, platform *ocispec.Platform) (id digest.Digest, manifestDigest digest.Digest, err error) {
manifestDigest, err = schema2ManifestDigest(ref, mfst) manifestDigest, err = schema2ManifestDigest(ref, mfst)
if err != nil { if err != nil {
return "", "", err return "", "", err
@ -807,7 +807,7 @@ func (p *puller) pullSchema2(ctx context.Context, ref reference.Named, mfst *sch
return id, manifestDigest, err return id, manifestDigest, err
} }
func (p *puller) pullOCI(ctx context.Context, ref reference.Named, mfst *ocischema.DeserializedManifest, platform *specs.Platform) (id digest.Digest, manifestDigest digest.Digest, err error) { func (p *puller) pullOCI(ctx context.Context, ref reference.Named, mfst *ocischema.DeserializedManifest, platform *ocispec.Platform) (id digest.Digest, manifestDigest digest.Digest, err error) {
manifestDigest, err = schema2ManifestDigest(ref, mfst) manifestDigest, err = schema2ManifestDigest(ref, mfst)
if err != nil { if err != nil {
return "", "", err return "", "", err
@ -816,7 +816,7 @@ func (p *puller) pullOCI(ctx context.Context, ref reference.Named, mfst *ocische
return id, manifestDigest, err return id, manifestDigest, err
} }
func receiveConfig(configChan <-chan []byte, errChan <-chan error) ([]byte, *image.RootFS, *specs.Platform, error) { func receiveConfig(configChan <-chan []byte, errChan <-chan error) ([]byte, *image.RootFS, *ocispec.Platform, error) {
select { select {
case configJSON := <-configChan: case configJSON := <-configChan:
rootfs, err := rootFSFromConfig(configJSON) rootfs, err := rootFSFromConfig(configJSON)
@ -837,13 +837,13 @@ func receiveConfig(configChan <-chan []byte, errChan <-chan error) ([]byte, *ima
// pullManifestList handles "manifest lists" which point to various // pullManifestList handles "manifest lists" which point to various
// platform-specific manifests. // platform-specific manifests.
func (p *puller) pullManifestList(ctx context.Context, ref reference.Named, mfstList *manifestlist.DeserializedManifestList, pp *specs.Platform) (id digest.Digest, manifestListDigest digest.Digest, err error) { func (p *puller) pullManifestList(ctx context.Context, ref reference.Named, mfstList *manifestlist.DeserializedManifestList, pp *ocispec.Platform) (id digest.Digest, manifestListDigest digest.Digest, err error) {
manifestListDigest, err = schema2ManifestDigest(ref, mfstList) manifestListDigest, err = schema2ManifestDigest(ref, mfstList)
if err != nil { if err != nil {
return "", "", err return "", "", err
} }
var platform specs.Platform var platform ocispec.Platform
if pp != nil { if pp != nil {
platform = *pp platform = *pp
} }
@ -856,7 +856,7 @@ func (p *puller) pullManifestList(ctx context.Context, ref reference.Named, mfst
return "", "", err return "", "", err
} }
desc := specs.Descriptor{ desc := ocispec.Descriptor{
Digest: match.Digest, Digest: match.Digest,
Size: match.Size, Size: match.Size,
MediaType: match.MediaType, MediaType: match.MediaType,
@ -942,7 +942,7 @@ func (p *puller) pullSchema2Config(ctx context.Context, dgst digest.Digest) (con
} }
type noMatchesErr struct { type noMatchesErr struct {
platform specs.Platform platform ocispec.Platform
} }
func (e noMatchesErr) Error() string { func (e noMatchesErr) Error() string {
@ -1081,13 +1081,13 @@ func createDownloadFile() (*os.File, error) {
return os.CreateTemp("", "GetImageBlob") return os.CreateTemp("", "GetImageBlob")
} }
func toOCIPlatform(p manifestlist.PlatformSpec) *specs.Platform { func toOCIPlatform(p manifestlist.PlatformSpec) *ocispec.Platform {
// distribution pkg does define platform as pointer so this hack for empty struct // distribution pkg does define platform as pointer so this hack for empty struct
// is necessary. This is temporary until correct OCI image-spec package is used. // is necessary. This is temporary until correct OCI image-spec package is used.
if p.OS == "" && p.Architecture == "" && p.Variant == "" && p.OSVersion == "" && p.OSFeatures == nil && p.Features == nil { if p.OS == "" && p.Architecture == "" && p.Variant == "" && p.OSVersion == "" && p.OSFeatures == nil && p.Features == nil {
return nil return nil
} }
return &specs.Platform{ return &ocispec.Platform{
OS: p.OS, OS: p.OS,
Architecture: p.Architecture, Architecture: p.Architecture,
Variant: p.Variant, Variant: p.Variant,
@ -1097,7 +1097,7 @@ func toOCIPlatform(p manifestlist.PlatformSpec) *specs.Platform {
} }
// maximumSpec returns the distribution platform with maximum compatibility for the current node. // maximumSpec returns the distribution platform with maximum compatibility for the current node.
func maximumSpec() specs.Platform { func maximumSpec() ocispec.Platform {
p := platforms.DefaultSpec() p := platforms.DefaultSpec()
if p.Architecture == "amd64" { if p.Architecture == "amd64" {
p.Variant = archvariant.AMD64Variant() p.Variant = archvariant.AMD64Variant()

View file

@ -20,7 +20,7 @@ import (
"github.com/docker/docker/image" "github.com/docker/docker/image"
"github.com/docker/docker/registry" "github.com/docker/docker/registry"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -194,7 +194,7 @@ func TestValidateManifest(t *testing.T) {
} }
func TestFormatPlatform(t *testing.T) { func TestFormatPlatform(t *testing.T) {
var platform specs.Platform var platform ocispec.Platform
var result = formatPlatform(platform) var result = formatPlatform(platform)
if strings.HasPrefix(result, "unknown") { if strings.HasPrefix(result, "unknown") {
t.Fatal("expected formatPlatform to show a known platform") t.Fatal("expected formatPlatform to show a known platform")

View file

@ -10,7 +10,7 @@ import (
"github.com/containerd/containerd/platforms" "github.com/containerd/containerd/platforms"
"github.com/docker/distribution" "github.com/docker/distribution"
"github.com/docker/distribution/manifest/manifestlist" "github.com/docker/distribution/manifest/manifestlist"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -19,7 +19,7 @@ func (ld *layerDescriptor) open(ctx context.Context) (distribution.ReadSeekClose
return blobs.Open(ctx, ld.digest) return blobs.Open(ctx, ld.digest)
} }
func filterManifests(manifests []manifestlist.ManifestDescriptor, p specs.Platform) []manifestlist.ManifestDescriptor { func filterManifests(manifests []manifestlist.ManifestDescriptor, p ocispec.Platform) []manifestlist.ManifestDescriptor {
p = platforms.Normalize(withDefault(p)) p = platforms.Normalize(withDefault(p))
m := platforms.Only(p) m := platforms.Only(p)
var matches []manifestlist.ManifestDescriptor var matches []manifestlist.ManifestDescriptor
@ -53,7 +53,7 @@ func checkImageCompatibility(imageOS, imageOSVersion string) error {
return nil return nil
} }
func withDefault(p specs.Platform) specs.Platform { func withDefault(p ocispec.Platform) ocispec.Platform {
def := maximumSpec() def := maximumSpec()
if p.OS == "" { if p.OS == "" {
p.OS = def.OS p.OS = def.OS
@ -65,7 +65,7 @@ func withDefault(p specs.Platform) specs.Platform {
return p return p
} }
func formatPlatform(platform specs.Platform) string { func formatPlatform(platform ocispec.Platform) string {
if platform.OS == "" { if platform.OS == "" {
platform = platforms.DefaultSpec() platform = platforms.DefaultSpec()
} }

View file

@ -18,7 +18,7 @@ import (
"github.com/docker/distribution/manifest/schema2" "github.com/docker/distribution/manifest/schema2"
"github.com/docker/distribution/registry/client/transport" "github.com/docker/distribution/registry/client/transport"
"github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/system"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -65,7 +65,7 @@ func (ld *layerDescriptor) open(ctx context.Context) (distribution.ReadSeekClose
return rsc, err return rsc, err
} }
func filterManifests(manifests []manifestlist.ManifestDescriptor, p specs.Platform) []manifestlist.ManifestDescriptor { func filterManifests(manifests []manifestlist.ManifestDescriptor, p ocispec.Platform) []manifestlist.ManifestDescriptor {
version := osversion.Get() version := osversion.Get()
osVersion := fmt.Sprintf("%d.%d.%d", version.MajorVersion, version.MinorVersion, version.Build) osVersion := fmt.Sprintf("%d.%d.%d", version.MajorVersion, version.MinorVersion, version.Build)
logrus.Debugf("will prefer Windows entries with version %s", osVersion) logrus.Debugf("will prefer Windows entries with version %s", osVersion)
@ -139,7 +139,7 @@ func checkImageCompatibility(imageOS, imageOSVersion string) error {
return nil return nil
} }
func formatPlatform(platform specs.Platform) string { func formatPlatform(platform ocispec.Platform) string {
if platform.OS == "" { if platform.OS == "" {
platform = platforms.DefaultSpec() platform = platforms.DefaultSpec()
} }

View file

@ -17,7 +17,7 @@ import (
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
ctr "github.com/docker/docker/integration/internal/container" ctr "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/oci" "github.com/docker/docker/oci"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/poll" "gotest.tools/v3/poll"
@ -475,7 +475,7 @@ func TestCreateDifferentPlatform(t *testing.T) {
assert.Assert(t, img.Architecture != "") assert.Assert(t, img.Architecture != "")
t.Run("different os", func(t *testing.T) { t.Run("different os", func(t *testing.T) {
p := specs.Platform{ p := ocispec.Platform{
OS: img.Os + "DifferentOS", OS: img.Os + "DifferentOS",
Architecture: img.Architecture, Architecture: img.Architecture,
Variant: img.Variant, Variant: img.Variant,
@ -484,7 +484,7 @@ func TestCreateDifferentPlatform(t *testing.T) {
assert.Assert(t, client.IsErrNotFound(err), err) assert.Assert(t, client.IsErrNotFound(err), err)
}) })
t.Run("different cpu arch", func(t *testing.T) { t.Run("different cpu arch", func(t *testing.T) {
p := specs.Platform{ p := ocispec.Platform{
OS: img.Os, OS: img.Os,
Architecture: img.Architecture + "DifferentArch", Architecture: img.Architecture + "DifferentArch",
Variant: img.Variant, Variant: img.Variant,

View file

@ -19,7 +19,7 @@ import (
"github.com/docker/docker/testutil/registry" "github.com/docker/docker/testutil/registry"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go" "github.com/opencontainers/image-spec/specs-go"
imagespec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/skip" "gotest.tools/v3/skip"
) )
@ -36,7 +36,7 @@ func TestImagePullPlatformInvalid(t *testing.T) {
assert.Assert(t, errdefs.IsInvalidParameter(err)) assert.Assert(t, errdefs.IsInvalidParameter(err))
} }
func createTestImage(ctx context.Context, t testing.TB, store content.Store) imagespec.Descriptor { func createTestImage(ctx context.Context, t testing.TB, store content.Store) ocispec.Descriptor {
w, err := store.Writer(ctx, content.WithRef("layer")) w, err := store.Writer(ctx, content.WithRef("layer"))
assert.NilError(t, err) assert.NilError(t, err)
defer w.Close() defer w.Close()
@ -55,11 +55,11 @@ func createTestImage(ctx context.Context, t testing.TB, store content.Store) ima
platform := platforms.DefaultSpec() platform := platforms.DefaultSpec()
img := imagespec.Image{ img := ocispec.Image{
Architecture: platform.Architecture, Architecture: platform.Architecture,
OS: platform.OS, OS: platform.OS,
RootFS: imagespec.RootFS{Type: "layers", DiffIDs: []digest.Digest{layerDigest}}, RootFS: ocispec.RootFS{Type: "layers", DiffIDs: []digest.Digest{layerDigest}},
Config: imagespec.ImageConfig{WorkingDir: "/"}, Config: ocispec.ImageConfig{WorkingDir: "/"},
} }
imgJSON, err := json.Marshal(img) imgJSON, err := json.Marshal(img)
assert.NilError(t, err) assert.NilError(t, err)
@ -77,17 +77,17 @@ func createTestImage(ctx context.Context, t testing.TB, store content.Store) ima
info, err := store.Info(ctx, layerDigest) info, err := store.Info(ctx, layerDigest)
assert.NilError(t, err) assert.NilError(t, err)
manifest := imagespec.Manifest{ manifest := ocispec.Manifest{
Versioned: specs.Versioned{ Versioned: specs.Versioned{
SchemaVersion: 2, SchemaVersion: 2,
}, },
MediaType: images.MediaTypeDockerSchema2Manifest, MediaType: images.MediaTypeDockerSchema2Manifest,
Config: imagespec.Descriptor{ Config: ocispec.Descriptor{
MediaType: images.MediaTypeDockerSchema2Config, MediaType: images.MediaTypeDockerSchema2Config,
Digest: configDigest, Digest: configDigest,
Size: int64(len(imgJSON)), Size: int64(len(imgJSON)),
}, },
Layers: []imagespec.Descriptor{{ Layers: []ocispec.Descriptor{{
MediaType: images.MediaTypeDockerSchema2Layer, MediaType: images.MediaTypeDockerSchema2Layer,
Digest: layerDigest, Digest: layerDigest,
Size: info.Size, Size: info.Size,
@ -107,7 +107,7 @@ func createTestImage(ctx context.Context, t testing.TB, store content.Store) ima
manifestDigest := w.Digest() manifestDigest := w.Digest()
w.Close() w.Close()
return imagespec.Descriptor{ return ocispec.Descriptor{
MediaType: images.MediaTypeDockerSchema2Manifest, MediaType: images.MediaTypeDockerSchema2Manifest,
Digest: manifestDigest, Digest: manifestDigest,
Size: int64(len(manifestJSON)), Size: int64(len(manifestJSON)),

View file

@ -9,7 +9,7 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/client" "github.com/docker/docker/client"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -20,7 +20,7 @@ type TestContainerConfig struct {
Config *container.Config Config *container.Config
HostConfig *container.HostConfig HostConfig *container.HostConfig
NetworkingConfig *network.NetworkingConfig NetworkingConfig *network.NetworkingConfig
Platform *specs.Platform Platform *ocispec.Platform
} }
// create creates a container with the specified options // create creates a container with the specified options

View file

@ -8,7 +8,7 @@ import (
networktypes "github.com/docker/docker/api/types/network" networktypes "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/strslice" "github.com/docker/docker/api/types/strslice"
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
) )
// WithName sets the name of the container // WithName sets the name of the container
@ -204,7 +204,7 @@ func WithExtraHost(extraHost string) func(*TestContainerConfig) {
} }
// WithPlatform specifies the desired platform the image should have. // WithPlatform specifies the desired platform the image should have.
func WithPlatform(p *specs.Platform) func(*TestContainerConfig) { func WithPlatform(p *ocispec.Platform) func(*TestContainerConfig) {
return func(c *TestContainerConfig) { return func(c *TestContainerConfig) {
c.Platform = p c.Platform = p
} }

View file

@ -23,7 +23,7 @@ import (
"github.com/docker/docker/testutil/fixtures/plugin" "github.com/docker/docker/testutil/fixtures/plugin"
"github.com/docker/docker/testutil/registry" "github.com/docker/docker/testutil/registry"
"github.com/docker/docker/testutil/request" "github.com/docker/docker/testutil/request"
v1 "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/skip" "gotest.tools/v3/skip"
@ -306,7 +306,7 @@ func TestPluginBackCompatMediaTypes(t *testing.T) {
assert.NilError(t, err) assert.NilError(t, err)
defer rdr.Close() defer rdr.Close()
var m v1.Manifest var m ocispec.Manifest
assert.NilError(t, json.NewDecoder(rdr).Decode(&m)) assert.NilError(t, json.NewDecoder(rdr).Decode(&m))
assert.Check(t, is.Equal(m.MediaType, images.MediaTypeDockerSchema2Manifest)) assert.Check(t, is.Equal(m.MediaType, images.MediaTypeDockerSchema2Manifest))
assert.Check(t, is.Len(m.Layers, 1)) assert.Check(t, is.Len(m.Layers, 1))

View file

@ -29,7 +29,7 @@ import (
libcontainerdtypes "github.com/docker/docker/libcontainerd/types" libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
"github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/ioutils"
"github.com/hashicorp/go-multierror" "github.com/hashicorp/go-multierror"
v1 "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
specs "github.com/opencontainers/runtime-spec/specs-go" specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -439,12 +439,12 @@ func (t *task) CreateCheckpoint(ctx context.Context, checkpointDir string, exit
if err != nil { if err != nil {
return errdefs.System(errors.Wrapf(err, "failed to retrieve checkpoint data")) return errdefs.System(errors.Wrapf(err, "failed to retrieve checkpoint data"))
} }
var index v1.Index var index ocispec.Index
if err := json.Unmarshal(b, &index); err != nil { if err := json.Unmarshal(b, &index); err != nil {
return errdefs.System(errors.Wrapf(err, "failed to decode checkpoint data")) return errdefs.System(errors.Wrapf(err, "failed to decode checkpoint data"))
} }
var cpDesc *v1.Descriptor var cpDesc *ocispec.Descriptor
for _, m := range index.Manifests { for _, m := range index.Manifests {
m := m m := m
if m.MediaType == images.MediaTypeContainerd1Checkpoint { if m.MediaType == images.MediaTypeContainerd1Checkpoint {

View file

@ -35,7 +35,7 @@ import (
v2 "github.com/docker/docker/plugin/v2" v2 "github.com/docker/docker/plugin/v2"
"github.com/moby/sys/mount" "github.com/moby/sys/mount"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -165,19 +165,19 @@ func (pm *Manager) Privileges(ctx context.Context, ref reference.Named, metaHead
configSeen bool configSeen bool
) )
h := func(ctx context.Context, desc specs.Descriptor) ([]specs.Descriptor, error) { h := func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
switch desc.MediaType { switch desc.MediaType {
case schema2.MediaTypeManifest, specs.MediaTypeImageManifest: case schema2.MediaTypeManifest, ocispec.MediaTypeImageManifest:
data, err := content.ReadBlob(ctx, pm.blobStore, desc) data, err := content.ReadBlob(ctx, pm.blobStore, desc)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "error reading image manifest from blob store for %s", ref) return nil, errors.Wrapf(err, "error reading image manifest from blob store for %s", ref)
} }
var m specs.Manifest var m ocispec.Manifest
if err := json.Unmarshal(data, &m); err != nil { if err := json.Unmarshal(data, &m); err != nil {
return nil, errors.Wrapf(err, "error unmarshaling image manifest for %s", ref) return nil, errors.Wrapf(err, "error unmarshaling image manifest for %s", ref)
} }
return []specs.Descriptor{m.Config}, nil return []ocispec.Descriptor{m.Config}, nil
case schema2.MediaTypePluginConfig: case schema2.MediaTypePluginConfig:
configSeen = true configSeen = true
data, err := content.ReadBlob(ctx, pm.blobStore, desc) data, err := content.ReadBlob(ctx, pm.blobStore, desc)
@ -383,7 +383,7 @@ func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header
out, waitProgress := setupProgressOutput(outStream, cancel) out, waitProgress := setupProgressOutput(outStream, cancel)
defer waitProgress() defer waitProgress()
progressHandler := images.HandlerFunc(func(ctx context.Context, desc specs.Descriptor) ([]specs.Descriptor, error) { progressHandler := images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
logrus.WithField("mediaType", desc.MediaType).WithField("digest", desc.Digest.String()).Debug("Preparing to push plugin layer") logrus.WithField("mediaType", desc.MediaType).WithField("digest", desc.Digest.String()).Debug("Preparing to push plugin layer")
id := stringid.TruncateID(desc.Digest.String()) id := stringid.TruncateID(desc.Digest.String())
pj.add(remotes.MakeRefKey(ctx, desc), id) pj.add(remotes.MakeRefKey(ctx, desc), id)
@ -469,7 +469,7 @@ func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header
// even though this is set on the descriptor // even though this is set on the descriptor
// The OCI types do not have this field. // The OCI types do not have this field.
type manifest struct { type manifest struct {
specs.Manifest ocispec.Manifest
MediaType string `json:"mediaType,omitempty"` MediaType string `json:"mediaType,omitempty"`
} }
@ -482,7 +482,7 @@ func buildManifest(ctx context.Context, s content.Manager, config digest.Digest,
if err != nil { if err != nil {
return m, errors.Wrapf(err, "error reading plugin config content for digest %s", config) return m, errors.Wrapf(err, "error reading plugin config content for digest %s", config)
} }
m.Config = specs.Descriptor{ m.Config = ocispec.Descriptor{
MediaType: mediaTypePluginConfig, MediaType: mediaTypePluginConfig,
Size: configInfo.Size, Size: configInfo.Size,
Digest: configInfo.Digest, Digest: configInfo.Digest,
@ -493,7 +493,7 @@ func buildManifest(ctx context.Context, s content.Manager, config digest.Digest,
if err != nil { if err != nil {
return m, errors.Wrapf(err, "error fetching info for content digest %s", l) return m, errors.Wrapf(err, "error fetching info for content digest %s", l)
} }
m.Layers = append(m.Layers, specs.Descriptor{ m.Layers = append(m.Layers, ocispec.Descriptor{
MediaType: images.MediaTypeDockerSchema2LayerGzip, // TODO: This is assuming everything is a gzip compressed layer, but that may not be true. MediaType: images.MediaTypeDockerSchema2LayerGzip, // TODO: This is assuming everything is a gzip compressed layer, but that may not be true.
Digest: l, Digest: l,
Size: info.Size, Size: info.Size,
@ -504,12 +504,12 @@ func buildManifest(ctx context.Context, s content.Manager, config digest.Digest,
// getManifestDescriptor gets the OCI descriptor for a manifest // getManifestDescriptor gets the OCI descriptor for a manifest
// It will generate a manifest if one does not exist // It will generate a manifest if one does not exist
func (pm *Manager) getManifestDescriptor(ctx context.Context, p *v2.Plugin) (specs.Descriptor, error) { func (pm *Manager) getManifestDescriptor(ctx context.Context, p *v2.Plugin) (ocispec.Descriptor, error) {
logger := logrus.WithField("plugin", p.Name()).WithField("digest", p.Manifest) logger := logrus.WithField("plugin", p.Name()).WithField("digest", p.Manifest)
if p.Manifest != "" { if p.Manifest != "" {
info, err := pm.blobStore.Info(ctx, p.Manifest) info, err := pm.blobStore.Info(ctx, p.Manifest)
if err == nil { if err == nil {
desc := specs.Descriptor{ desc := ocispec.Descriptor{
Size: info.Size, Size: info.Size,
Digest: info.Digest, Digest: info.Digest,
MediaType: images.MediaTypeDockerSchema2Manifest, MediaType: images.MediaTypeDockerSchema2Manifest,
@ -524,7 +524,7 @@ func (pm *Manager) getManifestDescriptor(ctx context.Context, p *v2.Plugin) (spe
manifest, err := buildManifest(ctx, pm.blobStore, p.Config, p.Blobsums) manifest, err := buildManifest(ctx, pm.blobStore, p.Config, p.Blobsums)
if err != nil { if err != nil {
return specs.Descriptor{}, err return ocispec.Descriptor{}, err
} }
desc, err := writeManifest(ctx, pm.blobStore, &manifest) desc, err := writeManifest(ctx, pm.blobStore, &manifest)
@ -538,9 +538,9 @@ func (pm *Manager) getManifestDescriptor(ctx context.Context, p *v2.Plugin) (spe
return desc, nil return desc, nil
} }
func writeManifest(ctx context.Context, cs content.Store, m *manifest) (specs.Descriptor, error) { func writeManifest(ctx context.Context, cs content.Store, m *manifest) (ocispec.Descriptor, error) {
platform := platforms.DefaultSpec() platform := platforms.DefaultSpec()
desc := specs.Descriptor{ desc := ocispec.Descriptor{
MediaType: images.MediaTypeDockerSchema2Manifest, MediaType: images.MediaTypeDockerSchema2Manifest,
Platform: &platform, Platform: &platform,
} }

View file

@ -19,7 +19,7 @@ import (
"github.com/docker/docker/pkg/progress" "github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -88,8 +88,8 @@ func (pm *Manager) fetch(ctx context.Context, ref reference.Named, auth *registr
headers := http.Header{} headers := http.Header{}
headers.Add("Accept", images.MediaTypeDockerSchema2Manifest) headers.Add("Accept", images.MediaTypeDockerSchema2Manifest)
headers.Add("Accept", images.MediaTypeDockerSchema2ManifestList) headers.Add("Accept", images.MediaTypeDockerSchema2ManifestList)
headers.Add("Accept", specs.MediaTypeImageManifest) headers.Add("Accept", ocispec.MediaTypeImageManifest)
headers.Add("Accept", specs.MediaTypeImageIndex) headers.Add("Accept", ocispec.MediaTypeImageIndex)
resolver, _ = pm.newResolver(ctx, nil, auth, headers, false) resolver, _ = pm.newResolver(ctx, nil, auth, headers, false)
if resolver != nil { if resolver != nil {
resolved, desc, err = resolver.Resolve(ctx, withDomain.String()) resolved, desc, err = resolver.Resolve(ctx, withDomain.String())
@ -118,12 +118,12 @@ func (pm *Manager) fetch(ctx context.Context, ref reference.Named, auth *registr
// if there are multiple layers to fetch we may end up extracting layers in the wrong // if there are multiple layers to fetch we may end up extracting layers in the wrong
// order. // order.
func applyLayer(cs content.Store, dir string, out progress.Output) images.HandlerFunc { func applyLayer(cs content.Store, dir string, out progress.Output) images.HandlerFunc {
return func(ctx context.Context, desc specs.Descriptor) ([]specs.Descriptor, error) { return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
switch desc.MediaType { switch desc.MediaType {
case case
specs.MediaTypeImageLayer, ocispec.MediaTypeImageLayer,
images.MediaTypeDockerSchema2Layer, images.MediaTypeDockerSchema2Layer,
specs.MediaTypeImageLayerGzip, ocispec.MediaTypeImageLayerGzip,
images.MediaTypeDockerSchema2LayerGzip: images.MediaTypeDockerSchema2LayerGzip:
default: default:
return nil, nil return nil, nil
@ -150,7 +150,7 @@ func applyLayer(cs content.Store, dir string, out progress.Output) images.Handle
func childrenHandler(cs content.Store) images.HandlerFunc { func childrenHandler(cs content.Store) images.HandlerFunc {
ch := images.ChildrenHandler(cs) ch := images.ChildrenHandler(cs)
return func(ctx context.Context, desc specs.Descriptor) ([]specs.Descriptor, error) { return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
switch desc.MediaType { switch desc.MediaType {
case mediaTypePluginConfig: case mediaTypePluginConfig:
return nil, nil return nil, nil
@ -167,15 +167,15 @@ type fetchMeta struct {
} }
func storeFetchMetadata(m *fetchMeta) images.HandlerFunc { func storeFetchMetadata(m *fetchMeta) images.HandlerFunc {
return func(ctx context.Context, desc specs.Descriptor) ([]specs.Descriptor, error) { return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
switch desc.MediaType { switch desc.MediaType {
case case
images.MediaTypeDockerSchema2LayerForeignGzip, images.MediaTypeDockerSchema2LayerForeignGzip,
images.MediaTypeDockerSchema2Layer, images.MediaTypeDockerSchema2Layer,
specs.MediaTypeImageLayer, ocispec.MediaTypeImageLayer,
specs.MediaTypeImageLayerGzip: ocispec.MediaTypeImageLayerGzip:
m.blobs = append(m.blobs, desc.Digest) m.blobs = append(m.blobs, desc.Digest)
case specs.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest: case ocispec.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest:
m.manifest = desc.Digest m.manifest = desc.Digest
case mediaTypePluginConfig: case mediaTypePluginConfig:
m.config = desc.Digest m.config = desc.Digest
@ -196,9 +196,9 @@ func validateFetchedMetadata(md fetchMeta) error {
// withFetchProgress is a fetch handler which registers a descriptor with a progress // withFetchProgress is a fetch handler which registers a descriptor with a progress
func withFetchProgress(cs content.Store, out progress.Output, ref reference.Named) images.HandlerFunc { func withFetchProgress(cs content.Store, out progress.Output, ref reference.Named) images.HandlerFunc {
return func(ctx context.Context, desc specs.Descriptor) ([]specs.Descriptor, error) { return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
switch desc.MediaType { switch desc.MediaType {
case specs.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest: case ocispec.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest:
tn := reference.TagNameOnly(ref) tn := reference.TagNameOnly(ref)
tagged := tn.(reference.Tagged) tagged := tn.(reference.Tagged)
progress.Messagef(out, tagged.Tag(), "Pulling from %s", reference.FamiliarName(ref)) progress.Messagef(out, tagged.Tag(), "Pulling from %s", reference.FamiliarName(ref))
@ -207,8 +207,8 @@ func withFetchProgress(cs content.Store, out progress.Output, ref reference.Name
case case
images.MediaTypeDockerSchema2LayerGzip, images.MediaTypeDockerSchema2LayerGzip,
images.MediaTypeDockerSchema2Layer, images.MediaTypeDockerSchema2Layer,
specs.MediaTypeImageLayer, ocispec.MediaTypeImageLayer,
specs.MediaTypeImageLayerGzip: ocispec.MediaTypeImageLayerGzip:
default: default:
return nil, nil return nil, nil
} }

View file

@ -18,7 +18,7 @@ import (
v2 "github.com/docker/docker/plugin/v2" v2 "github.com/docker/docker/plugin/v2"
"github.com/moby/sys/mount" "github.com/moby/sys/mount"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
@ -267,7 +267,7 @@ func (pm *Manager) upgradePlugin(p *v2.Plugin, configDigest, manifestDigest dige
} }
func (pm *Manager) setupNewPlugin(configDigest digest.Digest, privileges *types.PluginPrivileges) (types.PluginConfig, error) { func (pm *Manager) setupNewPlugin(configDigest digest.Digest, privileges *types.PluginPrivileges) (types.PluginConfig, error) {
configRA, err := pm.blobStore.ReaderAt(context.TODO(), specs.Descriptor{Digest: configDigest}) configRA, err := pm.blobStore.ReaderAt(context.TODO(), ocispec.Descriptor{Digest: configDigest})
if err != nil { if err != nil {
return types.PluginConfig{}, err return types.PluginConfig{}, err
} }