Search in sources :

Example 6 with ResourceConfig

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

the class ConfigMapEnricherTest method should_materialize_file_content_from_xml.

@Test
public void should_materialize_file_content_from_xml() throws Exception {
    final org.eclipse.jkube.kit.config.resource.ConfigMap baseConfigMap = createXmlConfigMap("src/test/resources/test-application.properties");
    final ResourceConfig config = ResourceConfig.builder().configMap(baseConfigMap).build();
    new Expectations() {

        {
            context.getConfiguration();
            result = Configuration.builder().resource(config).build();
        }
    };
    final KubernetesListBuilder builder = new KubernetesListBuilder();
    new ConfigMapEnricher(context).create(PlatformMode.kubernetes, builder);
    final ConfigMap configMap = (ConfigMap) builder.buildFirstItem();
    final Map<String, String> data = configMap.getData();
    assertThat(data).containsEntry("test-application.properties", readFileContentsAsString("src/test/resources/test-application.properties"));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 7 with ResourceConfig

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

the class ConfigMapEnricherTest method should_materialize_binary_file_content_from_xml.

@Test
public void should_materialize_binary_file_content_from_xml() {
    final org.eclipse.jkube.kit.config.resource.ConfigMap baseConfigMap = createXmlConfigMap("src/test/resources/test.bin");
    final ResourceConfig config = ResourceConfig.builder().configMap(baseConfigMap).build();
    new Expectations() {

        {
            context.getConfiguration();
            result = Configuration.builder().resource(config).build();
        }
    };
    final KubernetesListBuilder builder = new KubernetesListBuilder();
    new ConfigMapEnricher(context).create(PlatformMode.kubernetes, builder);
    final ConfigMap configMap = (ConfigMap) builder.buildFirstItem();
    final Map<String, String> data = configMap.getData();
    assertNull(data);
    final Map<String, String> binaryData = configMap.getBinaryData();
    assertThat(binaryData).containsEntry("test.bin", "wA==");
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 8 with ResourceConfig

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

the class IngressEnricherTest method testGetRouteDomainFromResourceConfig.

@Test
public void testGetRouteDomainFromResourceConfig() {
    // Given
    ResourceConfig resourceConfig = ResourceConfig.builder().routeDomain("org.eclipse.jkube").build();
    // When
    String result = ingressEnricher.getRouteDomain(resourceConfig);
    // Then
    assertThat(result).isEqualTo("org.eclipse.jkube");
}
Also used : ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) IngressRulePathResourceConfig(org.eclipse.jkube.kit.config.resource.IngressRulePathResourceConfig) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) Test(org.junit.Test)

Example 9 with ResourceConfig

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

the class IngressEnricherTest method testGetIngressTlsXMLConfigWithNonNullResourceConfig.

@Test
public void testGetIngressTlsXMLConfigWithNonNullResourceConfig() {
    // Given
    ResourceConfig resourceConfig = ResourceConfig.builder().ingress(IngressConfig.builder().ingressTlsConfig(IngressTlsConfig.builder().secretName("secret1").build()).build()).build();
    // When
    List<IngressTlsConfig> ingressTlsConfigs = IngressEnricher.getIngressTlsXMLConfig(resourceConfig);
    // Then
    assertThat(ingressTlsConfigs).asList().hasSize(1);
}
Also used : IngressTlsConfig(org.eclipse.jkube.kit.config.resource.IngressTlsConfig) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) IngressRulePathResourceConfig(org.eclipse.jkube.kit.config.resource.IngressRulePathResourceConfig) Test(org.junit.Test)

Example 10 with ResourceConfig

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

the class BaseEnricherGetReplicaCountTest method withDeploymentConfigInListBuilderAndEmptyResourceConfigShouldReturnDeploymentConfig.

@Test
public void withDeploymentConfigInListBuilderAndEmptyResourceConfigShouldReturnDeploymentConfig() {
    // Given
    final KubernetesListBuilder klb = new KubernetesListBuilder().addToItems(new DeploymentConfigBuilder().withNewSpec().withReplicas(1).endSpec());
    final ResourceConfig resourceConfig = ResourceConfig.builder().replicas(313373).build();
    // When
    final int result = getReplicaCount(klb, resourceConfig, 1337);
    // Then
    assertThat(result).isEqualTo(1);
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) DeploymentConfigBuilder(io.fabric8.openshift.api.model.DeploymentConfigBuilder) 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