Search in sources :

Example 26 with AssemblyFileEntry

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method directoryExcludes.

@Test
public void directoryExcludes() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).fileMode("0764").exclude("one/**").exclude("one").exclude("two{/**,}").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(8);
    FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/1.txt", "source-directory/3.other", "source-directory/37", "source-directory/three", "source-directory/three/1.txt", "source-directory/three/3.other", "source-directory/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 27 with AssemblyFileEntry

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method minimumRequiredFields.

/**
 * Has AssemblyFileSet#directory and AssemblyConfiguration#targetDir options.
 *
 * Should copy the AssemblyFileSet#directory to the outputDirectory in a subdirectory named as the AssemblyConfiguration#targetDir.
 *
 * n.b. this is the only case where the source directory and not its contents is copied.
 */
@Test
public void minimumRequiredFields() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).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")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/1.txt", "source-directory/3.other", "source-directory/37", "source-directory/one", "source-directory/one/1.txt", "source-directory/one/3.other", "source-directory/one/37", "source-directory/two", "source-directory/two/1.txt", "source-directory/two/3.other", "source-directory/two/37", "source-directory/three", "source-directory/three/1.txt", "source-directory/three/3.other", "source-directory/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 28 with AssemblyFileEntry

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method hierarchicalInclude.

/**
 * Has AssemblyFileSet#directory 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 hierarchicalInclude() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).include("1.txt").include("one/1.txt").include("two").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(6);
    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/two/3.other", "source-directory/two/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 29 with AssemblyFileEntry

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

the class AssemblyFileSetUtilsTest method calculateFilePermissionsFileWithFileMode.

@Test
public void calculateFilePermissionsFileWithFileMode() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().fileMode("0777").build();
    final File sourceFile = temp.newFile("source-file.txt");
    final File aFile = temp.newFile("just-a-file.txt");
    // When
    final List<AssemblyFileEntry> result = calculateFilePermissions(sourceFile, aFile, afs);
    // Then
    assertThat(result).hasSize(1).contains(new AssemblyFileEntry(sourceFile, aFile, "0777"));
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) File(java.io.File) Test(org.junit.Test)

Example 30 with AssemblyFileEntry

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

the class AssemblyFileSetUtilsTest method calculateFilePermissionsDirectoryAndNestedDirectoryWithDirectoryAndFileMode.

@Test
public void calculateFilePermissionsDirectoryAndNestedDirectoryWithDirectoryAndFileMode() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directoryMode("040775").fileMode("0755").build();
    final File sourceDirectory = temp.newFolder("source-directory");
    final File sourceSubdirectory = new File(sourceDirectory, "subdirectory");
    FileUtils.forceMkdir(sourceSubdirectory);
    final File aDirectory = temp.newFolder("just-a-directory");
    final File aSubdirectory = new File(aDirectory, "subdirectory");
    FileUtils.forceMkdir(aSubdirectory);
    // When
    final List<AssemblyFileEntry> result = calculateFilePermissions(sourceDirectory, aDirectory, afs);
    // Then
    assertThat(result).hasSize(2).containsExactlyInAnyOrder(new AssemblyFileEntry(sourceDirectory, aDirectory, "040775"), new AssemblyFileEntry(sourceSubdirectory, aSubdirectory, "040775"));
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) File(java.io.File) Test(org.junit.Test)

Aggregations

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