diff --git a/daemon/cluster/executor/backend.go b/daemon/cluster/executor/backend.go index 08de6eae58..ee2f3dffab 100644 --- a/daemon/cluster/executor/backend.go +++ b/daemon/cluster/executor/backend.go @@ -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) } diff --git a/daemon/cluster/executor/container/adapter.go b/daemon/cluster/executor/container/adapter.go index acff0844b8..39f7d292d4 100644 --- a/daemon/cluster/executor/container/adapter.go +++ b/daemon/cluster/executor/container/adapter.go @@ -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 } diff --git a/daemon/containerd/cache.go b/daemon/containerd/cache.go index daae226eed..fe15f4eed5 100644 --- a/daemon/containerd/cache.go +++ b/daemon/containerd/cache.go @@ -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 { diff --git a/daemon/containerd/image.go b/daemon/containerd/image.go index 1dd1fba463..9e53227d22 100644 --- a/daemon/containerd/image.go +++ b/daemon/containerd/image.go @@ -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 diff --git a/daemon/containerd/image_builder.go b/daemon/containerd/image_builder.go index 61eb147ec3..0c9a02c493 100644 --- a/daemon/containerd/image_builder.go +++ b/daemon/containerd/image_builder.go @@ -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{ diff --git a/daemon/containerd/image_events.go b/daemon/containerd/image_events.go index bfb9abb958..81935e737e 100644 --- a/daemon/containerd/image_events.go +++ b/daemon/containerd/image_events.go @@ -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`. diff --git a/daemon/containerd/image_inspect.go b/daemon/containerd/image_inspect.go index 24760b8565..79e3b4cc6f 100644 --- a/daemon/containerd/image_inspect.go +++ b/daemon/containerd/image_inspect.go @@ -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) diff --git a/daemon/containerd/image_inspect_test.go b/daemon/containerd/image_inspect_test.go index b92299c629..c3ade5848e 100644 --- a/daemon/containerd/image_inspect_test.go +++ b/daemon/containerd/image_inspect_test.go @@ -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) diff --git a/daemon/containerd/image_list.go b/daemon/containerd/image_list.go index bd584b2d65..c011a504ea 100644 --- a/daemon/containerd/image_list.go +++ b/daemon/containerd/image_list.go @@ -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 } diff --git a/daemon/containerd/image_load_test.go b/daemon/containerd/image_load_test.go index 0c32d30e8e..1cc3f9b217 100644 --- a/daemon/containerd/image_load_test.go +++ b/daemon/containerd/image_load_test.go @@ -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 } diff --git a/daemon/create.go b/daemon/create.go index 8dc113a371..f68dfff7b8 100644 --- a/daemon/create.go +++ b/daemon/create.go @@ -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 } diff --git a/daemon/image_service.go b/daemon/image_service.go index 5514958e58..8cae555d2c 100644 --- a/daemon/image_service.go +++ b/daemon/image_service.go @@ -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 diff --git a/daemon/images/cache.go b/daemon/images/cache.go index 7ccb2b13de..fa70ac6f64 100644 --- a/daemon/images/cache.go +++ b/daemon/images/cache.go @@ -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 { diff --git a/daemon/images/image.go b/daemon/images/image.go index ab4ba71b84..2ec71536b0 100644 --- a/daemon/images/image.go +++ b/daemon/images/image.go @@ -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 diff --git a/daemon/images/image_builder.go b/daemon/images/image_builder.go index bcf8e6517f..23777e7904 100644 --- a/daemon/images/image_builder.go +++ b/daemon/images/image_builder.go @@ -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 } diff --git a/daemon/images/image_delete.go b/daemon/images/image_delete.go index ec04e88f49..b6d2c85334 100644 --- a/daemon/images/image_delete.go +++ b/daemon/images/image_delete.go @@ -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 } diff --git a/daemon/images/image_events.go b/daemon/images/image_events.go index a436136c13..2ffd3993dd 100644 --- a/daemon/images/image_events.go +++ b/daemon/images/image_events.go @@ -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`. diff --git a/daemon/images/image_history.go b/daemon/images/image_history.go index e308929dd6..88e6594ba5 100644 --- a/daemon/images/image_history.go +++ b/daemon/images/image_history.go @@ -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 } diff --git a/daemon/images/image_inspect.go b/daemon/images/image_inspect.go index 749f64d8a5..30039958c1 100644 --- a/daemon/images/image_inspect.go +++ b/daemon/images/image_inspect.go @@ -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 } diff --git a/daemon/images/image_list.go b/daemon/images/image_list.go index 4870758d9c..6a89c46da7 100644 --- a/daemon/images/image_list.go +++ b/daemon/images/image_list.go @@ -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 } diff --git a/daemon/images/image_pull.go b/daemon/images/image_pull.go index aa6c6a3353..abef9e2a34 100644 --- a/daemon/images/image_pull.go +++ b/daemon/images/image_pull.go @@ -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 diff --git a/daemon/images/image_push.go b/daemon/images/image_push.go index 5c2ce3dfed..98b32d5474 100644 --- a/daemon/images/image_push.go +++ b/daemon/images/image_push.go @@ -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 } diff --git a/daemon/list.go b/daemon/list.go index 7129a978ed..3bcb4b43fd 100644 --- a/daemon/list.go +++ b/daemon/list.go @@ -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. diff --git a/daemon/migration.go b/daemon/migration.go index 24a187cc42..34c4b06caf 100644 --- a/daemon/migration.go +++ b/daemon/migration.go @@ -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 } diff --git a/daemon/oci_windows.go b/daemon/oci_windows.go index 46d074f6c4..52454056d2 100644 --- a/daemon/oci_windows.go +++ b/daemon/oci_windows.go @@ -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 } diff --git a/daemon/server/backend/backend.go b/daemon/server/backend/backend.go index 3aa531d557..ff4eccf313 100644 --- a/daemon/server/backend/backend.go +++ b/daemon/server/backend/backend.go @@ -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 diff --git a/daemon/server/imagebackend/image.go b/daemon/server/imagebackend/image.go index 960852b48a..01b8186b14 100644 --- a/daemon/server/imagebackend/image.go +++ b/daemon/server/imagebackend/image.go @@ -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 +} diff --git a/daemon/server/router/image/backend.go b/daemon/server/router/image/backend.go index 2575f6de83..97f3040b29 100644 --- a/daemon/server/router/image/backend.go +++ b/daemon/server/router/image/backend.go @@ -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) } diff --git a/daemon/server/router/image/image_routes.go b/daemon/server/router/image/image_routes.go index e35f5b4bda..df2d969f53 100644 --- a/daemon/server/router/image/image_routes.go +++ b/daemon/server/router/image/image_routes.go @@ -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) } diff --git a/daemon/volumes.go b/daemon/volumes.go index f995d6fc2f..945e37a2fb 100644 --- a/daemon/volumes.go +++ b/daemon/volumes.go @@ -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 }