ImageService.ImageHistory(): pass context

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-12-09 19:00:49 +01:00
parent 77f9c550bd
commit a8eb15eafb
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
5 changed files with 6 additions and 6 deletions

View file

@ -22,7 +22,7 @@ type Backend interface {
type imageBackend interface {
ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)
ImageHistory(imageName string) ([]*image.HistoryResponseItem, error)
ImageHistory(ctx context.Context, imageName string) ([]*image.HistoryResponseItem, error)
Images(ctx context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error)
GetImage(ctx context.Context, refOrID string, options image.GetImageOpts) (*dockerimage.Image, error)
TagImage(imageName, repository, tag string) (string, error)

View file

@ -321,7 +321,7 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
}
func (ir *imageRouter) getImagesHistory(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
history, err := ir.backend.ImageHistory(vars["name"])
history, err := ir.backend.ImageHistory(ctx, vars["name"])
if err != nil {
return err
}

View file

@ -1,6 +1,7 @@
package containerd
import (
"context"
"errors"
imagetype "github.com/docker/docker/api/types/image"
@ -9,6 +10,6 @@ import (
// ImageHistory returns a slice of ImageHistory structures for the specified
// image name by walking the image lineage.
func (i *ImageService) ImageHistory(name string) ([]*imagetype.HistoryResponseItem, error) {
func (i *ImageService) ImageHistory(ctx context.Context, name string) ([]*imagetype.HistoryResponseItem, error) {
return nil, errdefs.NotImplemented(errors.New("not implemented"))
}

View file

@ -40,7 +40,7 @@ type ImageService interface {
TagImage(imageName, repository, tag string) (string, error)
TagImageWithReference(imageID image.ID, newTag reference.Named) error
GetImage(ctx context.Context, refOrID string, options imagetype.GetImageOpts) (*image.Image, error)
ImageHistory(name string) ([]*imagetype.HistoryResponseItem, error)
ImageHistory(ctx context.Context, name string) ([]*imagetype.HistoryResponseItem, error)
CommitImage(c backend.CommitConfig) (image.ID, error)
SquashImage(id, parent string) (string, error)

View file

@ -12,8 +12,7 @@ import (
// ImageHistory returns a slice of ImageHistory structures for the specified image
// name by walking the image lineage.
func (i *ImageService) ImageHistory(name string) ([]*image.HistoryResponseItem, error) {
ctx := context.TODO()
func (i *ImageService) ImageHistory(ctx context.Context, name string) ([]*image.HistoryResponseItem, error) {
start := time.Now()
img, err := i.GetImage(ctx, name, image.GetImageOpts{})
if err != nil {