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());
}
}
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));
}
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));
}
}
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));
}
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));
}
}
Aggregations