Search in sources :

Example 41 with BuildConfiguration

use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.

the class PropertyConfigHandlerTest method testRunCommandsFromPropertiesAndConfig.

@Test
public void testRunCommandsFromPropertiesAndConfig() {
    imageConfiguration = ImageConfiguration.builder().external(new HashMap<>()).build(BuildConfiguration.builder().runCmds(Arrays.asList("some", "ignored", "value")).addCacheFrom("foo/bar:latest").build()).build();
    makeExternalConfigUse(PropertyMode.Override);
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "base", "docker.name", "demo", "docker.run.1", "propconf", "docker.run.2", "withrun", "docker.run.3", "used"));
    assertEquals(1, configs.size());
    BuildConfiguration buildConfig = configs.get(0).getBuildConfiguration();
    String[] runCommands = new ArrayList<>(buildConfig.getRunCmds()).toArray(new String[buildConfig.getRunCmds().size()]);
    assertArrayEquals(new String[] { "propconf", "withrun", "used" }, runCommands);
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) HashMap(java.util.HashMap) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) Test(org.junit.Test)

Example 42 with BuildConfiguration

use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.

the class PropertyConfigHandlerTest method testRunCommandsFromConfigAndProperties.

@Test
public void testRunCommandsFromConfigAndProperties() {
    imageConfiguration = ImageConfiguration.builder().external(externalMode(PropertyMode.Fallback)).build(BuildConfiguration.builder().runCmds(Arrays.asList("some", "configured", "value")).addCacheFrom("foo/bar:latest").build()).build();
    List<ImageConfiguration> configs = resolveImage(imageConfiguration, props("docker.from", "base", "docker.name", "demo", "docker.run.1", "this", "docker.run.2", "is", "docker.run.3", "ignored"));
    assertEquals(1, configs.size());
    BuildConfiguration buildConfig = configs.get(0).getBuildConfiguration();
    String[] runCommands = new ArrayList<>(buildConfig.getRunCmds()).toArray(new String[buildConfig.getRunCmds().size()]);
    assertArrayEquals(new String[] { "some", "configured", "value" }, runCommands);
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) Test(org.junit.Test)

Example 43 with BuildConfiguration

use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.

the class PropertyConfigHandler method resolve.

@Override
public List<ImageConfiguration> resolve(ImageConfiguration fromConfig, JavaProject project) {
    Map<String, String> externalConfig = fromConfig.getExternalConfig();
    String prefix = getPrefix(externalConfig);
    Properties properties = JKubeProjectUtil.getPropertiesWithSystemOverrides(project);
    PropertyMode propertyMode = getMode(externalConfig);
    ValueProvider valueProvider = new ValueProvider(prefix, properties, propertyMode);
    RunImageConfiguration run = extractRunConfiguration(fromConfig, valueProvider);
    BuildConfiguration build = extractBuildConfiguration(fromConfig, valueProvider, project);
    WatchImageConfiguration watch = extractWatchConfig(fromConfig, valueProvider);
    String name = valueProvider.getString(NAME, fromConfig.getName());
    String alias = valueProvider.getString(ALIAS, fromConfig.getAlias());
    if (name == null) {
        throw new IllegalArgumentException(String.format("Mandatory property [%s] is not defined", NAME));
    }
    return Collections.singletonList(ImageConfiguration.builder().name(name).alias(alias).run(run).build(build).watch(watch).build());
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) WatchImageConfiguration(org.eclipse.jkube.kit.config.image.WatchImageConfiguration) Properties(java.util.Properties) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration)

Example 44 with BuildConfiguration

use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.

the class RegistryServiceTest method pullImageWithPolicy_pullPolicyAlwaysAndBuildConfiguration_shouldPull.

@Test
public void pullImageWithPolicy_pullPolicyAlwaysAndBuildConfiguration_shouldPull() throws Exception {
    // Given
    final BuildConfiguration bc = BuildConfiguration.builder().createImageOptions(Collections.singletonMap("platform", "linux/amd64")).build();
    final ArgumentCaptor<CreateImageOptions> createImageOptionsCaptor = ArgumentCaptor.forClass(CreateImageOptions.class);
    // When
    registryService.pullImageWithPolicy("quay.io/organization/image:version", ImagePullManager.createImagePullManager("Always", "", new Properties()), RegistryConfig.builder().settings(Collections.emptyList()).build(), bc);
    // Then
    verify(dockerAccess, times(1)).pullImage(eq("quay.io/organization/image:version"), any(), eq("quay.io"), createImageOptionsCaptor.capture());
    assertThat(createImageOptionsCaptor.getValue().getOptions()).containsExactlyInAnyOrderEntriesOf(new CreateImageOptions().fromImage("quay.io/organization/image").tag("version").platform("linux/amd64").getOptions());
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) CreateImageOptions(org.eclipse.jkube.kit.build.service.docker.access.CreateImageOptions) Properties(java.util.Properties) Test(org.junit.Test)

Example 45 with BuildConfiguration

use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.

the class RegistryServiceTest method pullImageWithPolicy_pullPolicyAlways_shouldPull.

@Test
public void pullImageWithPolicy_pullPolicyAlways_shouldPull() throws Exception {
    // Given
    final ArgumentCaptor<CreateImageOptions> createImageOptionsCaptor = ArgumentCaptor.forClass(CreateImageOptions.class);
    // When
    registryService.pullImageWithPolicy("quay.io/organization/image:version", ImagePullManager.createImagePullManager("Always", "", new Properties()), RegistryConfig.builder().settings(Collections.emptyList()).build(), new BuildConfiguration());
    // Then
    verify(dockerAccess, times(1)).pullImage(eq("quay.io/organization/image:version"), any(), eq("quay.io"), createImageOptionsCaptor.capture());
    assertThat(createImageOptionsCaptor.getValue().getOptions()).containsExactlyInAnyOrderEntriesOf(new CreateImageOptions().fromImage("quay.io/organization/image").tag("version").getOptions());
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) CreateImageOptions(org.eclipse.jkube.kit.build.service.docker.access.CreateImageOptions) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)58 Test (org.junit.Test)39 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)24 File (java.io.File)23 Properties (java.util.Properties)11 AssemblyFile (org.eclipse.jkube.kit.common.AssemblyFile)10 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)10 RunImageConfiguration (org.eclipse.jkube.kit.config.image.RunImageConfiguration)8 GroupArtifactVersion (org.eclipse.jkube.kit.config.resource.GroupArtifactVersion)8 Before (org.junit.Before)8 AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)7 ArrayList (java.util.ArrayList)6 Expectations (mockit.Expectations)5 VolumeConfig (org.eclipse.jkube.kit.config.resource.VolumeConfig)5 Verifications (mockit.Verifications)4 List (java.util.List)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assembly (org.eclipse.jkube.kit.common.Assembly)3 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)3 JavaProject (org.eclipse.jkube.kit.common.JavaProject)3