Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions pkg/client/create_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ func (c *Client) validateRunImageConfig(ctx context.Context, opts CreateBuilderO
if !opts.Publish {
img, err := c.imageFetcher.Fetch(ctx, i, image.FetchOptions{Daemon: true, PullPolicy: opts.PullPolicy, Target: target})
if err != nil {
if errors.Cause(err) != image.ErrNotFound {
return errors.Wrap(err, "failed to fetch image")
}
c.logger.Warnf("run image %s is not accessible", style.Symbol(i))
} else {
runImages = append(runImages, img)
continue
Expand All @@ -183,9 +181,6 @@ func (c *Client) validateRunImageConfig(ctx context.Context, opts CreateBuilderO

img, err := c.imageFetcher.Fetch(ctx, i, image.FetchOptions{Daemon: false, PullPolicy: opts.PullPolicy, Target: target})
if err != nil {
if errors.Cause(err) != image.ErrNotFound {
return errors.Wrap(err, "failed to fetch image")
}
c.logger.Warnf("run image %s is not accessible", style.Symbol(i))
} else {
runImages = append(runImages, img)
Expand Down
16 changes: 6 additions & 10 deletions pkg/client/create_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,19 +388,15 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
h.AssertContains(t, out.String(), "Warning: run image 'some/run-image' is not accessible")
})

it("should fail when not publish and the run image cannot be fetched", func() {
mockImageFetcher.EXPECT().Fetch(gomock.Any(), "some/run-image", image.FetchOptions{Daemon: true, PullPolicy: image.PullAlways}).Return(nil, errors.New("yikes"))

err := subject.CreateBuilder(context.TODO(), opts)
h.AssertError(t, err, "failed to fetch image: yikes")
})

it("should fail when publish and the run image cannot be fetched", func() {
mockImageFetcher.EXPECT().Fetch(gomock.Any(), "some/run-image", image.FetchOptions{Daemon: false, PullPolicy: image.PullAlways}).Return(nil, errors.New("yikes"))
it("should warn when publish and the run image cannot be fetched", func() {
prepareFetcherWithBuildImage()
mockImageFetcher.EXPECT().Fetch(gomock.Any(), "some/run-image", image.FetchOptions{Daemon: false, PullPolicy: image.PullAlways}).Return(nil, errors.Wrap(image.ErrNotFound, "yikes"))
mockImageFetcher.EXPECT().Fetch(gomock.Any(), "localhost:5000/some/run-image", image.FetchOptions{Daemon: false, PullPolicy: image.PullAlways}).Return(nil, errors.Wrap(image.ErrNotFound, "yikes"))

opts.Publish = true
err := subject.CreateBuilder(context.TODO(), opts)
h.AssertError(t, err, "failed to fetch image: yikes")
h.AssertNil(t, err)
h.AssertContains(t, out.String(), "Warning: run image 'some/run-image' is not accessible")
})

it("should fail when the run image isn't a valid image", func() {
Expand Down
Loading