CRI: Retrieve image spec on client
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
@@ -18,12 +18,10 @@ package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/pkg/cri/util"
|
||||
|
||||
@@ -132,15 +130,12 @@ func getImage(ctx context.Context, i containerd.Image) (*Image, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get image config descriptor: %w", err)
|
||||
}
|
||||
|
||||
id := desc.Digest.String()
|
||||
|
||||
rb, err := content.ReadBlob(ctx, i.ContentStore(), desc)
|
||||
spec, err := i.Spec(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read image config from content store: %w", err)
|
||||
}
|
||||
var ociimage imagespec.Image
|
||||
if err := json.Unmarshal(rb, &ociimage); err != nil {
|
||||
return nil, fmt.Errorf("unmarshal image config %s: %w", rb, err)
|
||||
return nil, fmt.Errorf("failed to read get image spec: %w", err)
|
||||
}
|
||||
|
||||
return &Image{
|
||||
@@ -148,7 +143,7 @@ func getImage(ctx context.Context, i containerd.Image) (*Image, error) {
|
||||
References: []string{i.Name()},
|
||||
ChainID: chainID.String(),
|
||||
Size: size,
|
||||
ImageSpec: ociimage,
|
||||
ImageSpec: spec,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user