mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
daemon/server: move GetImageOpts, ImageInspectOpts to imagebackend
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -75,5 +75,5 @@ type VolumeBackend interface {
|
||||
type ImageBackend interface {
|
||||
PullImage(ctx context.Context, ref reference.Named, options imagebackend.PullOptions) error
|
||||
GetRepositories(context.Context, reference.Named, *registry.AuthConfig) ([]distribution.Repository, error)
|
||||
GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*image.Image, error)
|
||||
GetImage(ctx context.Context, refOrID string, options imagebackend.GetImageOpts) (*image.Image, error)
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func (c *containerAdapter) pullImage(ctx context.Context) error {
|
||||
named, err := reference.ParseNormalizedNamed(spec.Image)
|
||||
if err == nil {
|
||||
if _, ok := named.(reference.Canonical); ok {
|
||||
_, err := c.imageBackend.GetImage(ctx, spec.Image, backend.GetImageOpts{})
|
||||
_, err := c.imageBackend.GetImage(ctx, spec.Image, imagebackend.GetImageOpts{})
|
||||
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/internal/image/cache"
|
||||
"github.com/moby/moby/v2/daemon/internal/layer"
|
||||
"github.com/moby/moby/v2/daemon/internal/multierror"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/errdefs"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
@@ -34,7 +34,7 @@ func (c cacheAdaptor) Get(id image.ID) (*image.Image, error) {
|
||||
ctx := context.TODO()
|
||||
ref := id.String()
|
||||
|
||||
outImg, err := c.is.GetImage(ctx, id.String(), backend.GetImageOpts{})
|
||||
outImg, err := c.is.GetImage(ctx, id.String(), imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GetImage: %w", err)
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func (c cacheAdaptor) Get(id image.ID) (*image.Image, error) {
|
||||
}
|
||||
|
||||
func (c cacheAdaptor) GetByRef(ctx context.Context, refOrId string) (*image.Image, error) {
|
||||
return c.is.GetImage(ctx, refOrId, backend.GetImageOpts{})
|
||||
return c.is.GetImage(ctx, refOrId, imagebackend.GetImageOpts{})
|
||||
}
|
||||
|
||||
func (c cacheAdaptor) SetParent(target, parent image.ID) error {
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
imagespec "github.com/moby/docker-image-spec/specs-go/v1"
|
||||
"github.com/moby/moby/v2/daemon/images"
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/errdefs"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
@@ -41,7 +41,7 @@ func (e *errPlatformNotFound) Error() string {
|
||||
}
|
||||
|
||||
// GetImage returns an image corresponding to the image referred to by refOrID.
|
||||
func (i *ImageService) GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*image.Image, error) {
|
||||
func (i *ImageService) GetImage(ctx context.Context, refOrID string, options imagebackend.GetImageOpts) (*image.Image, error) {
|
||||
img, err := i.resolveImage(ctx, refOrID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -32,7 +32,6 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/internal/layer"
|
||||
"github.com/moby/moby/v2/daemon/internal/stringid"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/buildbackend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/errdefs"
|
||||
@@ -84,7 +83,7 @@ func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID s
|
||||
|
||||
if opts.PullOption != buildbackend.PullOptionForcePull {
|
||||
// TODO(laurazard): same as below
|
||||
img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{Platform: opts.Platform})
|
||||
img, err := i.GetImage(ctx, refOrID, imagebackend.GetImageOpts{Platform: opts.Platform})
|
||||
if err != nil && opts.PullOption == buildbackend.PullOptionNoPull {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -120,7 +119,7 @@ func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID s
|
||||
|
||||
// TODO(laurazard): pullForBuilder should return whatever we
|
||||
// need here instead of having to go and get it again
|
||||
img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{
|
||||
img, err := i.GetImage(ctx, refOrID, imagebackend.GetImageOpts{
|
||||
Platform: opts.Platform,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -159,7 +158,7 @@ func (i *ImageService) pullForBuilder(ctx context.Context, name string, authConf
|
||||
return nil, err
|
||||
}
|
||||
|
||||
img, err := i.GetImage(ctx, name, backend.GetImageOpts{Platform: platform})
|
||||
img, err := i.GetImage(ctx, name, imagebackend.GetImageOpts{Platform: platform})
|
||||
if err != nil {
|
||||
if cerrdefs.IsNotFound(err) && img != nil && platform != nil {
|
||||
imgPlat := ocispec.Platform{
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
c8dimages "github.com/containerd/containerd/v2/core/images"
|
||||
"github.com/moby/moby/api/types/events"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
)
|
||||
|
||||
// LogImageEvent generates an event related to an image with only the default attributes.
|
||||
@@ -13,7 +13,7 @@ func (i *ImageService) LogImageEvent(ctx context.Context, imageID, refName strin
|
||||
ctx = context.WithoutCancel(ctx)
|
||||
attributes := map[string]string{}
|
||||
|
||||
img, err := i.GetImage(ctx, imageID, backend.GetImageOpts{})
|
||||
img, err := i.GetImage(ctx, imageID, imagebackend.GetImageOpts{})
|
||||
if err == nil && img.Config != nil {
|
||||
// image has not been removed yet.
|
||||
// it could be missing if the event is `delete`.
|
||||
|
||||
@@ -12,13 +12,13 @@ import (
|
||||
"github.com/distribution/reference"
|
||||
imagespec "github.com/moby/docker-image-spec/specs-go/v1"
|
||||
imagetypes "github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/internal/sliceutil"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"golang.org/x/sync/semaphore"
|
||||
)
|
||||
|
||||
func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, opts backend.ImageInspectOpts) (*imagetypes.InspectResponse, error) {
|
||||
func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, opts imagebackend.ImageInspectOpts) (*imagetypes.InspectResponse, error) {
|
||||
requestedPlatform := opts.Platform
|
||||
|
||||
c8dImg, err := i.resolveImage(ctx, refOrID)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
c8dimages "github.com/containerd/containerd/v2/core/images"
|
||||
"github.com/containerd/containerd/v2/pkg/namespaces"
|
||||
"github.com/containerd/log/logtest"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/internal/testutil/specialimage"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"gotest.tools/v3/assert"
|
||||
@@ -49,7 +49,7 @@ func TestImageInspect(t *testing.T) {
|
||||
|
||||
for _, manifests := range []bool{true, false} {
|
||||
t.Run(fmt.Sprintf("manifests=%t", manifests), func(t *testing.T) {
|
||||
inspect, err := service.ImageInspect(ctx, missingMultiPlatform.Name, backend.ImageInspectOpts{Manifests: manifests})
|
||||
inspect, err := service.ImageInspect(ctx, missingMultiPlatform.Name, imagebackend.ImageInspectOpts{Manifests: manifests})
|
||||
assert.NilError(t, err)
|
||||
|
||||
if manifests {
|
||||
@@ -78,7 +78,7 @@ func TestImageInspect(t *testing.T) {
|
||||
|
||||
// Test with amd64 platform
|
||||
amd64Platform := &ocispec.Platform{OS: "linux", Architecture: "amd64"}
|
||||
inspectAmd64, err := service.ImageInspect(ctx, multiPlatformImage.Name, backend.ImageInspectOpts{
|
||||
inspectAmd64, err := service.ImageInspect(ctx, multiPlatformImage.Name, imagebackend.ImageInspectOpts{
|
||||
Platform: amd64Platform,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
@@ -87,7 +87,7 @@ func TestImageInspect(t *testing.T) {
|
||||
|
||||
// Test with arm64 platform
|
||||
arm64Platform := &ocispec.Platform{OS: "linux", Architecture: "arm64"}
|
||||
inspectArm64, err := service.ImageInspect(ctx, multiPlatformImage.Name, backend.ImageInspectOpts{
|
||||
inspectArm64, err := service.ImageInspect(ctx, multiPlatformImage.Name, imagebackend.ImageInspectOpts{
|
||||
Platform: arm64Platform,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"github.com/moby/moby/api/types/filters"
|
||||
imagetypes "github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/v2/daemon/internal/timestamp"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/errdefs"
|
||||
"github.com/opencontainers/go-digest"
|
||||
@@ -498,13 +497,13 @@ type imageFilterFunc func(image c8dimages.Image) bool
|
||||
func (i *ImageService) setupFilters(ctx context.Context, imageFilters filters.Args) (filterFunc imageFilterFunc, outErr error) {
|
||||
var fltrs []imageFilterFunc
|
||||
err := imageFilters.WalkValues("before", func(value string) error {
|
||||
img, err := i.GetImage(ctx, value, backend.GetImageOpts{})
|
||||
img, err := i.GetImage(ctx, value, imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if img != nil && img.Created != nil {
|
||||
fltrs = append(fltrs, func(candidate c8dimages.Image) bool {
|
||||
cand, err := i.GetImage(ctx, candidate.Name, backend.GetImageOpts{})
|
||||
cand, err := i.GetImage(ctx, candidate.Name, imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
@@ -518,13 +517,13 @@ func (i *ImageService) setupFilters(ctx context.Context, imageFilters filters.Ar
|
||||
}
|
||||
|
||||
err = imageFilters.WalkValues("since", func(value string) error {
|
||||
img, err := i.GetImage(ctx, value, backend.GetImageOpts{})
|
||||
img, err := i.GetImage(ctx, value, imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if img != nil && img.Created != nil {
|
||||
fltrs = append(fltrs, func(candidate c8dimages.Image) bool {
|
||||
cand, err := i.GetImage(ctx, candidate.Name, backend.GetImageOpts{})
|
||||
cand, err := i.GetImage(ctx, candidate.Name, imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
cerrdefs "github.com/containerd/errdefs"
|
||||
"github.com/containerd/platforms"
|
||||
"github.com/moby/go-archive"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/internal/testutil/labelstore"
|
||||
"github.com/moby/moby/v2/internal/testutil/specialimage"
|
||||
@@ -152,7 +151,7 @@ func TestImageLoad(t *testing.T) {
|
||||
|
||||
func verifyImagePlatforms(ctx context.Context, imgSvc *ImageService, imgRef string, expectedPlatforms []ocispec.Platform) error {
|
||||
// get the manifest(s) for the image
|
||||
img, err := imgSvc.ImageInspect(ctx, imgRef, backend.ImageInspectOpts{Manifests: true})
|
||||
img, err := imgSvc.ImageInspect(ctx, imgRef, imagebackend.ImageInspectOpts{Manifests: true})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/internal/multierror"
|
||||
"github.com/moby/moby/v2/daemon/internal/otelutil"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/errdefs"
|
||||
"github.com/moby/sys/user"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
@@ -92,7 +93,7 @@ func (daemon *Daemon) containerCreate(ctx context.Context, daemonCfg *configStor
|
||||
}
|
||||
|
||||
if opts.params.Platform == nil && opts.params.Config.Image != "" {
|
||||
img, err := daemon.imageService.GetImage(ctx, opts.params.Config.Image, backend.GetImageOpts{})
|
||||
img, err := daemon.imageService.GetImage(ctx, opts.params.Config.Image, imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return containertypes.CreateResponse{}, err
|
||||
}
|
||||
@@ -173,7 +174,7 @@ func (daemon *Daemon) create(ctx context.Context, daemonCfg *config.Config, opts
|
||||
)
|
||||
|
||||
if opts.params.Config.Image != "" {
|
||||
img, err = daemon.imageService.GetImage(ctx, opts.params.Config.Image, backend.GetImageOpts{Platform: opts.params.Platform})
|
||||
img, err = daemon.imageService.GetImage(ctx, opts.params.Config.Image, imagebackend.GetImageOpts{Platform: opts.params.Platform})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ type ImageService interface {
|
||||
ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*imagetype.PruneReport, 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
|
||||
GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*image.Image, error)
|
||||
GetImage(ctx context.Context, refOrID string, options imagebackend.GetImageOpts) (*image.Image, error)
|
||||
ImageHistory(ctx context.Context, name string, platform *ocispec.Platform) ([]*imagetype.HistoryResponseItem, error)
|
||||
CommitImage(ctx context.Context, c backend.CommitConfig) (image.ID, error)
|
||||
SquashImage(id, parent string) (string, error)
|
||||
ImageInspect(ctx context.Context, refOrID string, opts backend.ImageInspectOpts) (*imagetype.InspectResponse, error)
|
||||
ImageInspect(ctx context.Context, refOrID string, opts imagebackend.ImageInspectOpts) (*imagetype.InspectResponse, error)
|
||||
ImageDiskUsage(ctx context.Context) (int64, error)
|
||||
|
||||
// Layers
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/internal/image/cache"
|
||||
"github.com/moby/moby/v2/daemon/internal/layer"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
)
|
||||
|
||||
type cacheAdaptor struct {
|
||||
@@ -22,7 +22,7 @@ func (c cacheAdaptor) Get(id image.ID) (*image.Image, error) {
|
||||
}
|
||||
|
||||
func (c cacheAdaptor) GetByRef(ctx context.Context, refOrId string) (*image.Image, error) {
|
||||
return c.is.GetImage(ctx, refOrId, backend.GetImageOpts{})
|
||||
return c.is.GetImage(ctx, refOrId, imagebackend.GetImageOpts{})
|
||||
}
|
||||
|
||||
func (c cacheAdaptor) SetParent(target, parent image.ID) error {
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/containerd/platforms"
|
||||
"github.com/distribution/reference"
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/errdefs"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
@@ -158,7 +158,7 @@ func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.I
|
||||
}
|
||||
|
||||
// GetImage returns an image corresponding to the image referred to by refOrID.
|
||||
func (i *ImageService) GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (retImg *image.Image, retErr error) {
|
||||
func (i *ImageService) GetImage(ctx context.Context, refOrID string, options imagebackend.GetImageOpts) (retImg *image.Image, retErr error) {
|
||||
defer func() {
|
||||
if retErr != nil || retImg == nil || options.Platform == nil {
|
||||
return
|
||||
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/internal/layer"
|
||||
"github.com/moby/moby/v2/daemon/internal/stringid"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/buildbackend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
@@ -169,7 +169,7 @@ func (i *ImageService) pullForBuilder(ctx context.Context, name string, authConf
|
||||
return nil, err
|
||||
}
|
||||
|
||||
img, err := i.GetImage(ctx, name, backend.GetImageOpts{Platform: platform})
|
||||
img, err := i.GetImage(ctx, name, imagebackend.GetImageOpts{Platform: platform})
|
||||
if cerrdefs.IsNotFound(err) && img != nil && platform != nil {
|
||||
imgPlat := ocispec.Platform{
|
||||
OS: img.OS,
|
||||
@@ -211,7 +211,7 @@ func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID s
|
||||
}
|
||||
|
||||
if opts.PullOption != buildbackend.PullOptionForcePull {
|
||||
img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{Platform: opts.Platform})
|
||||
img, err := i.GetImage(ctx, refOrID, imagebackend.GetImageOpts{Platform: opts.Platform})
|
||||
if err != nil && opts.PullOption == buildbackend.PullOptionNoPull {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/internal/metrics"
|
||||
"github.com/moby/moby/v2/daemon/internal/stringid"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/errdefs"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
@@ -77,7 +76,7 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, options
|
||||
return nil, errdefs.InvalidParameter(errors.New("multiple platforms are not supported"))
|
||||
}
|
||||
|
||||
img, err := i.GetImage(ctx, imageRef, backend.GetImageOpts{Platform: platform})
|
||||
img, err := i.GetImage(ctx, imageRef, imagebackend.GetImageOpts{Platform: platform})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/moby/moby/api/types/events"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
)
|
||||
|
||||
// LogImageEvent generates an event related to an image with only the default attributes.
|
||||
@@ -12,7 +12,7 @@ func (i *ImageService) LogImageEvent(ctx context.Context, imageID, refName strin
|
||||
ctx = context.WithoutCancel(ctx)
|
||||
attributes := map[string]string{}
|
||||
|
||||
img, err := i.GetImage(ctx, imageID, backend.GetImageOpts{})
|
||||
img, err := i.GetImage(ctx, imageID, imagebackend.GetImageOpts{})
|
||||
if err == nil && img.Config != nil {
|
||||
// image has not been removed yet.
|
||||
// it could be missing if the event is `delete`.
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/v2/daemon/internal/layer"
|
||||
"github.com/moby/moby/v2/daemon/internal/metrics"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
// name by walking the image lineage.
|
||||
func (i *ImageService) ImageHistory(ctx context.Context, name string, platform *ocispec.Platform) ([]*image.HistoryResponseItem, error) {
|
||||
start := time.Now()
|
||||
img, err := i.GetImage(ctx, name, backend.GetImageOpts{Platform: platform})
|
||||
img, err := i.GetImage(ctx, name, imagebackend.GetImageOpts{Platform: platform})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (i *ImageService) ImageHistory(ctx context.Context, name string, platform *
|
||||
if id == "" {
|
||||
break
|
||||
}
|
||||
histImg, err = i.GetImage(ctx, id.String(), backend.GetImageOpts{})
|
||||
histImg, err = i.GetImage(ctx, id.String(), imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ import (
|
||||
"github.com/moby/moby/api/types/storage"
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/internal/layer"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
)
|
||||
|
||||
func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, opts backend.ImageInspectOpts) (*imagetypes.InspectResponse, error) {
|
||||
img, err := i.GetImage(ctx, refOrID, backend.GetImageOpts{Platform: opts.Platform})
|
||||
func (i *ImageService) ImageInspect(ctx context.Context, refOrID string, opts imagebackend.ImageInspectOpts) (*imagetypes.InspectResponse, error) {
|
||||
img, err := i.GetImage(ctx, refOrID, imagebackend.GetImageOpts{Platform: opts.Platform})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/internal/layer"
|
||||
"github.com/moby/moby/v2/daemon/internal/timestamp"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
)
|
||||
|
||||
@@ -47,7 +46,7 @@ func (i *ImageService) Images(ctx context.Context, opts imagebackend.ListOptions
|
||||
|
||||
var beforeFilter, sinceFilter time.Time
|
||||
err = opts.Filters.WalkValues("before", func(value string) error {
|
||||
img, err := i.GetImage(ctx, value, backend.GetImageOpts{})
|
||||
img, err := i.GetImage(ctx, value, imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -82,7 +81,7 @@ func (i *ImageService) Images(ctx context.Context, opts imagebackend.ListOptions
|
||||
}
|
||||
|
||||
err = opts.Filters.WalkValues("since", func(value string) error {
|
||||
img, err := i.GetImage(ctx, value, backend.GetImageOpts{})
|
||||
img, err := i.GetImage(ctx, value, imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/internal/distribution"
|
||||
progressutils "github.com/moby/moby/v2/daemon/internal/distribution/utils"
|
||||
"github.com/moby/moby/v2/daemon/internal/metrics"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
@@ -50,7 +49,7 @@ func (i *ImageService) PullImage(ctx context.Context, ref reference.Named, optio
|
||||
// we allow the image to have a non-matching architecture. The code
|
||||
// below checks for this situation, and returns a warning to the client,
|
||||
// as well as logging it to the daemon logs.
|
||||
img, err := i.GetImage(ctx, ref.String(), backend.GetImageOpts{Platform: platform})
|
||||
img, err := i.GetImage(ctx, ref.String(), imagebackend.GetImageOpts{Platform: platform})
|
||||
|
||||
// Note that this is a special case where GetImage returns both an image
|
||||
// and an error: https://github.com/moby/moby/blob/v28.3.3/daemon/images/image.go#L186-L193
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/internal/distribution"
|
||||
progressutils "github.com/moby/moby/v2/daemon/internal/distribution/utils"
|
||||
"github.com/moby/moby/v2/daemon/internal/metrics"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
@@ -30,7 +29,7 @@ func (i *ImageService) PushImage(ctx context.Context, ref reference.Named, optio
|
||||
}
|
||||
if platform != nil {
|
||||
// Check if the image is actually the platform we want to push.
|
||||
_, err := i.GetImage(ctx, ref.String(), backend.GetImageOpts{Platform: platform})
|
||||
_, err := i.GetImage(ctx, ref.String(), imagebackend.GetImageOpts{Platform: platform})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/container"
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@@ -328,7 +329,7 @@ func (daemon *Daemon) foldFilter(ctx context.Context, view *container.View, conf
|
||||
if psFilters.Contains("ancestor") {
|
||||
ancestorFilter = true
|
||||
err := psFilters.WalkValues("ancestor", func(ancestor string) error {
|
||||
img, err := daemon.imageService.GetImage(ctx, ancestor, backend.GetImageOpts{})
|
||||
img, err := daemon.imageService.GetImage(ctx, ancestor, imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
log.G(ctx).Warnf("Error while looking up for image %v", ancestor)
|
||||
return nil
|
||||
@@ -618,7 +619,7 @@ func (daemon *Daemon) refreshImage(ctx context.Context, s *container.Snapshot) *
|
||||
}
|
||||
|
||||
// Check if the image reference still resolves to the same digest.
|
||||
img, err := daemon.imageService.GetImage(ctx, s.Image, backend.GetImageOpts{})
|
||||
img, err := daemon.imageService.GetImage(ctx, s.Image, imagebackend.GetImageOpts{})
|
||||
// If the image is no longer found or can't be resolved for some other
|
||||
// reason. Update the Image to the specific ID of the original image it
|
||||
// resolved to when the container was created.
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/container"
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/internal/multierror"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -131,7 +131,7 @@ func (r daemonPlatformReader) ReadPlatformFromConfigByImageManifest(
|
||||
}
|
||||
|
||||
func (r daemonPlatformReader) ReadPlatformFromImage(ctx context.Context, id image.ID) (ocispec.Platform, error) {
|
||||
img, err := r.imageService.GetImage(ctx, id.String(), backend.GetImageOpts{})
|
||||
img, err := r.imageService.GetImage(ctx, id.String(), imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return ocispec.Platform{}, err
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/container"
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/pkg/oci"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/errdefs"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
@@ -93,7 +93,7 @@ func (daemon *Daemon) isHyperV(c *container.Container) bool {
|
||||
}
|
||||
|
||||
func (daemon *Daemon) createSpec(ctx context.Context, daemonCfg *configStore, c *container.Container, mounts []container.Mount) (*specs.Spec, error) {
|
||||
img, err := daemon.imageService.GetImage(ctx, string(c.ImageID), backend.GetImageOpts{})
|
||||
img, err := daemon.imageService.GetImage(ctx, string(c.ImageID), imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -160,18 +160,6 @@ type CreateImageConfig struct {
|
||||
Changes []string
|
||||
}
|
||||
|
||||
// GetImageOpts holds parameters to retrieve image information
|
||||
// from the backend.
|
||||
type GetImageOpts struct {
|
||||
Platform *ocispec.Platform
|
||||
}
|
||||
|
||||
// ImageInspectOpts holds parameters to inspect an image.
|
||||
type ImageInspectOpts struct {
|
||||
Manifests bool
|
||||
Platform *ocispec.Platform
|
||||
}
|
||||
|
||||
// CommitConfig is the configuration for creating an image as part of a build.
|
||||
type CommitConfig struct {
|
||||
Author string
|
||||
|
||||
@@ -43,3 +43,15 @@ type ListOptions struct {
|
||||
// Manifests indicates whether the image manifests should be returned.
|
||||
Manifests bool
|
||||
}
|
||||
|
||||
// GetImageOpts holds parameters to retrieve image information
|
||||
// from the backend.
|
||||
type GetImageOpts struct {
|
||||
Platform *ocispec.Platform
|
||||
}
|
||||
|
||||
// ImageInspectOpts holds parameters to inspect an image.
|
||||
type ImageInspectOpts struct {
|
||||
Manifests bool
|
||||
Platform *ocispec.Platform
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/moby/moby/api/types/image"
|
||||
"github.com/moby/moby/api/types/registry"
|
||||
dockerimage "github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
@@ -26,8 +25,8 @@ type imageBackend interface {
|
||||
ImageDelete(ctx context.Context, imageRef string, options imagebackend.RemoveOptions) ([]image.DeleteResponse, error)
|
||||
ImageHistory(ctx context.Context, imageName string, platform *ocispec.Platform) ([]*image.HistoryResponseItem, error)
|
||||
Images(ctx context.Context, opts imagebackend.ListOptions) ([]*image.Summary, error)
|
||||
GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*dockerimage.Image, error)
|
||||
ImageInspect(ctx context.Context, refOrID string, options backend.ImageInspectOpts) (*image.InspectResponse, error)
|
||||
GetImage(ctx context.Context, refOrID string, options imagebackend.GetImageOpts) (*dockerimage.Image, error)
|
||||
ImageInspect(ctx context.Context, refOrID string, options imagebackend.ImageInspectOpts) (*image.InspectResponse, error)
|
||||
TagImage(ctx context.Context, id dockerimage.ID, newRef reference.Named) error
|
||||
ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*image.PruneReport, error)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/builder/remotecontext"
|
||||
"github.com/moby/moby/v2/daemon/internal/compat"
|
||||
"github.com/moby/moby/v2/daemon/internal/image"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/httputils"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/dockerversion"
|
||||
@@ -380,7 +379,7 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
|
||||
return errdefs.InvalidParameter(errors.New("conflicting options: manifests and platform options cannot both be set"))
|
||||
}
|
||||
|
||||
imageInspect, err := ir.backend.ImageInspect(ctx, vars["name"], backend.ImageInspectOpts{
|
||||
imageInspect, err := ir.backend.ImageInspect(ctx, vars["name"], imagebackend.ImageInspectOpts{
|
||||
Manifests: manifests,
|
||||
Platform: platform,
|
||||
})
|
||||
@@ -555,7 +554,7 @@ func (ir *imageRouter) postImagesTag(ctx context.Context, w http.ResponseWriter,
|
||||
return errdefs.InvalidParameter(errors.New("refusing to create an ambiguous tag using digest algorithm as name"))
|
||||
}
|
||||
|
||||
img, err := ir.backend.GetImage(ctx, vars["name"], backend.GetImageOpts{})
|
||||
img, err := ir.backend.GetImage(ctx, vars["name"], imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return errdefs.NotFound(err)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
volumetypes "github.com/moby/moby/api/types/volume"
|
||||
"github.com/moby/moby/v2/daemon/container"
|
||||
"github.com/moby/moby/v2/daemon/internal/layer"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/imagebackend"
|
||||
"github.com/moby/moby/v2/daemon/volume"
|
||||
volumemounts "github.com/moby/moby/v2/daemon/volume/mounts"
|
||||
"github.com/moby/moby/v2/daemon/volume/service"
|
||||
@@ -248,7 +248,7 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo
|
||||
}
|
||||
|
||||
if mp.Type == mounttypes.TypeImage {
|
||||
img, err := daemon.imageService.GetImage(ctx, mp.Source, backend.GetImageOpts{})
|
||||
img, err := daemon.imageService.GetImage(ctx, mp.Source, imagebackend.GetImageOpts{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user