Search in sources :

Example 31 with AssemblyFileEntry

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

the class AssemblyFileSetUtilsTest method calculateFilePermissionsDirectoryWithNoDirectoryMode.

@Test
public void calculateFilePermissionsDirectoryWithNoDirectoryMode() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().build();
    final File sourceDirectory = temp.newFile("source-directory");
    final File aDirectory = temp.newFolder("just-a-directory");
    // When
    final List<AssemblyFileEntry> result = calculateFilePermissions(sourceDirectory, aDirectory, afs);
    // Then
    assertThat(result).hasSize(1).contains(new AssemblyFileEntry(sourceDirectory, aDirectory, "040755"));
}
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 32 with AssemblyFileEntry

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

the class AssemblyFileSetUtils method calculateFilePermissions.

@Nonnull
public static List<AssemblyFileEntry> calculateFilePermissions(File source, File dest, AssemblyFileSet assemblyFileSet) {
    final List<AssemblyFileEntry> ret = new ArrayList<>();
    final String fileMode = Optional.ofNullable(assemblyFileSet.getFileMode()).orElse(FILE_MODE_DEFAULT);
    if (dest.isDirectory()) {
        final String directoryMode = Optional.ofNullable(assemblyFileSet.getDirectoryMode()).orElse(DIRECTORY_MODE_DEFAULT);
        ret.add(new AssemblyFileEntry(source, dest, directoryMode));
        FileUtil.listFilesAndDirsRecursivelyInDirectory(dest).forEach(f -> {
            final File s = source.toPath().resolve(dest.toPath().relativize(f.toPath())).toFile();
            if (f.isDirectory()) {
                ret.add(new AssemblyFileEntry(s, f, directoryMode));
            } else if (f.isFile()) {
                ret.add(new AssemblyFileEntry(s, f, fileMode));
            }
        });
    } else if (dest.isFile()) {
        ret.add(new AssemblyFileEntry(source, dest, fileMode));
    }
    return ret;
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) ArrayList(java.util.ArrayList) File(java.io.File) Nonnull(javax.annotation.Nonnull)

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