use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class MavenIssueManagementEnricherTest method testMavenIssueManagementOnlySystem.
@Test
public void testMavenIssueManagementOnlySystem() {
final JavaProject project = JavaProject.builder().build();
project.setIssueManagementSystem("GitHub");
// Setup mock behaviour
new Expectations() {
{
{
context.getProject();
result = project;
}
}
};
MavenIssueManagementEnricher enricher = new MavenIssueManagementEnricher(context);
KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("foo").endMetadata().build());
enricher.create(PlatformMode.kubernetes, builder);
Map<String, String> scmAnnotations = builder.buildFirstItem().getMetadata().getAnnotations();
assertNotNull(scmAnnotations);
assertTrue(scmAnnotations.isEmpty());
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class MavenProjectEnricherTest method testGeneratedResources.
@Test
public void testGeneratedResources() {
ProjectLabelEnricher projectEnricher = new ProjectLabelEnricher(context);
KubernetesListBuilder builder = createListWithDeploymentConfig();
projectEnricher.enrich(PlatformMode.kubernetes, builder);
KubernetesList list = builder.build();
Map<String, String> labels = list.getItems().get(0).getMetadata().getLabels();
assertNotNull(labels);
assertEquals("groupId", labels.get("group"));
assertEquals("artifactId", labels.get("app"));
assertEquals("version", labels.get("version"));
assertNull(labels.get("project"));
builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().build());
projectEnricher.create(PlatformMode.kubernetes, builder);
Deployment deployment = (Deployment) builder.buildFirstItem();
Map<String, String> selectors = deployment.getSpec().getSelector().getMatchLabels();
assertEquals("groupId", selectors.get("group"));
assertEquals("artifactId", selectors.get("app"));
assertNull(selectors.get("version"));
assertNull(selectors.get("project"));
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class PodAnnotationEnricherTest method enrich_withDeployment_shouldAddAnnotationsToPodTemplateSpec.
@Test
public void enrich_withDeployment_shouldAddAnnotationsToPodTemplateSpec() {
// Given
klb.addToItems(new DeploymentBuilder().withMetadata(createResourceMetadata()).withNewSpec().withNewTemplate().withMetadata(createPodTemplateSpecMetadata()).endTemplate().endSpec());
// When
podAnnotationEnricher.enrich(PlatformMode.kubernetes, klb);
// Then
KubernetesList kubernetesList = klb.build();
assertThat(kubernetesList.getItems()).hasSize(1).first().isInstanceOf(Deployment.class);
Deployment deployment = (Deployment) kubernetesList.getItems().get(0);
assertThat(deployment).extracting(Deployment::getSpec).extracting(DeploymentSpec::getTemplate).extracting(PodTemplateSpec::getMetadata).extracting(ObjectMeta::getAnnotations).hasFieldOrPropertyWithValue("key1", "value1").hasFieldOrPropertyWithValue("key2", "value2");
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class ProjectLabelEnricherTest method testEmptyCustomAppName.
@Test
public void testEmptyCustomAppName() {
// Setup
properties.setProperty("jkube.enricher.jkube-project-label.app", "");
KubernetesListBuilder builder = createListWithDeploymentConfig();
projectLabelEnricher.enrich(PlatformMode.kubernetes, builder);
KubernetesList list = builder.build();
Map<String, String> labels = list.getItems().get(0).getMetadata().getLabels();
assertNotNull(labels);
assertEquals("groupId", labels.get("group"));
assertEquals("", labels.get("app"));
assertEquals("version", labels.get("version"));
assertNull(labels.get("project"));
builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().build());
projectLabelEnricher.create(PlatformMode.kubernetes, builder);
Deployment deployment = (Deployment) builder.buildFirstItem();
Map<String, String> selectors = deployment.getSpec().getSelector().getMatchLabels();
assertEquals("groupId", selectors.get("group"));
assertEquals("", selectors.get("app"));
assertNull(selectors.get("version"));
assertNull(selectors.get("project"));
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class RevisionHistoryEnricherTest method testDefaultRevisionHistoryLimit.
@Test
public void testDefaultRevisionHistoryLimit() throws JsonProcessingException {
// Given
KubernetesListBuilder builder = new KubernetesListBuilder().addToItems(new DeploymentBuilder().build());
RevisionHistoryEnricher enricher = new RevisionHistoryEnricher(context);
// When
enricher.create(PlatformMode.kubernetes, builder);
// Then
assertRevisionHistory(builder.build(), 2);
}
Aggregations