Merge pull request #8597 from thaJeztah/unpack_nits

Image: fix some minor nits
This commit is contained in:
Samuel Karp 2023-05-31 02:06:48 -07:00 committed by GitHub
commit 8454b23ead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,7 +58,7 @@ type Image interface {
Usage(context.Context, ...UsageOpt) (int64, error) Usage(context.Context, ...UsageOpt) (int64, error)
// Config descriptor for the image. // Config descriptor for the image.
Config(ctx context.Context) (ocispec.Descriptor, error) Config(ctx context.Context) (ocispec.Descriptor, error)
// IsUnpacked returns whether or not an image is unpacked. // IsUnpacked returns whether an image is unpacked.
IsUnpacked(context.Context, string) (bool, error) IsUnpacked(context.Context, string) (bool, error)
// ContentStore provides a content store which contains image blob data // ContentStore provides a content store which contains image blob data
ContentStore() content.Store ContentStore() content.Store
@ -285,15 +285,14 @@ func (i *image) IsUnpacked(ctx context.Context, snapshotterName string) (bool, e
return false, err return false, err
} }
chainID := identity.ChainID(diffs) if _, err := sn.Stat(ctx, identity.ChainID(diffs).String()); err != nil {
_, err = sn.Stat(ctx, chainID.String()) if errdefs.IsNotFound(err) {
if err == nil { return false, nil
return true, nil }
} else if !errdefs.IsNotFound(err) {
return false, err return false, err
} }
return false, nil return true, nil
} }
func (i *image) Spec(ctx context.Context) (ocispec.Image, error) { func (i *image) Spec(ctx context.Context) (ocispec.Image, error) {
@ -423,12 +422,12 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string, opts ...Unpa
return err return err
} }
rootfs := identity.ChainID(chain).String() rootFS := identity.ChainID(chain).String()
cinfo := content.Info{ cinfo := content.Info{
Digest: desc.Digest, Digest: desc.Digest,
Labels: map[string]string{ Labels: map[string]string{
fmt.Sprintf("containerd.io/gc.ref.snapshot.%s", snapshotterName): rootfs, fmt.Sprintf("containerd.io/gc.ref.snapshot.%s", snapshotterName): rootFS,
}, },
} }