Search in sources :

Example 16 with ResourceConfig

use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.

the class DefaultNamespaceEnricherTest method createWithPropertiesAndConfigInKubernetesShouldAddConfigNamespace.

@Test
public void createWithPropertiesAndConfigInKubernetesShouldAddConfigNamespace() {
    // Given
    Properties properties = new Properties();
    properties.put("jkube.enricher.jkube-namespace.namespace", "config-example");
    setExpectations(properties, new ResourceConfig());
    final KubernetesListBuilder klb = new KubernetesListBuilder();
    // When
    new DefaultNamespaceEnricher(context).create(PlatformMode.kubernetes, klb);
    // Then
    assertThat(klb.build().getItems()).hasSize(1);
    assertThat(klb.build().getItems().iterator().next()).isInstanceOf(Namespace.class).hasFieldOrPropertyWithValue("metadata.name", "config-example").hasFieldOrPropertyWithValue("status.phase", "Active");
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Properties(java.util.Properties) Test(org.junit.Test)

Example 17 with ResourceConfig

use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.

the class DefaultNamespaceEnricherTest method noNameShouldReturnEmpty.

@Test
public void noNameShouldReturnEmpty() {
    // Given
    setExpectations(new Properties(), new ResourceConfig());
    final KubernetesListBuilder klb = new KubernetesListBuilder();
    // When
    new DefaultNamespaceEnricher(context).create(PlatformMode.kubernetes, klb);
    // Then
    assertThat(klb.build().getItems()).isEmpty();
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Properties(java.util.Properties) Test(org.junit.Test)

Example 18 with ResourceConfig

use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.

the class DefaultNamespaceEnricherTest method createWithPropertiesInKubernetesShouldAddNamespace.

@Test
public void createWithPropertiesInKubernetesShouldAddNamespace() {
    // Given
    Properties properties = new Properties();
    properties.put("jkube.enricher.jkube-namespace.namespace", "example");
    setExpectations(properties, new ResourceConfig());
    final KubernetesListBuilder klb = new KubernetesListBuilder();
    // When
    new DefaultNamespaceEnricher(context).create(PlatformMode.kubernetes, klb);
    // Then
    assertThat(klb.build().getItems()).hasSize(1);
    assertThat(klb.build().getItems().iterator().next()).isInstanceOf(Namespace.class).hasFieldOrPropertyWithValue("metadata.name", "example").hasFieldOrPropertyWithValue("status.phase", "Active");
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Properties(java.util.Properties) Test(org.junit.Test)

Example 19 with ResourceConfig

use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.

the class DefaultNamespaceEnricherTest method enrichWithPropertiesInKubernetesShouldAddProjectWithStatus.

@Test
public void enrichWithPropertiesInKubernetesShouldAddProjectWithStatus() {
    // Given
    setExpectations(new Properties(), new ResourceConfig());
    final KubernetesListBuilder klb = new KubernetesListBuilder();
    klb.addToItems(new ProjectBuilder().withNewMetadata().withName("name").endMetadata().withNewStatus().withPhase("active").endStatus().build());
    // When
    new DefaultNamespaceEnricher(context).enrich(PlatformMode.openshift, klb);
    // Then
    assertThat(klb.build().getItems()).hasSize(1);
    assertThat(klb.build().getItems().iterator().next()).hasFieldOrPropertyWithValue("metadata.namespace", null);
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ProjectBuilder(io.fabric8.openshift.api.model.ProjectBuilder) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Properties(java.util.Properties) Test(org.junit.Test)

Example 20 with ResourceConfig

use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.

the class ReplicaSetHandlerTest method replicaSetHandlerWithoutControllerTest.

@Test(expected = IllegalArgumentException.class)
public void replicaSetHandlerWithoutControllerTest() {
    // without controller name
    ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
    replicaSetHandler.get(config, images);
}
Also used : ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Aggregations

ResourceConfig (org.eclipse.jkube.kit.config.resource.ResourceConfig)69 Test (org.junit.Test)60 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)17 Properties (java.util.Properties)10 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)9 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)7 VolumeConfig (org.eclipse.jkube.kit.config.resource.VolumeConfig)7 ArrayList (java.util.ArrayList)5 Expectations (mockit.Expectations)5 File (java.io.File)4 IngressRulePathResourceConfig (org.eclipse.jkube.kit.config.resource.IngressRulePathResourceConfig)4 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)3 Service (io.fabric8.kubernetes.api.model.Service)3 IOException (java.io.IOException)3 List (java.util.List)3 Optional (java.util.Optional)3 KitLogger (org.eclipse.jkube.kit.common.KitLogger)3 JKubeServiceHub (org.eclipse.jkube.kit.config.service.JKubeServiceHub)3 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)2 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)2