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