Proposed fix for image content store
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
a21a19a658
commit
f6e877e8be
6
image.go
6
image.go
@ -32,6 +32,8 @@ type Image interface {
|
||||
Config(ctx context.Context) (ocispec.Descriptor, error)
|
||||
// IsUnpacked returns whether or not an image is unpacked.
|
||||
IsUnpacked(context.Context, string) (bool, error)
|
||||
// ContentStore provides a content store which contains image blob data
|
||||
ContentStore() content.Store
|
||||
}
|
||||
|
||||
var _ = (Image)(&image{})
|
||||
@ -166,3 +168,7 @@ func (i *image) getLayers(ctx context.Context, platform string) ([]rootfs.Layer,
|
||||
}
|
||||
return layers, nil
|
||||
}
|
||||
|
||||
func (i *image) ContentStore() content.Store {
|
||||
return i.client.ContentStore()
|
||||
}
|
||||
|
@ -11,11 +11,12 @@ import (
|
||||
// Client interface used by SpecOpt
|
||||
type Client interface {
|
||||
SnapshotService(snapshotterName string) snapshot.Snapshotter
|
||||
ContentStore() content.Store
|
||||
}
|
||||
|
||||
// Image interface used by some SpecOpt to query image configuration
|
||||
type Image interface {
|
||||
// Config descriptor for the image.
|
||||
Config(ctx context.Context) (ocispec.Descriptor, error)
|
||||
// ContentStore provides a content store which contains image blob data
|
||||
ContentStore() content.Store
|
||||
}
|
||||
|
@ -67,12 +67,6 @@ func WithLinuxNamespace(ns specs.LinuxNamespace) SpecOpts {
|
||||
// WithImageConfig configures the spec to from the configuration of an Image
|
||||
func WithImageConfig(image Image) SpecOpts {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) error {
|
||||
store := client.ContentStore()
|
||||
// TODO: needs review. Previous this passed in a store, now it's using
|
||||
// a store that is part of the client. This makes the assumption that
|
||||
// the client store is the same as the one wrapped by `image`.
|
||||
// Is this assumption safe? Should the interface be changed to accept
|
||||
// a store instead of wrapping one?
|
||||
ic, err := image.Config(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -83,7 +77,7 @@ func WithImageConfig(image Image) SpecOpts {
|
||||
)
|
||||
switch ic.MediaType {
|
||||
case v1.MediaTypeImageConfig, images.MediaTypeDockerSchema2Config:
|
||||
p, err := content.ReadBlob(ctx, store, ic.Digest)
|
||||
p, err := content.ReadBlob(ctx, image.ContentStore(), ic.Digest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
// WithImageConfig configures the spec to from the configuration of an Image
|
||||
func WithImageConfig(image Image) SpecOpts {
|
||||
return func(ctx context.Context, client Client, _ *containers.Container, s *specs.Spec) error {
|
||||
store := client.ContentStore()
|
||||
ic, err := image.Config(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -28,7 +27,7 @@ func WithImageConfig(image Image) SpecOpts {
|
||||
)
|
||||
switch ic.MediaType {
|
||||
case v1.MediaTypeImageConfig, images.MediaTypeDockerSchema2Config:
|
||||
p, err := content.ReadBlob(ctx, store, ic.Digest)
|
||||
p, err := content.ReadBlob(ctx, image.ContentStore(), ic.Digest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user