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"));
}
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;
}
Aggregations