Search in sources :

Example 21 with Assembly

use of org.eclipse.jkube.kit.common.Assembly 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 22 with Assembly

use of org.eclipse.jkube.kit.common.Assembly 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 23 with Assembly

use of org.eclipse.jkube.kit.common.Assembly 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)

Example 24 with Assembly

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

the class AssemblyConfigurationUtilsTest method getJKubeAssemblyFilesNullFilesShouldReturnEmptyList.

@Test
public void getJKubeAssemblyFilesNullFilesShouldReturnEmptyList() {
    // Given
    final Assembly assembly = new Assembly();
    // When
    final List<AssemblyFile> result = getJKubeAssemblyFiles(assembly);
    // Then
    assertThat(result).isNotNull().isEmpty();
}
Also used : Assembly(org.eclipse.jkube.kit.common.Assembly) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) Test(org.junit.Test)

Example 25 with Assembly

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

the class AssemblyConfigurationUtilsTest method createDockerFileBuilder_withAssemblyAndFilesInSingleLayer_shouldReturnTransformedContent.

@Test
public void createDockerFileBuilder_withAssemblyAndFilesInSingleLayer_shouldReturnTransformedContent() {
    // Given
    final BuildConfiguration buildConfig = BuildConfiguration.builder().user("1000").maintainer("Alex").build();
    final AssemblyConfiguration assemblyConfiguration = AssemblyConfiguration.builder().targetDir("/deployments").layer(Assembly.builder().id("layer-with-id").build()).layer(new Assembly()).build();
    final Map<Assembly, List<AssemblyFileEntry>> layers = assemblyConfiguration.getLayers().stream().collect(Collectors.toMap(Function.identity(), a -> Collections.singletonList(new AssemblyFileEntry(new File(""), new File(""), null))));
    layers.put(new Assembly(), Collections.emptyList());
    // When
    final String result = createDockerFileBuilder(buildConfig, assemblyConfiguration, layers).content();
    // Then
    assertThat(result).isEqualTo("FROM busybox\n" + "MAINTAINER Alex\n" + "COPY /layer-with-id/deployments /deployments/\n" + "VOLUME [\"/deployments\"]\n" + "USER 1000\n");
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) Expectations(mockit.Expectations) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) Test(org.junit.Test) AssemblyConfigurationUtils.createDockerFileBuilder(org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.createDockerFileBuilder) AssemblyConfigurationUtils.getJKubeAssemblyFileSets(org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getJKubeAssemblyFileSets) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) File(java.io.File) AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyConfigurationUtils.getAssemblyConfigurationOrCreateDefault(org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getAssemblyConfigurationOrCreateDefault) List(java.util.List) AssemblyConfigurationUtils.getJKubeAssemblyFiles(org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getJKubeAssemblyFiles) Assembly(org.eclipse.jkube.kit.common.Assembly) Map(java.util.Map) Arguments(org.eclipse.jkube.kit.config.image.build.Arguments) Injectable(mockit.Injectable) Collections(java.util.Collections) AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) List(java.util.List) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Aggregations

Assembly (org.eclipse.jkube.kit.common.Assembly)36 AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)31 File (java.io.File)29 Test (org.junit.Test)29 AssemblyFileSet (org.eclipse.jkube.kit.common.AssemblyFileSet)22 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)21 AssemblyFileSetUtils.processAssemblyFileSet (org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet)18 AssemblyFile (org.eclipse.jkube.kit.common.AssemblyFile)12 List (java.util.List)9 Map (java.util.Map)7 IOException (java.io.IOException)6 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)6 ArrayList (java.util.ArrayList)5 Collections (java.util.Collections)5 Collectors (java.util.stream.Collectors)5 Nonnull (javax.annotation.Nonnull)5 AssemblyConfigurationUtils.createDockerFileBuilder (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.createDockerFileBuilder)4 AssemblyConfigurationUtils.getAssemblyConfigurationOrCreateDefault (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getAssemblyConfigurationOrCreateDefault)4 AssemblyConfigurationUtils.getJKubeAssemblyFileSets (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getJKubeAssemblyFileSets)4 AssemblyConfigurationUtils.getJKubeAssemblyFiles (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getJKubeAssemblyFiles)4