Search in sources :

Example 1 with KubernetesEnvBuildItem

use of io.quarkus.kubernetes.spi.KubernetesEnvBuildItem in project quarkus by quarkusio.

the class EnvVarValidator method process.

void process(String name, Optional<String> value, Optional<String> secret, Optional<String> configmap, Optional<String> field, String target, boolean... oldStyle) {
    try {
        final KubernetesEnvBuildItem kebi = KubernetesEnvBuildItem.create(name, value.orElse(null), secret.orElse(null), configmap.orElse(null), field.orElse(null), target, oldStyle);
        process(kebi);
    } catch (IllegalArgumentException e) {
        errors.add(e.getMessage());
    }
}
Also used : KubernetesEnvBuildItem(io.quarkus.kubernetes.spi.KubernetesEnvBuildItem)

Example 2 with KubernetesEnvBuildItem

use of io.quarkus.kubernetes.spi.KubernetesEnvBuildItem in project quarkus by quarkusio.

the class EnvVarValidatorTest method getBuildItemsUsingOldStyleProcessAndNewStyleCreateForSameItemShouldKeepNewStyle.

@Test
void getBuildItemsUsingOldStyleProcessAndNewStyleCreateForSameItemShouldKeepNewStyle() {
    final String name = "name";
    final String configmap = "configmap";
    final String key = "key";
    final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createFromConfigMapKey(name, key, configmap, TARGET);
    validator.process(first);
    validator.process(name, Optional.of("oldKey"), Optional.empty(), Optional.of(configmap), Optional.empty(), TARGET, true);
    Collection<KubernetesEnvBuildItem> buildItems = validator.getBuildItems();
    assertEquals(1, buildItems.size());
    assertTrue(buildItems.contains(first));
    // check different order
    validator = new EnvVarValidator();
    validator.process(name, Optional.of("oldKey"), Optional.empty(), Optional.of(configmap), Optional.empty(), TARGET, true);
    validator.process(first);
    buildItems = validator.getBuildItems();
    assertEquals(1, buildItems.size());
    assertTrue(buildItems.contains(first));
}
Also used : KubernetesEnvBuildItem(io.quarkus.kubernetes.spi.KubernetesEnvBuildItem) Test(org.junit.jupiter.api.Test)

Example 3 with KubernetesEnvBuildItem

use of io.quarkus.kubernetes.spi.KubernetesEnvBuildItem in project quarkus by quarkusio.

the class EnvVarValidatorTest method getBuildItemsTwoConflictingItemsUsingDifferentStylesShouldFail.

@Test
void getBuildItemsTwoConflictingItemsUsingDifferentStylesShouldFail() {
    final String name = "name";
    final String value1 = "foo";
    final String value2 = "bar";
    final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createSimpleVar(name, value1, TARGET, true);
    final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromField(name, value2, TARGET);
    validator.process(first);
    validator.process(second);
    try {
        validator.getBuildItems();
        fail();
    } catch (Exception e) {
        final String message = e.getMessage();
        assertTrue(message.contains(name) && message.contains(value1) && message.contains(value2));
    }
    // check different order
    validator = new EnvVarValidator();
    validator.process(second);
    validator.process(first);
    try {
        validator.getBuildItems();
        fail();
    } catch (Exception e) {
        final String message = e.getMessage();
        assertTrue(message.contains(name) && message.contains(value1) && message.contains(value2));
    }
}
Also used : KubernetesEnvBuildItem(io.quarkus.kubernetes.spi.KubernetesEnvBuildItem) Test(org.junit.jupiter.api.Test)

Example 4 with KubernetesEnvBuildItem

use of io.quarkus.kubernetes.spi.KubernetesEnvBuildItem in project quarkus by quarkusio.

the class EnvVarValidatorTest method getBuildItemsSimilarlyNamedCompatibleItemsShouldWork.

@Test
void getBuildItemsSimilarlyNamedCompatibleItemsShouldWork() {
    final String name = "name";
    final String value1 = "foo";
    final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createSimpleVar(name, value1, TARGET);
    final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromSecret(name, TARGET);
    final KubernetesEnvBuildItem third = KubernetesEnvBuildItem.createFromConfigMap(name, TARGET);
    validator.process(first);
    validator.process(second);
    validator.process(third);
    Collection<KubernetesEnvBuildItem> items = validator.getBuildItems();
    assertEquals(3, items.size());
    assertTrue(items.contains(first) && items.contains(second) && items.contains(third));
    // check different order
    validator = new EnvVarValidator();
    validator.process(third);
    validator.process(first);
    validator.process(second);
    items = validator.getBuildItems();
    assertEquals(3, items.size());
    assertTrue(items.contains(first) && items.contains(second) && items.contains(third));
}
Also used : KubernetesEnvBuildItem(io.quarkus.kubernetes.spi.KubernetesEnvBuildItem) Test(org.junit.jupiter.api.Test)

Example 5 with KubernetesEnvBuildItem

use of io.quarkus.kubernetes.spi.KubernetesEnvBuildItem in project quarkus by quarkusio.

the class EnvVarValidatorTest method getBuildItemsTwoConflictingItemsShouldFail.

@Test
void getBuildItemsTwoConflictingItemsShouldFail() {
    final String name = "name";
    final String value1 = "foo";
    final String value2 = "bar";
    final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createSimpleVar(name, value1, TARGET);
    final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromField(name, value2, TARGET);
    validator.process(first);
    validator.process(second);
    try {
        validator.getBuildItems();
        fail();
    } catch (Exception e) {
        final String message = e.getMessage();
        assertTrue(message.contains(name) && message.contains(value1) && message.contains(value2));
    }
}
Also used : KubernetesEnvBuildItem(io.quarkus.kubernetes.spi.KubernetesEnvBuildItem) Test(org.junit.jupiter.api.Test)

Aggregations

KubernetesEnvBuildItem (io.quarkus.kubernetes.spi.KubernetesEnvBuildItem)11 Test (org.junit.jupiter.api.Test)9 Clients (io.dekorate.utils.Clients)1 Serialization (io.dekorate.utils.Serialization)1 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)1 KubernetesList (io.fabric8.kubernetes.api.model.KubernetesList)1 Secret (io.fabric8.kubernetes.api.model.Secret)1 Config (io.fabric8.kubernetes.client.Config)1 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)1 LogWatch (io.fabric8.kubernetes.client.dsl.LogWatch)1 Build (io.fabric8.openshift.api.model.Build)1 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)1 ImageStream (io.fabric8.openshift.api.model.ImageStream)1 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)1 ContainerImageConfig (io.quarkus.container.image.deployment.ContainerImageConfig)1 ImageUtil (io.quarkus.container.image.deployment.util.ImageUtil)1 AvailableContainerImageExtensionBuildItem (io.quarkus.container.spi.AvailableContainerImageExtensionBuildItem)1 BaseImageInfoBuildItem (io.quarkus.container.spi.BaseImageInfoBuildItem)1 ContainerImageBuildRequestBuildItem (io.quarkus.container.spi.ContainerImageBuildRequestBuildItem)1