Skip to content

Commit 0501346

Browse files
committed
feat: log warning if unable to validateRunImageConfig for whatever error returned (#2584)
1 parent a7f39ca commit 0501346

2 files changed

Lines changed: 7 additions & 16 deletions

File tree

pkg/client/create_builder.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,7 @@ func (c *Client) validateRunImageConfig(ctx context.Context, opts CreateBuilderO
172172
if !opts.Publish {
173173
img, err := c.imageFetcher.Fetch(ctx, i, image.FetchOptions{Daemon: true, PullPolicy: opts.PullPolicy, Target: target})
174174
if err != nil {
175-
if errors.Cause(err) != image.ErrNotFound {
176-
return errors.Wrap(err, "failed to fetch image")
177-
}
175+
c.logger.Warnf("run image %s is not accessible", style.Symbol(i))
178176
} else {
179177
runImages = append(runImages, img)
180178
continue
@@ -183,9 +181,6 @@ func (c *Client) validateRunImageConfig(ctx context.Context, opts CreateBuilderO
183181

184182
img, err := c.imageFetcher.Fetch(ctx, i, image.FetchOptions{Daemon: false, PullPolicy: opts.PullPolicy, Target: target})
185183
if err != nil {
186-
if errors.Cause(err) != image.ErrNotFound {
187-
return errors.Wrap(err, "failed to fetch image")
188-
}
189184
c.logger.Warnf("run image %s is not accessible", style.Symbol(i))
190185
} else {
191186
runImages = append(runImages, img)

pkg/client/create_builder_test.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,19 +388,15 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
388388
h.AssertContains(t, out.String(), "Warning: run image 'some/run-image' is not accessible")
389389
})
390390

391-
it("should fail when not publish and the run image cannot be fetched", func() {
392-
mockImageFetcher.EXPECT().Fetch(gomock.Any(), "some/run-image", image.FetchOptions{Daemon: true, PullPolicy: image.PullAlways}).Return(nil, errors.New("yikes"))
393-
394-
err := subject.CreateBuilder(context.TODO(), opts)
395-
h.AssertError(t, err, "failed to fetch image: yikes")
396-
})
397-
398-
it("should fail when publish and the run image cannot be fetched", func() {
399-
mockImageFetcher.EXPECT().Fetch(gomock.Any(), "some/run-image", image.FetchOptions{Daemon: false, PullPolicy: image.PullAlways}).Return(nil, errors.New("yikes"))
391+
it("should warn when publish and the run image cannot be fetched", func() {
392+
prepareFetcherWithBuildImage()
393+
mockImageFetcher.EXPECT().Fetch(gomock.Any(), "some/run-image", image.FetchOptions{Daemon: false, PullPolicy: image.PullAlways}).Return(nil, errors.Wrap(image.ErrNotFound, "yikes"))
394+
mockImageFetcher.EXPECT().Fetch(gomock.Any(), "localhost:5000/some/run-image", image.FetchOptions{Daemon: false, PullPolicy: image.PullAlways}).Return(nil, errors.Wrap(image.ErrNotFound, "yikes"))
400395

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

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

0 commit comments

Comments
 (0)