mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #43968 from thaJeztah/implement_GetImageOpts
introduce GetImageOpts to manage image inspect data in backend
This commit is contained in:
commit
ce550fa9c2
19 changed files with 48 additions and 26 deletions
|
@ -24,7 +24,7 @@ type imageBackend interface {
|
||||||
ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)
|
ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)
|
||||||
ImageHistory(imageName string) ([]*image.HistoryResponseItem, error)
|
ImageHistory(imageName string) ([]*image.HistoryResponseItem, error)
|
||||||
Images(ctx context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error)
|
Images(ctx context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error)
|
||||||
GetImage(refOrID string, platform *specs.Platform) (retImg *dockerimage.Image, retErr error)
|
GetImage(refOrID string, options image.GetImageOpts) (*dockerimage.Image, error)
|
||||||
TagImage(imageName, repository, tag string) (string, error)
|
TagImage(imageName, repository, tag string) (string, error)
|
||||||
ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error)
|
ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/docker/docker/api/server/httputils"
|
"github.com/docker/docker/api/server/httputils"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
opts "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
|
@ -192,7 +193,7 @@ func (ir *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
img, err := ir.backend.GetImage(vars["name"], nil)
|
img, err := ir.backend.GetImage(vars["name"], opts.GetImageOpts{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
8
api/types/image/opts.go
Normal file
8
api/types/image/opts.go
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package image
|
||||||
|
|
||||||
|
import specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
|
|
||||||
|
// GetImageOpts holds parameters to inspect an image.
|
||||||
|
type GetImageOpts struct {
|
||||||
|
Platform *specs.Platform
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/events"
|
"github.com/docker/docker/api/types/events"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
opts "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"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"
|
||||||
|
@ -76,5 +77,5 @@ type VolumeBackend interface {
|
||||||
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 *specs.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(refOrID string, platform *specs.Platform) (retImg *image.Image, retErr error)
|
GetImage(refOrID string, options opts.GetImageOpts) (*image.Image, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/docker/docker/api/types/backend"
|
"github.com/docker/docker/api/types/backend"
|
||||||
containertypes "github.com/docker/docker/api/types/container"
|
containertypes "github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/events"
|
"github.com/docker/docker/api/types/events"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
containerpkg "github.com/docker/docker/container"
|
containerpkg "github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/daemon"
|
"github.com/docker/docker/daemon"
|
||||||
|
@ -75,7 +76,7 @@ func (c *containerAdapter) pullImage(ctx context.Context) error {
|
||||||
named, err := reference.ParseNormalizedNamed(spec.Image)
|
named, err := reference.ParseNormalizedNamed(spec.Image)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if _, ok := named.(reference.Canonical); ok {
|
if _, ok := named.(reference.Canonical); ok {
|
||||||
_, err := c.imageBackend.GetImage(spec.Image, nil)
|
_, err := c.imageBackend.GetImage(spec.Image, imagetypes.GetImageOpts{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package containerd
|
package containerd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
imagetype "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/image"
|
"github.com/docker/docker/image"
|
||||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetImage returns an image corresponding to the image referred to by refOrID.
|
// GetImage returns an image corresponding to the image referred to by refOrID.
|
||||||
func (i *ImageService) GetImage(refOrID string, platform *specs.Platform) (retImg *image.Image, retErr error) {
|
func (i *ImageService) GetImage(refOrID string, options imagetype.GetImageOpts) (retImg *image.Image, retErr error) {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/containerd/containerd/platforms"
|
"github.com/containerd/containerd/platforms"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
containertypes "github.com/docker/docker/api/types/container"
|
containertypes "github.com/docker/docker/api/types/container"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
networktypes "github.com/docker/docker/api/types/network"
|
networktypes "github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/daemon/images"
|
"github.com/docker/docker/daemon/images"
|
||||||
|
@ -68,7 +69,7 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.CreateRes
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.params.Platform == nil && opts.params.Config.Image != "" {
|
if opts.params.Platform == nil && opts.params.Config.Image != "" {
|
||||||
if img, _ := daemon.imageService.GetImage(opts.params.Config.Image, opts.params.Platform); img != nil {
|
if img, _ := daemon.imageService.GetImage(opts.params.Config.Image, imagetypes.GetImageOpts{Platform: opts.params.Platform}); img != nil {
|
||||||
p := maximumSpec()
|
p := maximumSpec()
|
||||||
imgPlat := v1.Platform{
|
imgPlat := v1.Platform{
|
||||||
OS: img.OS,
|
OS: img.OS,
|
||||||
|
@ -119,7 +120,7 @@ func (daemon *Daemon) create(opts createOpts) (retC *container.Container, retErr
|
||||||
)
|
)
|
||||||
|
|
||||||
if opts.params.Config.Image != "" {
|
if opts.params.Config.Image != "" {
|
||||||
img, err = daemon.imageService.GetImage(opts.params.Config.Image, opts.params.Platform)
|
img, err = daemon.imageService.GetImage(opts.params.Config.Image, imagetypes.GetImageOpts{Platform: opts.params.Platform})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ type ImageService interface {
|
||||||
ImportImage(src string, repository string, platform *v1.Platform, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error
|
ImportImage(src string, repository string, platform *v1.Platform, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error
|
||||||
TagImage(imageName, repository, tag string) (string, error)
|
TagImage(imageName, repository, tag string) (string, error)
|
||||||
TagImageWithReference(imageID image.ID, newTag reference.Named) error
|
TagImageWithReference(imageID image.ID, newTag reference.Named) error
|
||||||
GetImage(refOrID string, platform *v1.Platform) (retImg *image.Image, retErr error)
|
GetImage(refOrID string, options imagetype.GetImageOpts) (*image.Image, error)
|
||||||
ImageHistory(name string) ([]*imagetype.HistoryResponseItem, error)
|
ImageHistory(name string) ([]*imagetype.HistoryResponseItem, error)
|
||||||
CommitImage(c backend.CommitConfig) (image.ID, error)
|
CommitImage(c backend.CommitConfig) (image.ID, error)
|
||||||
SquashImage(id, parent string) (string, error)
|
SquashImage(id, parent string) (string, error)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package images // import "github.com/docker/docker/daemon/images"
|
package images // import "github.com/docker/docker/daemon/images"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/builder"
|
"github.com/docker/docker/builder"
|
||||||
"github.com/docker/docker/image/cache"
|
"github.com/docker/docker/image/cache"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -15,7 +16,7 @@ func (i *ImageService) MakeImageCache(sourceRefs []string) builder.ImageCache {
|
||||||
cache := cache.New(i.imageStore)
|
cache := cache.New(i.imageStore)
|
||||||
|
|
||||||
for _, ref := range sourceRefs {
|
for _, ref := range sourceRefs {
|
||||||
img, err := i.GetImage(ref, nil)
|
img, err := i.GetImage(ref, imagetypes.GetImageOpts{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Warnf("Could not look up %s for cache resolution, skipping: %+v", ref, err)
|
logrus.Warnf("Could not look up %s for cache resolution, skipping: %+v", ref, err)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/containerd/containerd/leases"
|
"github.com/containerd/containerd/leases"
|
||||||
"github.com/containerd/containerd/platforms"
|
"github.com/containerd/containerd/platforms"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/docker/docker/image"
|
"github.com/docker/docker/image"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
|
@ -148,9 +149,9 @@ func (i *ImageService) manifestMatchesPlatform(img *image.Image, platform specs.
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetImage returns an image corresponding to the image referred to by refOrID.
|
// GetImage returns an image corresponding to the image referred to by refOrID.
|
||||||
func (i *ImageService) GetImage(refOrID string, platform *specs.Platform) (retImg *image.Image, retErr error) {
|
func (i *ImageService) GetImage(refOrID string, options imagetypes.GetImageOpts) (retImg *image.Image, retErr error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if retErr != nil || retImg == nil || platform == nil {
|
if retErr != nil || retImg == nil || options.Platform == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +160,7 @@ func (i *ImageService) GetImage(refOrID string, platform *specs.Platform) (retIm
|
||||||
Architecture: retImg.Architecture,
|
Architecture: retImg.Architecture,
|
||||||
Variant: retImg.Variant,
|
Variant: retImg.Variant,
|
||||||
}
|
}
|
||||||
p := *platform
|
p := *options.Platform
|
||||||
// Note that `platforms.Only` will fuzzy match this for us
|
// Note that `platforms.Only` will fuzzy match this for us
|
||||||
// For example: an armv6 image will run just fine an an armv7 CPU, without emulation or anything.
|
// For example: an armv6 image will run just fine an an armv7 CPU, without emulation or anything.
|
||||||
if OnlyPlatformWithFallback(p).Match(imgPlat) {
|
if OnlyPlatformWithFallback(p).Match(imgPlat) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/containerd/containerd/platforms"
|
"github.com/containerd/containerd/platforms"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api/types/backend"
|
"github.com/docker/docker/api/types/backend"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/builder"
|
"github.com/docker/docker/builder"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
|
@ -167,7 +168,7 @@ func (i *ImageService) pullForBuilder(ctx context.Context, name string, authConf
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
img, err := i.GetImage(name, platform)
|
img, err := i.GetImage(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 := specs.Platform{
|
||||||
OS: img.OS,
|
OS: img.OS,
|
||||||
|
@ -211,7 +212,7 @@ func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID s
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.PullOption != backend.PullOptionForcePull {
|
if opts.PullOption != backend.PullOptionForcePull {
|
||||||
img, err := i.GetImage(refOrID, opts.Platform)
|
img, err := i.GetImage(refOrID, imagetypes.GetImageOpts{Platform: opts.Platform})
|
||||||
if err != nil && opts.PullOption == backend.PullOptionNoPull {
|
if err != nil && opts.PullOption == backend.PullOptionNoPull {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/docker/docker/image"
|
"github.com/docker/docker/image"
|
||||||
|
@ -63,7 +64,7 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force,
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
records := []types.ImageDeleteResponseItem{}
|
records := []types.ImageDeleteResponseItem{}
|
||||||
|
|
||||||
img, err := i.GetImage(imageRef, nil)
|
img, err := i.GetImage(imageRef, imagetypes.GetImageOpts{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package images // import "github.com/docker/docker/daemon/images"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/docker/docker/api/types/events"
|
"github.com/docker/docker/api/types/events"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LogImageEvent generates an event related to an image with only the default attributes.
|
// LogImageEvent generates an event related to an image with only the default attributes.
|
||||||
|
@ -11,7 +12,7 @@ func (i *ImageService) LogImageEvent(imageID, refName, action string) {
|
||||||
|
|
||||||
// LogImageEventWithAttributes generates an event related to an image with specific given attributes.
|
// LogImageEventWithAttributes generates an event related to an image with specific given attributes.
|
||||||
func (i *ImageService) LogImageEventWithAttributes(imageID, refName, action string, attributes map[string]string) {
|
func (i *ImageService) LogImageEventWithAttributes(imageID, refName, action string, attributes map[string]string) {
|
||||||
img, err := i.GetImage(imageID, nil)
|
img, err := i.GetImage(imageID, imagetypes.GetImageOpts{})
|
||||||
if err == nil && img.Config != nil {
|
if err == nil && img.Config != nil {
|
||||||
// image has not been removed yet.
|
// image has not been removed yet.
|
||||||
// it could be missing if the event is `delete`.
|
// it could be missing if the event is `delete`.
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
// name by walking the image lineage.
|
// name by walking the image lineage.
|
||||||
func (i *ImageService) ImageHistory(name string) ([]*image.HistoryResponseItem, error) {
|
func (i *ImageService) ImageHistory(name string) ([]*image.HistoryResponseItem, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
img, err := i.GetImage(name, nil)
|
img, err := i.GetImage(name, image.GetImageOpts{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ func (i *ImageService) ImageHistory(name string) ([]*image.HistoryResponseItem,
|
||||||
if id == "" {
|
if id == "" {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
histImg, err = i.GetImage(id.String(), nil)
|
histImg, err = i.GetImage(id.String(), image.GetImageOpts{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/image"
|
"github.com/docker/docker/image"
|
||||||
"github.com/docker/docker/layer"
|
"github.com/docker/docker/layer"
|
||||||
|
@ -49,7 +50,7 @@ func (i *ImageService) Images(_ context.Context, opts types.ImageListOptions) ([
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
err = opts.Filters.WalkValues("before", func(value string) error {
|
err = opts.Filters.WalkValues("before", func(value string) error {
|
||||||
beforeFilter, err = i.GetImage(value, nil)
|
beforeFilter, err = i.GetImage(value, imagetypes.GetImageOpts{})
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -57,7 +58,7 @@ func (i *ImageService) Images(_ context.Context, opts types.ImageListOptions) ([
|
||||||
}
|
}
|
||||||
|
|
||||||
err = opts.Filters.WalkValues("since", func(value string) error {
|
err = opts.Filters.WalkValues("since", func(value string) error {
|
||||||
sinceFilter, err = i.GetImage(value, nil)
|
sinceFilter, err = i.GetImage(value, imagetypes.GetImageOpts{})
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
dist "github.com/docker/distribution"
|
dist "github.com/docker/distribution"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/distribution"
|
"github.com/docker/docker/distribution"
|
||||||
progressutils "github.com/docker/docker/distribution/utils"
|
progressutils "github.com/docker/docker/distribution/utils"
|
||||||
|
@ -63,7 +64,7 @@ func (i *ImageService) PullImage(ctx context.Context, image, tag string, platfor
|
||||||
// we allow the image to have a non-matching architecture. The code
|
// we allow the image to have a non-matching architecture. The code
|
||||||
// below checks for this situation, and returns a warning to the client,
|
// below checks for this situation, and returns a warning to the client,
|
||||||
// as well as logging it to the daemon logs.
|
// as well as logging it to the daemon logs.
|
||||||
img, err := i.GetImage(image, platform)
|
img, err := i.GetImage(image, imagetypes.GetImageOpts{Platform: platform})
|
||||||
|
|
||||||
// Note that this is a special case where GetImage returns both an image
|
// Note that this is a special case where GetImage returns both an image
|
||||||
// and an error: https://github.com/docker/docker/blob/v20.10.7/daemon/images/image.go#L175-L183
|
// and an error: https://github.com/docker/docker/blob/v20.10.7/daemon/images/image.go#L175-L183
|
||||||
|
|
|
@ -2,13 +2,14 @@ package images // import "github.com/docker/docker/daemon/images"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/image"
|
"github.com/docker/docker/image"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TagImage creates the tag specified by newTag, pointing to the image named
|
// TagImage creates the tag specified by newTag, pointing to the image named
|
||||||
// imageName (alternatively, imageName can also be an image ID).
|
// imageName (alternatively, imageName can also be an image ID).
|
||||||
func (i *ImageService) TagImage(imageName, repository, tag string) (string, error) {
|
func (i *ImageService) TagImage(imageName, repository, tag string) (string, error) {
|
||||||
img, err := i.GetImage(imageName, nil)
|
img, err := i.GetImage(imageName, imagetypes.GetImageOpts{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/daemon/images"
|
"github.com/docker/docker/daemon/images"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
|
@ -317,7 +318,7 @@ func (daemon *Daemon) foldFilter(view container.View, config *types.ContainerLis
|
||||||
if psFilters.Contains("ancestor") {
|
if psFilters.Contains("ancestor") {
|
||||||
ancestorFilter = true
|
ancestorFilter = true
|
||||||
psFilters.WalkValues("ancestor", func(ancestor string) error {
|
psFilters.WalkValues("ancestor", func(ancestor string) error {
|
||||||
img, err := daemon.imageService.GetImage(ancestor, nil)
|
img, err := daemon.imageService.GetImage(ancestor, imagetypes.GetImageOpts{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Warnf("Error while looking up for image %v", ancestor)
|
logrus.Warnf("Error while looking up for image %v", ancestor)
|
||||||
return nil
|
return nil
|
||||||
|
@ -581,7 +582,7 @@ func (daemon *Daemon) refreshImage(s *container.Snapshot, filter *listContext) (
|
||||||
c := s.Container
|
c := s.Container
|
||||||
tmpImage := s.Image // keep the original ref if still valid (hasn't changed)
|
tmpImage := s.Image // keep the original ref if still valid (hasn't changed)
|
||||||
if tmpImage != s.ImageID {
|
if tmpImage != s.ImageID {
|
||||||
img, err := daemon.imageService.GetImage(tmpImage, nil)
|
img, err := daemon.imageService.GetImage(tmpImage, imagetypes.GetImageOpts{})
|
||||||
if _, isDNE := err.(images.ErrImageDoesNotExist); err != nil && !isDNE {
|
if _, isDNE := err.(images.ErrImageDoesNotExist); err != nil && !isDNE {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
containertypes "github.com/docker/docker/api/types/container"
|
containertypes "github.com/docker/docker/api/types/container"
|
||||||
|
imagetypes "github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/docker/docker/oci"
|
"github.com/docker/docker/oci"
|
||||||
|
@ -26,7 +27,7 @@ const (
|
||||||
|
|
||||||
func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
|
func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
|
||||||
|
|
||||||
img, err := daemon.imageService.GetImage(string(c.ImageID), nil)
|
img, err := daemon.imageService.GetImage(string(c.ImageID), imagetypes.GetImageOpts{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue