Skip to content

Commit d64d8a0

Browse files
committed
Use image constructor in client
Replace manual image struct creation with the image constructor which is there to do just that. Signed-off-by: Derek McGowan <[email protected]>
1 parent 3629344 commit d64d8a0

4 files changed

Lines changed: 5 additions & 20 deletions

File tree

client.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,7 @@ func (c *Client) GetImage(ctx context.Context, ref string) (Image, error) {
449449
if err != nil {
450450
return nil, err
451451
}
452-
return &image{
453-
client: c,
454-
i: i,
455-
}, nil
452+
return NewImage(c, i), nil
456453
}
457454

458455
// ListImages returns all existing images
@@ -463,10 +460,7 @@ func (c *Client) ListImages(ctx context.Context, filters ...string) ([]Image, er
463460
}
464461
images := make([]Image, len(imgs))
465462
for i, img := range imgs {
466-
images[i] = &image{
467-
client: c,
468-
i: img,
469-
}
463+
images[i] = NewImage(c, img)
470464
}
471465
return images, nil
472466
}

container.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,7 @@ func (c *container) Image(ctx context.Context) (Image, error) {
173173
if err != nil {
174174
return nil, errors.Wrapf(err, "failed to get image %s for container", r.Image)
175175
}
176-
return &image{
177-
client: c.client,
178-
i: i,
179-
}, nil
176+
return NewImage(c.client, i), nil
180177
}
181178

182179
func (c *container) NewTask(ctx context.Context, ioCreate cio.Creator, opts ...NewTaskOpts) (_ Task, err error) {

import.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ func (c *Client) Import(ctx context.Context, importer images.Importer, reader io
8080
imgrec = updated
8181
}
8282

83-
images = append(images, &image{
84-
client: c,
85-
i: imgrec,
86-
})
83+
images = append(images, NewImage(c, imgrec))
8784
}
8885
return images, nil
8986
}

task.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,7 @@ func (t *task) Checkpoint(ctx context.Context, opts ...CheckpointTaskOpts) (Imag
458458
if im, err = t.client.ImageService().Create(ctx, im); err != nil {
459459
return nil, err
460460
}
461-
return &image{
462-
client: t.client,
463-
i: im,
464-
}, nil
461+
return NewImage(t.client, im), nil
465462
}
466463

467464
// UpdateTaskInfo allows updated specific settings to be changed on a task

0 commit comments

Comments
 (0)