Skip to content

Commit

Permalink
create-builder only validates remote run-images when publish is true
Browse files Browse the repository at this point in the history
Signed-off-by: Emily Casey <ecasey@pivotal.io>
  • Loading branch information
ekcasey committed Jun 12, 2019
1 parent 7a16588 commit e1a17ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
18 changes: 10 additions & 8 deletions create_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,19 @@ func validateBuilderConfig(conf builder.Config) error {
func (c *Client) validateRunImageConfig(ctx context.Context, opts CreateBuilderOptions) error {
var runImages []imgutil.Image
for _, i := range append([]string{opts.BuilderConfig.Stack.RunImage}, opts.BuilderConfig.Stack.RunImageMirrors...) {
img, err := c.imageFetcher.Fetch(ctx, i, true, false)
if err != nil {
if errors.Cause(err) != image.ErrNotFound {
return err
if !opts.Publish {
img, err := c.imageFetcher.Fetch(ctx, i, true, false)
if err != nil {
if errors.Cause(err) != image.ErrNotFound {
return err
}
} else {
runImages = append(runImages, img)
continue
}
} else {
runImages = append(runImages, img)
continue
}

img, err = c.imageFetcher.Fetch(ctx, i, false, false)
img, err := c.imageFetcher.Fetch(ctx, i, false, false)
if err != nil {
if errors.Cause(err) != image.ErrNotFound {
return err
Expand Down
13 changes: 13 additions & 0 deletions create_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ 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")
})

when("publish is true", func() {
it("should only try to validate the remote run image", func() {
delete(imageFetcher.LocalImages, "some/run-image")
delete(imageFetcher.LocalImages, "some/build-image")
imageFetcher.RemoteImages["some/run-image"] = fakeRunImage
imageFetcher.RemoteImages["some/build-image"] = fakeBuildImage

opts.Publish = true
err := subject.CreateBuilder(context.TODO(), opts)
h.AssertNil(t, err)
})
})
})

it("should create a new builder image", func() {
Expand Down

0 comments on commit e1a17ff

Please sign in to comment.