Add pullPolicy option for image building

This commit adds a pullPolicy option to the configuration of the Maven
plugin spring-boot:build-image goal and the Gradle plugin bootBuildImage
task. The new option gives users control over pulling the builder image
and run image from a remote image registry to the local Docker daemon.

See gh-22736
This commit is contained in:
anshlykov
2020-08-03 02:24:07 +03:00
committed by Scott Frederick
parent b35cfb7fb7
commit c7449b57ce
15 changed files with 371 additions and 33 deletions

View File

@@ -26,6 +26,7 @@ import org.apache.maven.artifact.versioning.VersionRange;
import org.junit.jupiter.api.Test;
import org.springframework.boot.buildpack.platform.build.BuildRequest;
import org.springframework.boot.buildpack.platform.build.PullPolicy;
import org.springframework.boot.buildpack.platform.io.Owner;
import org.springframework.boot.buildpack.platform.io.TarArchive;
@@ -63,6 +64,7 @@ class ImageTests {
assertThat(request.getEnv()).isEmpty();
assertThat(request.isCleanCache()).isFalse();
assertThat(request.isVerboseLogging()).isFalse();
assertThat(request.getPullPolicy()).isEqualTo(PullPolicy.ALWAYS);
}
@Test
@@ -105,6 +107,14 @@ class ImageTests {
assertThat(request.isVerboseLogging()).isTrue();
}
@Test
void getBuildRequestWhenHasPullPolicyUsesPullPolicy() {
Image image = new Image();
image.setPullPolicy(PullPolicy.NEVER);
BuildRequest request = image.getBuildRequest(createArtifact(), mockApplicationContent());
assertThat(request.getPullPolicy()).isEqualTo(PullPolicy.NEVER);
}
private Artifact createArtifact() {
return new DefaultArtifact("com.example", "my-app", VersionRange.createFromVersion("0.0.1-SNAPSHOT"), "compile",
"jar", null, new DefaultArtifactHandler());