Search in sources :

Example 1 with TarArchive

use of org.springframework.boot.buildpack.platform.io.TarArchive 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));
}
Also used : AbstractBuildLog(org.springframework.boot.buildpack.platform.build.AbstractBuildLog) TotalProgressEvent(org.springframework.boot.buildpack.platform.docker.TotalProgressEvent) Parameter(org.apache.maven.plugins.annotations.Parameter) Function(java.util.function.Function) Supplier(java.util.function.Supplier) TarConstants(org.apache.commons.compress.archivers.tar.TarConstants) Execute(org.apache.maven.plugins.annotations.Execute) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) Mojo(org.apache.maven.plugins.annotations.Mojo) LayoutFactory(org.springframework.boot.loader.tools.LayoutFactory) TarArchiveEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry) TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive) Duration(java.time.Duration) Artifact(org.apache.maven.artifact.Artifact) LifecyclePhase(org.apache.maven.plugins.annotations.LifecyclePhase) ResolutionScope(org.apache.maven.plugins.annotations.ResolutionScope) ZipEntry(java.util.zip.ZipEntry) OutputStream(java.io.OutputStream) DockerConfiguration(org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration) ImagePackager(org.springframework.boot.loader.tools.ImagePackager) PullPolicy(org.springframework.boot.buildpack.platform.build.PullPolicy) BuildLog(org.springframework.boot.buildpack.platform.build.BuildLog) Builder(org.springframework.boot.buildpack.platform.build.Builder) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Log(org.apache.maven.plugin.logging.Log) Creator(org.springframework.boot.buildpack.platform.build.Creator) Libraries(org.springframework.boot.loader.tools.Libraries) File(java.io.File) Consumer(java.util.function.Consumer) BuildRequest(org.springframework.boot.buildpack.platform.build.BuildRequest) Owner(org.springframework.boot.buildpack.platform.io.Owner) EntryWriter(org.springframework.boot.loader.tools.EntryWriter) Collections(java.util.Collections) StringUtils(org.springframework.util.StringUtils) Owner(org.springframework.boot.buildpack.platform.io.Owner) TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ImagePackager(org.springframework.boot.loader.tools.ImagePackager)

Example 2 with TarArchive

use of org.springframework.boot.buildpack.platform.io.TarArchive in project spring-boot by spring-projects.

the class LifecycleTests method getTestRequest.

private BuildRequest getTestRequest() {
    TarArchive content = mock(TarArchive.class);
    ImageReference name = ImageReference.of("my-application");
    return BuildRequest.of(name, (owner) -> content).withRunImage(ImageReference.of("cloudfoundry/run"));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) VolumeApi(org.springframework.boot.buildpack.platform.docker.DockerApi.VolumeApi) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ContainerConfig(org.springframework.boot.buildpack.platform.docker.type.ContainerConfig) ImageReference(org.springframework.boot.buildpack.platform.docker.type.ImageReference) LinkedHashMap(java.util.LinkedHashMap) Answer(org.mockito.stubbing.Answer) ImageApi(org.springframework.boot.buildpack.platform.docker.DockerApi.ImageApi) BDDMockito.given(org.mockito.BDDMockito.given) ContainerReference(org.springframework.boot.buildpack.platform.docker.type.ContainerReference) TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive) Map(java.util.Map) SharedObjectMapper(org.springframework.boot.buildpack.platform.json.SharedObjectMapper) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) JsonNode(com.fasterxml.jackson.databind.JsonNode) ContainerContent(org.springframework.boot.buildpack.platform.docker.type.ContainerContent) PrintStream(java.io.PrintStream) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) BDDMockito.then(org.mockito.BDDMockito.then) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ContainerStatus(org.springframework.boot.buildpack.platform.docker.type.ContainerStatus) InputStreamReader(java.io.InputStreamReader) StandardCharsets(java.nio.charset.StandardCharsets) DockerApi(org.springframework.boot.buildpack.platform.docker.DockerApi) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Test(org.junit.jupiter.api.Test) IOConsumer(org.springframework.boot.buildpack.platform.io.IOConsumer) ContainerApi(org.springframework.boot.buildpack.platform.docker.DockerApi.ContainerApi) Binding(org.springframework.boot.buildpack.platform.docker.type.Binding) VolumeName(org.springframework.boot.buildpack.platform.docker.type.VolumeName) FileCopyUtils(org.springframework.util.FileCopyUtils) InputStream(java.io.InputStream) Mockito.mock(org.mockito.Mockito.mock) ImageReference(org.springframework.boot.buildpack.platform.docker.type.ImageReference) TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive)

Example 3 with TarArchive

use of org.springframework.boot.buildpack.platform.io.TarArchive in project spring-boot by spring-projects.

the class ContainerContentTests method ofWhenDestinationPathIsEmptyThrowsException.

@Test
void ofWhenDestinationPathIsEmptyThrowsException() {
    TarArchive archive = mock(TarArchive.class);
    assertThatIllegalArgumentException().isThrownBy(() -> ContainerContent.of(archive, "")).withMessage("DestinationPath must not be empty");
}
Also used : TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive) Test(org.junit.jupiter.api.Test)

Example 4 with TarArchive

use of org.springframework.boot.buildpack.platform.io.TarArchive in project spring-boot by spring-projects.

the class ContainerContentTests method ofWhenDestinationPathIsNullThrowsException.

@Test
void ofWhenDestinationPathIsNullThrowsException() {
    TarArchive archive = mock(TarArchive.class);
    assertThatIllegalArgumentException().isThrownBy(() -> ContainerContent.of(archive, null)).withMessage("DestinationPath must not be empty");
}
Also used : TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive) Test(org.junit.jupiter.api.Test)

Example 5 with TarArchive

use of org.springframework.boot.buildpack.platform.io.TarArchive in project spring-boot by spring-projects.

the class BuilderTests method getTestRequest.

private BuildRequest getTestRequest() {
    TarArchive content = mock(TarArchive.class);
    ImageReference name = ImageReference.of("my-application");
    return BuildRequest.of(name, (owner) -> content);
}
Also used : ImageReference(org.springframework.boot.buildpack.platform.docker.type.ImageReference) TarArchive(org.springframework.boot.buildpack.platform.io.TarArchive)

Aggregations

TarArchive (org.springframework.boot.buildpack.platform.io.TarArchive)8 Test (org.junit.jupiter.api.Test)6 IOException (java.io.IOException)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)2 TarArchiveOutputStream (org.apache.commons.compress.archivers.tar.TarArchiveOutputStream)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)2 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)2 BDDMockito.given (org.mockito.BDDMockito.given)2 ImageReference (org.springframework.boot.buildpack.platform.docker.type.ImageReference)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1