Polish "Add pullPolicy option for image building"
See gh-22736
This commit is contained in:
@@ -61,6 +61,12 @@ The following table summarizes the available properties and their default values
|
||||
| {spring-boot-api}/buildpack/platform/docker/type/ImageReference.html#of-java.lang.String-[Image name] for the generated image.
|
||||
| `docker.io/library/${project.artifactId}:${project.version}`
|
||||
|
||||
| `pullPolicy`
|
||||
| `--pullPolicy`
|
||||
| {spring-boot-api}/buildpack/platform/build/PullPolicy.html[Policy] used to determine when to pull the builder and run images from the registry.
|
||||
Acceptable values are `ALWAYS`, `NEVER`, and `IF_NOT_PRESENT`.
|
||||
| `ALWAYS`
|
||||
|
||||
| `environment`
|
||||
|
|
||||
| Environment variables that should be passed to the builder.
|
||||
|
||||
@@ -126,6 +126,31 @@ class BootBuildImageIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void buildsImageWithPullPolicy() throws IOException {
|
||||
writeMainClass();
|
||||
writeLongNameResource();
|
||||
String projectName = this.gradleBuild.getProjectDir().getName();
|
||||
ImageReference imageReference = ImageReference.of(ImageName.of(projectName));
|
||||
|
||||
BuildResult result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=ALWAYS");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("Pulled builder image").contains("Pulled run image");
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageReference.toString())) {
|
||||
container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start();
|
||||
}
|
||||
|
||||
result = this.gradleBuild.build("bootBuildImage", "--pullPolicy=IF_NOT_PRESENT");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).doesNotContain("Pulled builder image").doesNotContain("Pulled run image");
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageReference.toString())) {
|
||||
container.waitingFor(Wait.forLogMessage("Launched\\n", 1)).start();
|
||||
}
|
||||
finally {
|
||||
new DockerApi().image().remove(imageReference, false);
|
||||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void failsWithLaunchScript() {
|
||||
writeMainClass();
|
||||
|
||||
@@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Scott Frederick
|
||||
* @author Andrey Shlykov
|
||||
*/
|
||||
class BootBuildImageTests {
|
||||
|
||||
@@ -196,12 +197,12 @@ class BootBuildImageTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingDefaultConfigurationThenRequestHasNoPullDisabled() {
|
||||
void whenUsingDefaultConfigurationThenRequestHasAlwaysPullPolicy() {
|
||||
assertThat(this.buildImage.createRequest().getPullPolicy()).isEqualTo(PullPolicy.ALWAYS);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenNoPullIsEnabledThenRequestHasNoPullEnabled() {
|
||||
void whenPullPolicyIsConfiguredThenRequestHasPullPolicy() {
|
||||
this.buildImage.setPullPolicy(PullPolicy.NEVER);
|
||||
assertThat(this.buildImage.createRequest().getPullPolicy()).isEqualTo(PullPolicy.NEVER);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user