Allow digest builder references
Update `BuildRequest` to also allow digest based references. Closes gh-21879
This commit is contained in:
parent
8a249daf1a
commit
1e7da4d3ca
|
@ -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 {
|
||||||
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"));
|
||||||
|
|
Loading…
Reference in New Issue