use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class AssemblyManagerCreateDockerTarArchiveTest method withDockerfileInBaseDirectory.
@Test
public void withDockerfileInBaseDirectory() throws IOException {
// Given
final File dockerFile = new File(baseDirectory, "Dockerfile");
writeLineToFile(dockerFile, "FROM openjdk:jre");
final JKubeConfiguration configuration = createJKubeConfiguration();
final BuildConfiguration jKubeBuildConfiguration = BuildConfiguration.builder().dockerFileFile(dockerFile).dockerFile(dockerFile.getPath()).build();
// When
File dockerArchiveFile = assemblyManager.createDockerTarArchive("test-image", configuration, jKubeBuildConfiguration, prefixedLogger, null);
// Then
assertTargetHasDockerDirectories("test-image");
ArchiveAssertions.assertThat(dockerArchiveFile).isFile().hasName("docker-build.tar").hasSameContentAsDirectory(getExpectedDirectory("with-dockerfile-in-base-directory"));
assertDockerFile("test-image").hasContent("FROM openjdk:jre\n");
assertBuildDirectoryFileTree("test-image").containsExactlyInAnyOrder("Dockerfile", "maven", "maven/Dockerfile", "maven/test-0.1.0.jar", "maven/target", "maven/target/test-0.1.0.jar");
}
use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class AssemblyManagerCreateDockerTarArchiveTest method withDockerfileInBaseDirectoryAndDockerignore.
@Test
public void withDockerfileInBaseDirectoryAndDockerignore() throws IOException {
// Given
final File dockerFile = new File(baseDirectory, "Dockerfile");
writeLineToFile(dockerFile, "FROM openjdk:jre");
writeLineToFile(new File(baseDirectory, ".jkube-dockerignore"), "**/*.txt\ntarget/ill-be-ignored-too");
writeLineToFile(new File(targetDirectory, "ill-be-ignored.txt"), "Hello");
writeLineToFile(new File(targetDirectory, "ill-be-ignored-too"), "Hello");
writeLineToFile(new File(targetDirectory, "i-wont-be-ignored"), "Hello");
final JKubeConfiguration configuration = createJKubeConfiguration();
final BuildConfiguration jKubeBuildConfiguration = BuildConfiguration.builder().dockerFileFile(dockerFile).dockerFile(dockerFile.getPath()).build();
// When
File dockerArchiveFile = assemblyManager.createDockerTarArchive("test-image", configuration, jKubeBuildConfiguration, prefixedLogger, null);
// Then
assertTargetHasDockerDirectories("test-image");
ArchiveAssertions.assertThat(dockerArchiveFile).isFile().hasName("docker-build.tar").hasSameContentAsDirectory(getExpectedDirectory("with-dockerfile-in-base-directory-and-dockerignore"));
assertDockerFile("test-image").hasContent("FROM openjdk:jre\n");
assertBuildDirectoryFileTree("test-image").containsExactlyInAnyOrder("Dockerfile", "maven", "maven/Dockerfile", "maven/test-0.1.0.jar", "maven/target", "maven/target/test-0.1.0.jar", "maven/target/i-wont-be-ignored");
}
use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class AssemblyManagerCreateDockerTarArchiveTest method withoutDockerfileAndFinalCustomizer.
@Test
public void withoutDockerfileAndFinalCustomizer() throws IOException {
// Given
final JKubeConfiguration jKubeConfiguration = createJKubeConfiguration();
final BuildConfiguration buildConfiguration = BuildConfiguration.builder().build();
final AtomicBoolean customized = new AtomicBoolean(false);
final ArchiverCustomizer finalCustomizer = ac -> {
customized.set(true);
return ac;
};
// When
File dockerArchiveFile = assemblyManager.createDockerTarArchive("no-docker-file-and-customizer", jKubeConfiguration, buildConfiguration, prefixedLogger, finalCustomizer);
// Then
assertTargetHasDockerDirectories("no-docker-file-and-customizer");
ArchiveAssertions.assertThat(dockerArchiveFile).isFile().hasName("docker-build.tar").hasSameContentAsDirectory(getExpectedDirectory("without-dockerfile-and-final-customizer"));
assertDockerFile("no-docker-file-and-customizer").hasContent(DOCKERFILE_DEFAULT_FALLBACK_CONTENT);
assertBuildDirectoryFileTree("no-docker-file-and-customizer").containsExactlyInAnyOrder("Dockerfile", "jkube-generated-layer-final-artifact", "jkube-generated-layer-final-artifact/maven", "jkube-generated-layer-final-artifact/maven/test-0.1.0.jar", "maven");
assertThat(customized).isTrue();
}
use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class AssemblyManagerCreateDockerTarArchiveTest method createChangedFilesArchive.
@Test
public void createChangedFilesArchive() throws IOException {
// Given
final JKubeConfiguration jKubeConfiguration = createJKubeConfiguration();
final List<AssemblyFileEntry> entries = new ArrayList<>();
final File assemblyDirectory = temporaryFolder.getRoot().toPath().resolve("target").resolve("docker").toFile();
entries.add(AssemblyFileEntry.builder().source(temporaryFolder.getRoot().toPath().resolve("target").resolve("test-0.1.0.jar").toFile()).dest(temporaryFolder.getRoot().toPath().resolve("target").resolve("docker").resolve("test-0.1.0.jar").toFile()).fileMode("0655").build());
// When
final File result = assemblyManager.createChangedFilesArchive(entries, assemblyDirectory, "image-name", jKubeConfiguration);
// Then
ArchiveAssertions.assertThat(result).isFile().hasName("changed-files.tar").hasSameContentAsDirectory(getExpectedDirectory("changed-files.tar"));
}
use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class AssemblyManagerCreateDockerTarArchiveTest method withDockerfileInBaseDirectoryAndDockerexclude.
@Test
public void withDockerfileInBaseDirectoryAndDockerexclude() throws IOException {
// Given
final File dockerFile = new File(baseDirectory, "Dockerfile");
writeLineToFile(dockerFile, "FROM openjdk:jre");
writeLineToFile(new File(baseDirectory, ".jkube-dockerexclude"), "**/*.txt");
writeLineToFile(new File(targetDirectory, "ill-wont-be-included.txt"), "Hello");
writeLineToFile(new File(targetDirectory, "ill-be-included"), "Hello");
final JKubeConfiguration configuration = createJKubeConfiguration();
final BuildConfiguration jKubeBuildConfiguration = BuildConfiguration.builder().dockerFileFile(dockerFile).dockerFile(dockerFile.getPath()).build();
// When
final File dockerArchiveFile = assemblyManager.createDockerTarArchive("test-image", configuration, jKubeBuildConfiguration, prefixedLogger, null);
// Then
assertTargetHasDockerDirectories("test-image");
ArchiveAssertions.assertThat(dockerArchiveFile).isFile().hasName("docker-build.tar").hasSameContentAsDirectory(getExpectedDirectory("with-dockerfile-in-base-directory-and-dockerexclude"));
assertDockerFile("test-image").hasContent("FROM openjdk:jre\n");
assertBuildDirectoryFileTree("test-image").containsExactlyInAnyOrder("Dockerfile", "maven", "maven/Dockerfile", "maven/test-0.1.0.jar", "maven/target", "maven/target/test-0.1.0.jar", "maven/target/ill-be-included");
}
Aggregations