Search in sources :

Example 16 with AssemblyConfiguration

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method wildcardInclude.

@Test
public void wildcardInclude() throws IOException {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).include("*.txt").fileMode("0766").build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("deployments").targetDir("/deployments").build();
    // When
    final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
    // Then
    assertThat(result).hasSize(1);
    FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/1.txt");
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 17 with AssemblyConfiguration

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method fileSetDirectoryAndAbsoluteOutputDirectory.

/**
 * Has AssemblyFileSet directory and absolute outputDirectory.
 * Has AssemblyConfiguration targetDir.
 *
 * Should copy contents of AssemblyFileSet#directory to the absoluteOutputDirectory.
 */
@Test
public void fileSetDirectoryAndAbsoluteOutputDirectory() throws Exception {
    // Given
    final File absoluteOutputDirectory = temp.newFolder("absolute-output");
    assertThat(absoluteOutputDirectory).isEmptyDirectory();
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).outputDirectory(absoluteOutputDirectory).build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("/deployments").build();
    // When
    final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
    // Then
    assertThat(result).hasSize(16);
    FileAssertions.assertThat(new File(outputDirectory, "deployments")).doesNotExist();
    FileAssertions.assertThat(absoluteOutputDirectory).exists().fileTree().containsExactlyInAnyOrder("1.txt", "3.other", "37", "one", "one/1.txt", "one/3.other", "one/37", "two", "two/1.txt", "two/3.other", "two/37", "three", "three/1.txt", "three/3.other", "three/37").doesNotContainSequence("source-directory");
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 18 with AssemblyConfiguration

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method hierarchicalIncludeInRelativeDirectory.

/**
 * AssemblyFileSet#directory, relative outputDirectory and includes for files in several hierarchic levels.
 * Has AssemblyConfiguration targetDir.
 *
 * Should copy contents of AssemblyFileSet#directory to the outputDirectory in a subdirectory named as the AssemblyConfiguration#targetDir.
 */
@Test
public void hierarchicalIncludeInRelativeDirectory() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).outputDirectory(new File("relative")).include("37").include("one/1.txt").include("three").build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("maven").build();
    // When
    final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
    // Then
    assertThat(result).hasSize(6);
    FileAssertions.assertThat(new File(outputDirectory, "maven")).exists().fileTree().containsExactlyInAnyOrder("relative", "relative/37", "relative/one", "relative/one/1.txt", "relative/three", "relative/three/1.txt", "relative/three/3.other", "relative/three/37");
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 19 with AssemblyConfiguration

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method wildcardIncludeAcrossDirectories.

@Test
public void wildcardIncludeAcrossDirectories() throws IOException {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).include("**.txt").fileMode("0766").build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("deployments").targetDir("/deployments").build();
    // When
    final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
    // Then
    assertThat(result).hasSize(4);
    FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/1.txt", "source-directory/one", "source-directory/one/1.txt", "source-directory/two", "source-directory/two/1.txt", "source-directory/three", "source-directory/three/1.txt");
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 20 with AssemblyConfiguration

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method withRelativeSourceAndDirectoryExcludes.

@Test
public void withRelativeSourceAndDirectoryExcludes() throws Exception {
    // Given
    final File quickstartDirectory = new File(sourceDirectory, "quickstarts/directory");
    FileUtils.forceMkdir(quickstartDirectory);
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(new File(quickstartDirectory, "../../")).outputDirectory(new File(".")).fileMode("0764").exclude("quickstarts{/**,}").exclude("three/**").build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("deployments").targetDir("/deployments").build();
    // When
    final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
    // Then
    assertThat(result).hasSize(13);
    FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("1.txt", "3.other", "37", "one", "one/1.txt", "one/3.other", "one/37", "two", "two/1.txt", "two/3.other", "two/37", "three");
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) File(java.io.File) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Aggregations

AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)41 Test (org.junit.Test)32 File (java.io.File)29 Assembly (org.eclipse.jkube.kit.common.Assembly)29 AssemblyFileSet (org.eclipse.jkube.kit.common.AssemblyFileSet)22 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)19 AssemblyFileSetUtils.processAssemblyFileSet (org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet)19 AssemblyFile (org.eclipse.jkube.kit.common.AssemblyFile)12 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)8 List (java.util.List)6 Expectations (mockit.Expectations)6 ArrayList (java.util.ArrayList)5 Collectors (java.util.stream.Collectors)5 Nonnull (javax.annotation.Nonnull)5 AssemblyConfigurationUtils.getJKubeAssemblyFiles (org.eclipse.jkube.kit.build.api.assembly.AssemblyConfigurationUtils.getJKubeAssemblyFiles)5 IOException (java.io.IOException)4 Map (java.util.Map)4 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