Search in sources :

Example 16 with AssemblyFileEntry

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method wildcardIncludeAndExcludeAcrossDirectories.

@Test
public void wildcardIncludeAndExcludeAcrossDirectories() throws IOException {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).include("**.*").exclude("**.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/3.other", "source-directory/one", "source-directory/one/3.other", "source-directory/two", "source-directory/two/3.other", "source-directory/three", "source-directory/three/3.other");
}
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 AssemblyFileEntry

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

the class AssemblyFileSetUtilsTest method calculateFilePermissionsDirectoryWithDirectoryMode.

@Test
public void calculateFilePermissionsDirectoryWithDirectoryMode() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directoryMode("040777").build();
    final File sourceDirectory = temp.newFolder("source-directory");
    final File sourceSubdirectory = new File(sourceDirectory, "subdirectory");
    FileUtils.forceMkdir(sourceSubdirectory);
    final File sourceFile = new File(sourceDirectory, "file.txt");
    assertThat(sourceFile.createNewFile()).isTrue();
    final File aDirectory = temp.newFolder("just-a-directory");
    final File aSubdirectory = new File(aDirectory, "subdirectory");
    FileUtils.forceMkdir(aSubdirectory);
    final File aFile = new File(aDirectory, "file.txt");
    assertThat(aFile.createNewFile()).isTrue();
    // When
    final List<AssemblyFileEntry> result = calculateFilePermissions(sourceDirectory, aDirectory, afs);
    // Then
    assertThat(result).hasSize(3).containsExactlyInAnyOrder(new AssemblyFileEntry(sourceDirectory, aDirectory, "040777"), new AssemblyFileEntry(sourceSubdirectory, aSubdirectory, "040777"), new AssemblyFileEntry(sourceFile, aFile, "0644"));
}
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 18 with AssemblyFileEntry

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

the class AssemblyFileSetUtilsTest method calculateFilePermissionsDirectoryAndNestedDirectoryAndFileWithDirectoryAndFileMode.

@Test
public void calculateFilePermissionsDirectoryAndNestedDirectoryAndFileWithDirectoryAndFileMode() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directoryMode("040755").fileMode("0755").build();
    final File sourceDirectory = temp.newFolder("source-directory");
    final File sourceSubdirectory = new File(sourceDirectory, "subdirectory");
    FileUtils.forceMkdir(sourceSubdirectory);
    final File sourceFile = new File(sourceDirectory, "file.txt");
    assertThat(sourceFile.createNewFile()).isTrue();
    final File aDirectory = temp.newFolder("just-a-directory");
    final File aSubdirectory = new File(aDirectory, "subdirectory");
    FileUtils.forceMkdir(aSubdirectory);
    final File aFile = new File(aDirectory, "file.txt");
    assertThat(aFile.createNewFile()).isTrue();
    // When
    final List<AssemblyFileEntry> result = calculateFilePermissions(sourceDirectory, aDirectory, afs);
    // Then
    assertThat(result).hasSize(3).containsExactlyInAnyOrder(new AssemblyFileEntry(sourceDirectory, aDirectory, "040755"), new AssemblyFileEntry(sourceSubdirectory, aSubdirectory, "040755"), new AssemblyFileEntry(sourceFile, aFile, "0755"));
}
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 19 with AssemblyFileEntry

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

the class AssemblyFileSetUtilsTest method calculateFilePermissionsFileWithNoFileMode.

@Test
public void calculateFilePermissionsFileWithNoFileMode() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().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, "0644"));
}
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 20 with AssemblyFileEntry

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

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