Skip to content

Commit

Permalink
Allow digest builder references
Browse files Browse the repository at this point in the history
Update `BuildRequest` to also allow digest based references.

Closes gh-21879
  • Loading branch information
philwebb committed Jun 11, 2020
1 parent 8a249da commit 1e7da4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Expand Up @@ -84,8 +84,9 @@ public class BuildRequest {
*/
public BuildRequest withBuilder(ImageReference builder) {
Assert.notNull(builder, "Builder must not be null");
return new BuildRequest(this.name, this.applicationContent, builder.inTaggedForm(), this.creator, this.env,
this.cleanCache, this.verboseLogging);
builder = (builder.getDigest() != null) ? builder : builder.inTaggedForm();
return new BuildRequest(this.name, this.applicationContent, builder, this.creator, this.env, this.cleanCache,
this.verboseLogging);
}

/**
Expand Down
Expand Up @@ -98,6 +98,14 @@ void withBuilderUpdatesBuilder() throws IOException {
assertThat(request.getBuilder().toString()).isEqualTo("docker.io/spring/builder:latest");
}

@Test
void withBuilderWhenHasDigestUpdatesBuilder() throws IOException {
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar")).withBuilder(ImageReference
.of("spring/builder:@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d"));
assertThat(request.getBuilder().toString()).isEqualTo(
"docker.io/spring/builder:@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
}

@Test
void withCreatorUpdatesCreator() throws IOException {
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
Expand Down

0 comments on commit 1e7da4d

Please sign in to comment.