Search in sources :

Example 31 with AssemblyConfiguration

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

the class BuildUtilTest method extractBaseFromConfiguration_withBuildConfigurationAssemblyAndNoFrom_shouldReturnNull.

@Test
public void extractBaseFromConfiguration_withBuildConfigurationAssemblyAndNoFrom_shouldReturnNull() {
    // Given
    final BuildConfiguration buildConfiguration = BuildConfiguration.builder().assembly(new AssemblyConfiguration()).build();
    // When
    final String result = extractBaseFromConfiguration(buildConfiguration);
    // Then
    assertThat(result).isNull();
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) Test(org.junit.Test)

Example 32 with AssemblyConfiguration

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

the class AssemblyConfigurationUtils method getAssemblyConfigurationOrCreateDefault.

@Nonnull
static AssemblyConfiguration getAssemblyConfigurationOrCreateDefault(@Nullable BuildConfiguration buildConfiguration) {
    final AssemblyConfiguration ac = Optional.ofNullable(buildConfiguration).map(BuildConfiguration::getAssembly).orElse(AssemblyConfiguration.builder().build());
    final AssemblyConfiguration.AssemblyConfigurationBuilder builder = ac.toBuilder();
    final String name;
    if (StringUtils.isBlank(ac.getName())) {
        builder.name(DEFAULT_NAME);
        name = DEFAULT_NAME;
    } else {
        name = ac.getName();
    }
    if (StringUtils.isBlank(ac.getTargetDir())) {
        builder.targetDir(LINUX_FILE_SEPARATOR.concat(name));
    }
    return builder.build();
}
Also used : AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) Nonnull(javax.annotation.Nonnull)

Example 33 with AssemblyConfiguration

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

the class WebAppGenerator method createAssembly.

private AssemblyConfiguration createAssembly(AppServerHandler handler) {
    final File sourceFile = Objects.requireNonNull(JKubeProjectUtil.getFinalOutputArtifact(getProject()), "Final output artifact file was not detected");
    final String targetFilename;
    final String extension = FilenameUtils.getExtension(sourceFile.getName());
    final String path = getConfig(Config.PATH);
    if (path.equals("/") || isBlank(path)) {
        targetFilename = String.format("ROOT.%s", extension);
    } else {
        targetFilename = String.format("%s.%s", path.replaceAll("[\\\\/]", ""), extension);
    }
    final AssemblyConfiguration.AssemblyConfigurationBuilder builder = AssemblyConfiguration.builder();
    builder.name(handler.getAssemblyName()).targetDir(getDeploymentDir(handler)).excludeFinalOutputArtifact(true).inline(Assembly.builder().file(AssemblyFile.builder().source(sourceFile).destName(targetFilename).outputDirectory(new File(".")).build()).build());
    String user = getUser(handler);
    if (user != null) {
        builder.user(user);
    }
    return builder.build();
}
Also used : AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File)

Example 34 with AssemblyConfiguration

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method assemblyConfigurationHasNoTargetDir_shouldThrowException.

@Test
public void assemblyConfigurationHasNoTargetDir_shouldThrowException() {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
    // When
    final NullPointerException result = Assert.assertThrows(NullPointerException.class, () -> processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac));
    // Then
    assertThat(result).hasMessage("Assembly Configuration target dir is required");
}
Also used : AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) AssemblyFileSetUtils.processAssemblyFileSet(org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet) Assembly(org.eclipse.jkube.kit.common.Assembly) Test(org.junit.Test)

Example 35 with AssemblyConfiguration

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

the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method fileSetDirectoryAndOutputDirectoryResolvingToSelf.

/**
 * Has AssemblyFileSet with directory and outputDirectory relative path resolving to self.
 * Has AssemblyConfiguration targetDir.
 *
 * Should copy <b>contents</b> of AssemblyFileSet#directory to the outputDirectory in a subdirectory named as the
 * AssemblyConfiguration#targetDir.
 */
@Test
public void fileSetDirectoryAndOutputDirectoryResolvingToSelf() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).outputDirectory(new File(".")).build();
    final Assembly layer = new Assembly();
    final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("NotImportant").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("1.txt", "3.other", "37", "one", "one/1.txt", "one/3.other", "one/37", "two", "two/1.txt", "two/3.other", "two/37", "three", "three/1.txt", "three/3.other", "three/37").doesNotContainSequence("source-directory");
}
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)

Aggregations

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