use of org.springframework.boot.buildpack.platform.build.BuildRequest in project spring-boot by spring-projects.
the class BuildImageMojo method getBuildRequest.
private BuildRequest getBuildRequest(Libraries libraries) throws MojoExecutionException {
ImagePackager imagePackager = new ImagePackager(getArchiveFile(), getBackupFile());
Function<Owner, TarArchive> content = (owner) -> getApplicationContent(owner, libraries, imagePackager);
Image image = (this.image != null) ? this.image : new Image();
if (image.name == null && this.imageName != null) {
image.setName(this.imageName);
}
if (image.builder == null && this.imageBuilder != null) {
image.setBuilder(this.imageBuilder);
}
if (image.runImage == null && this.runImage != null) {
image.setRunImage(this.runImage);
}
if (image.cleanCache == null && this.cleanCache != null) {
image.setCleanCache(this.cleanCache);
}
if (image.pullPolicy == null && this.pullPolicy != null) {
image.setPullPolicy(this.pullPolicy);
}
if (image.publish == null && this.publish != null) {
image.setPublish(this.publish);
}
if (image.network == null && this.network != null) {
image.setNetwork(this.network);
}
if (image.publish != null && image.publish && publishRegistryNotConfigured()) {
throw new MojoExecutionException("Publishing an image requires docker.publishRegistry to be configured");
}
return customize(image.getBuildRequest(this.project.getArtifact(), content));
}
use of org.springframework.boot.buildpack.platform.build.BuildRequest in project spring-boot by spring-projects.
the class BuildImageMojo method buildImage.
private void buildImage() throws MojoExecutionException {
Libraries libraries = getLibraries(Collections.emptySet());
try {
DockerConfiguration dockerConfiguration = (this.docker != null) ? this.docker.asDockerConfiguration() : null;
BuildRequest request = getBuildRequest(libraries);
Builder builder = new Builder(new MojoBuildLog(this::getLog), dockerConfiguration);
builder.build(request);
} catch (IOException ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
}
use of org.springframework.boot.buildpack.platform.build.BuildRequest in project spring-boot by spring-projects.
the class BootBuildImageTests method whenProjectVersionIsSpecifiedThenItIsUsedInTagOfImageName.
@Test
void whenProjectVersionIsSpecifiedThenItIsUsedInTagOfImageName() {
this.project.setVersion("1.2.3");
assertThat(this.buildImage.getImageName()).isEqualTo("docker.io/library/build-image-test:1.2.3");
BuildRequest request = this.buildImage.createRequest();
assertThat(request.getName().getDomain()).isEqualTo("docker.io");
assertThat(request.getName().getName()).isEqualTo("library/build-image-test");
assertThat(request.getName().getTag()).isEqualTo("1.2.3");
assertThat(request.getName().getDigest()).isNull();
}
use of org.springframework.boot.buildpack.platform.build.BuildRequest in project spring-boot by spring-projects.
the class BootBuildImageTests method whenProjectVersionIsUnspecifiedThenItIsIgnoredWhenDerivingImageName.
@Test
void whenProjectVersionIsUnspecifiedThenItIsIgnoredWhenDerivingImageName() {
assertThat(this.buildImage.getImageName()).isEqualTo("docker.io/library/build-image-test");
BuildRequest request = this.buildImage.createRequest();
assertThat(request.getName().getDomain()).isEqualTo("docker.io");
assertThat(request.getName().getName()).isEqualTo("library/build-image-test");
assertThat(request.getName().getTag()).isEqualTo("latest");
assertThat(request.getName().getDigest()).isNull();
}
use of org.springframework.boot.buildpack.platform.build.BuildRequest in project spring-boot by spring-projects.
the class BootBuildImageTests method springBootVersionDefaultValueIsUsed.
@Test
void springBootVersionDefaultValueIsUsed() {
BuildRequest request = this.buildImage.createRequest();
assertThat(request.getCreator().getName()).isEqualTo("Spring Boot");
assertThat(request.getCreator().getVersion()).isEqualTo("");
}
Aggregations