Search in sources :

Example 1 with AssemblyFile

use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.

the class AssemblyManagerCreateDockerTarArchiveTest method withDockerfileInBaseDirectoryAndAssemblyFile.

@Test
public void withDockerfileInBaseDirectoryAndAssemblyFile() throws IOException {
    // Given
    final File dockerFile = new File(baseDirectory, "Dockerfile");
    writeLineToFile(dockerFile, "FROM busybox");
    final File assemblyFile = temporaryFolder.newFile("extra-file-1.txt");
    writeLineToFile(assemblyFile, "HELLO");
    AssemblyConfiguration assemblyConfig = AssemblyConfiguration.builder().inline(Assembly.builder().file(AssemblyFile.builder().source(assemblyFile).outputDirectory(new File(".")).build()).build()).build();
    final JKubeConfiguration configuration = createJKubeConfiguration();
    final BuildConfiguration jKubeBuildConfiguration = BuildConfiguration.builder().dockerFileFile(dockerFile).dockerFile(dockerFile.getPath()).assembly(assemblyConfig).build();
    // When
    final File dockerArchiveFile = assemblyManager.createDockerTarArchive("dockerfile-and-assembly-file", configuration, jKubeBuildConfiguration, prefixedLogger, null);
    // Then
    assertTargetHasDockerDirectories("dockerfile-and-assembly-file");
    ArchiveAssertions.assertThat(dockerArchiveFile).isFile().hasName("docker-build.tar").hasSameContentAsDirectory(getExpectedDirectory("with-dockerfile-in-base-directory-and-assembly-file"));
    assertDockerFile("dockerfile-and-assembly-file").hasContent("FROM busybox\n");
    assertBuildDirectoryFileTree("dockerfile-and-assembly-file").containsExactlyInAnyOrder("Dockerfile", "maven", "maven/Dockerfile", "maven/test-0.1.0.jar", "maven/extra-file-1.txt", "maven/target", "maven/target/test-0.1.0.jar");
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File) Test(org.junit.Test)

Example 2 with AssemblyFile

use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.

the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryWithAbsoluteDirectoryShouldReturnSameWindows.

@Test
public void getAssemblyFileOutputDirectoryWithAbsoluteDirectoryShouldReturnSameWindows() throws IOException {
    // Given
    assumeTrue(isWindows());
    final AssemblyFile af = AssemblyFile.builder().outputDirectory(new File("C:\\")).build();
    final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
    // When
    final File result = getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
    // Then
    assertEquals("C:\\", result.getAbsolutePath());
}
Also used : AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) Test(org.junit.Test)

Example 3 with AssemblyFile

use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.

the class AssemblyFileUtilsTest method resolveSourceFileAbsoluteFileShouldReturnSameWindows.

@Test
public void resolveSourceFileAbsoluteFileShouldReturnSameWindows() throws IOException {
    // Given
    assumeTrue(isWindows());
    final File baseDirectory = temporaryFolder.newFolder("base");
    final AssemblyFile af = AssemblyFile.builder().source(new File("C:\\")).build();
    // When
    final File result = AssemblyFileUtils.resolveSourceFile(baseDirectory, af);
    // Then
    assertEquals("C:\\", result.getAbsolutePath());
}
Also used : AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) Test(org.junit.Test)

Example 4 with AssemblyFile

use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.

the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryRequired.

@Test
public void getAssemblyFileOutputDirectoryRequired() throws IOException {
    // Given
    final AssemblyFile af = AssemblyFile.builder().build();
    final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
    // When
    final NullPointerException result = assertThrows(NullPointerException.class, () -> {
        getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
        fail("Should fail as output directory should not be null");
    });
    // Then
    assertEquals("Assembly Configuration output dir is required", result.getMessage());
}
Also used : AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) Test(org.junit.Test)

Example 5 with AssemblyFile

use of org.eclipse.jkube.kit.common.AssemblyFile in project jkube by eclipse.

the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryWithRelativeDirectoryShouldReturnComputedPath.

@Test
public void getAssemblyFileOutputDirectoryWithRelativeDirectoryShouldReturnComputedPath() throws IOException {
    // Given
    final AssemblyFile af = AssemblyFile.builder().outputDirectory(new File("target")).build();
    final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("/project").build();
    // When
    final File result = getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
    // Then
    final String expectedPath = outputDirectoryForRelativePaths.toPath().resolve("project").resolve("target").toAbsolutePath().toString();
    assertEquals(expectedPath, result.getAbsolutePath());
}
Also used : AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) Test(org.junit.Test)

Aggregations

AssemblyFile (org.eclipse.jkube.kit.common.AssemblyFile)13 File (java.io.File)12 Test (org.junit.Test)11 Assembly (org.eclipse.jkube.kit.common.Assembly)6 AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)6 Expectations (mockit.Expectations)1 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)1 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)1 AssemblyFileUtils.resolveSourceFile (org.eclipse.jkube.kit.common.archive.AssemblyFileUtils.resolveSourceFile)1 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)1