use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class ServiceAccountEnricherTest method testServiceAccountCreationFromFragment.
@Test
public void testServiceAccountCreationFromFragment() {
final KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("cheese").endMetadata().withNewSpec().withNewTemplate().withNewSpec().addNewContainer().withImage("cheese-image").endContainer().withServiceAccount("ribbon").endSpec().endTemplate().endSpec().build());
enrichAndAssert(builder);
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class ContainerEnvJavaOptionsMergeTest method setUp.
@Before
public void setUp() {
containerEnvJavaOptionsMergeEnricher = new ContainerEnvJavaOptionsMergeEnricher(context);
kubernetesListBuilder = new KubernetesListBuilder();
properties = new Properties();
// @formatter:off
kubernetesListBuilder.addToItems(new DeploymentBuilder().withNewSpec().withNewTemplate().withNewSpec().addToContainers(new ContainerBuilder().withImage("the-image:latest").addToEnv(new EnvVar("JAVA_OPTIONS", "val-from-container", null)).build()).endSpec().endTemplate().endSpec().build());
new Expectations() {
{
context.getConfiguration();
result = Configuration.builder().image(imageConfiguration).build();
context.getProperties();
result = properties;
}
};
// @formatter:on
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class DebugEnricherTest method setUp.
@Before
public void setUp() {
properties = new Properties();
processorConfig = new ProcessorConfig();
klb = new KubernetesListBuilder();
// @formatter:off
klb.addToItems(new DeploymentBuilder().editOrNewSpec().editOrNewTemplate().editOrNewMetadata().withName("template-name").endMetadata().editOrNewSpec().addNewContainer().withImage("container/image").endContainer().endSpec().endTemplate().endSpec().build());
new Expectations() {
{
context.getProperties();
result = properties;
context.getConfiguration().getProcessorConfig();
result = processorConfig;
}
};
// @formatter:on
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class DefaultMetadataEnricherTest method setUp.
@Before
public void setUp() throws Exception {
Configuration configuration = Configuration.builder().resource(ResourceConfig.builder().annotations(MetaDataConfig.builder().all(properties("all-annotation", 1)).deployment(properties("deployment", "Deployment")).ingress(properties("ingress", "Ingress")).serviceAccount(properties("service-account", "ServiceAccount")).build()).labels(MetaDataConfig.builder().all(properties("all-label", 10L)).deployment(properties("deployment-label", "Deployment")).ingress(properties("ingress-label", "Ingress")).serviceAccount(properties("service-account-label", "ServiceAccount")).build()).build()).build();
// @formatter:off
new Expectations() {
{
buildContext.getConfiguration();
result = configuration;
}
};
// @formatter:on
defaultMetadataEnricher = new DefaultMetadataEnricher(buildContext);
configMap = new ConfigMapBuilder().withNewMetadata().endMetadata();
deployment = new DeploymentBuilder();
genericResource = new GenericKubernetesResourceBuilder().withNewMetadata().endMetadata();
ingressV1 = new io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder();
ingressV1beta1 = new io.fabric8.kubernetes.api.model.networking.v1beta1.IngressBuilder();
serviceAccount = new ServiceAccountBuilder();
klb = new KubernetesListBuilder().addToItems(configMap).addToItems(deployment).addToItems(genericResource).addToItems(ingressV1).addToItems(ingressV1beta1).addToItems(serviceAccount);
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.
the class DefaultNamespaceEnricherTest method enrichWithPropertiesInKubernetesShouldAddNamespaceWithStatus.
@Test
public void enrichWithPropertiesInKubernetesShouldAddNamespaceWithStatus() {
// Given
setNamespaceInResourceConfig("example");
final KubernetesListBuilder klb = new KubernetesListBuilder();
Namespace namespace = new NamespaceBuilder().editOrNewMetadata().withName("name").withNamespace("to-be-overwritten").endMetadata().editOrNewStatus().withPhase("active").endStatus().build();
Deployment deployment = new DeploymentBuilder().withNewMetadata().withName("d1").endMetadata().build();
klb.addToItems(namespace, deployment);
// When
new DefaultNamespaceEnricher(context).enrich(PlatformMode.kubernetes, klb);
// Then
assertThat(klb.build().getItems()).hasSize(2);
assertThat(klb.build().getItems().get(1)).hasFieldOrPropertyWithValue("metadata.namespace", "example");
}
Aggregations