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