11
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
15
func (c *Client) PullImage(ctx context.Context, image *runtimeapi.ImageSpec, sandboxConfig *runtimeapi.PodSandboxConfig) (string, error) {
16
resp, err := c.imagesClient.PullImage(ctx, &runtimeapi.PullImageRequest{
18
SandboxConfig: sandboxConfig,
21
return "", fmt.Errorf("error pulling image %s: %w", image, err)
24
return resp.ImageRef, nil
28
func (c *Client) ListImages(ctx context.Context, filter *runtimeapi.ImageFilter) ([]*runtimeapi.Image, error) {
29
resp, err := c.imagesClient.ListImages(ctx, &runtimeapi.ListImagesRequest{
33
return nil, fmt.Errorf("error listing images: %w", err)
36
return resp.Images, nil
40
func (c *Client) ImageStatus(ctx context.Context, image *runtimeapi.ImageSpec) (*runtimeapi.Image, error) {
41
resp, err := c.imagesClient.ImageStatus(ctx, &runtimeapi.ImageStatusRequest{
45
return nil, fmt.Errorf("ImageStatus %q from image service failed: %w", image.Image, err)
48
if resp.Image != nil {
49
if resp.Image.Id == "" || resp.Image.Size_ == 0 {
50
return nil, fmt.Errorf("id or size of image %q is not set", image.Image)
54
return resp.Image, nil