use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class PodTemplateHandlerTest method getPodTemplate_withRestartPolicyAndResourceConfig_shouldGeneratePodTemplateWithConfiguredRestartPolicy.
@Test
public void getPodTemplate_withRestartPolicyAndResourceConfig_shouldGeneratePodTemplateWithConfiguredRestartPolicy() {
// Given
ResourceConfig config = ResourceConfig.builder().build();
// When
PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, "Always", images);
// Then
assertThat(podTemplateSpec).hasFieldOrPropertyWithValue("spec.restartPolicy", "Always");
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class PodTemplateHandlerTest method podWithoutVolumeTemplateHandlerTest.
@Test
public void podWithoutVolumeTemplateHandlerTest() {
// Pod without Volume Config
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").serviceAccount("test-account").replicas(5).build();
PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, null, images);
// Assertion
assertEquals("test-account", podTemplateSpec.getSpec().getServiceAccountName());
assertTrue(podTemplateSpec.getSpec().getVolumes().isEmpty());
assertNotNull(podTemplateSpec.getSpec().getContainers());
assertEquals("test-app", podTemplateSpec.getSpec().getContainers().get(0).getName());
assertEquals("docker.io/test:latest", podTemplateSpec.getSpec().getContainers().get(0).getImage());
assertEquals("IfNotPresent", podTemplateSpec.getSpec().getContainers().get(0).getImagePullPolicy());
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class PodTemplateHandlerTest method podWithVolumeTemplateHandlerTest.
@Test
public void podWithVolumeTemplateHandlerTest() {
// Config with Volume Config and ServiceAccount
// valid type
VolumeConfig volumeConfig1 = VolumeConfig.builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
volumes1.clear();
volumes1.add(volumeConfig1);
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, null, images);
// Assertion
assertEquals("test-account", podTemplateSpec.getSpec().getServiceAccountName());
assertFalse(podTemplateSpec.getSpec().getVolumes().isEmpty());
assertEquals("test", podTemplateSpec.getSpec().getVolumes().get(0).getName());
assertEquals("/test/path", podTemplateSpec.getSpec().getVolumes().get(0).getHostPath().getPath());
assertNotNull(podTemplateSpec.getSpec().getContainers());
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class PodTemplateHandlerTest method podWithInvalidVolumeTypeTemplateHandlerTest.
@Test
public void podWithInvalidVolumeTypeTemplateHandlerTest() {
// invalid type
VolumeConfig volumeConfig1 = VolumeConfig.builder().name("test").mounts(mounts).type("hoStPath").path("/test/path").build();
volumes1.clear();
volumes1.add(volumeConfig1);
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, null, images);
// Assertion
assertEquals("test-account", podTemplateSpec.getSpec().getServiceAccountName());
assertTrue(podTemplateSpec.getSpec().getVolumes().isEmpty());
assertNotNull(podTemplateSpec.getSpec().getContainers());
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class AbstractDockerMojo method buildServiceConfigBuilder.
protected BuildServiceConfig.BuildServiceConfigBuilder buildServiceConfigBuilder() {
return BuildServiceConfig.builder().buildRecreateMode(BuildRecreateMode.fromParameter(buildRecreate)).jKubeBuildStrategy(getJKubeBuildStrategy()).forcePull(forcePull).imagePullManager(ImagePullManager.createImagePullManager(imagePullPolicy, autoPull, project.getProperties())).buildDirectory(project.getBuild().getDirectory()).resourceConfig(resources).resourceDir(resourceDir).attacher((classifier, destFile) -> {
if (destFile.exists()) {
projectHelper.attachArtifact(project, "yml", classifier, destFile);
}
}).enricherTask(builder -> {
DefaultEnricherManager enricherManager = new DefaultEnricherManager(getEnricherContext(), useProjectClasspath ? javaProject.getCompileClassPathElements() : Collections.emptyList());
enricherManager.enrich(PlatformMode.kubernetes, builder);
enricherManager.enrich(PlatformMode.openshift, builder);
});
}
Aggregations