Commit 1e7da4d3 authored by Phillip Webb's avatar Phillip Webb

Allow digest builder references

Update `BuildRequest` to also allow digest based references.

Closes gh-21879
parent 8a249daf
...@@ -84,8 +84,9 @@ public class BuildRequest { ...@@ -84,8 +84,9 @@ public class BuildRequest {
*/ */
public BuildRequest withBuilder(ImageReference builder) { public BuildRequest withBuilder(ImageReference builder) {
Assert.notNull(builder, "Builder must not be null"); Assert.notNull(builder, "Builder must not be null");
return new BuildRequest(this.name, this.applicationContent, builder.inTaggedForm(), this.creator, this.env, builder = (builder.getDigest() != null) ? builder : builder.inTaggedForm();
this.cleanCache, this.verboseLogging); return new BuildRequest(this.name, this.applicationContent, builder, this.creator, this.env, this.cleanCache,
this.verboseLogging);
} }
/** /**
......
...@@ -98,6 +98,14 @@ public class BuildRequestTests { ...@@ -98,6 +98,14 @@ public class BuildRequestTests {
assertThat(request.getBuilder().toString()).isEqualTo("docker.io/spring/builder:latest"); 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 @Test
void withCreatorUpdatesCreator() throws IOException { void withCreatorUpdatesCreator() throws IOException {
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar")); BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment