diff --git a/extensions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesEnvBuildItem.java b/extensions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesEnvBuildItem.java index 388edee154a2d3..229bcf1294c1c9 100644 --- a/extensions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesEnvBuildItem.java +++ b/extensions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesEnvBuildItem.java @@ -4,12 +4,13 @@ import io.quarkus.builder.item.MultiBuildItem; public final class KubernetesEnvBuildItem extends MultiBuildItem { - public enum EnvType { var(false), field(false), secret(true), - configmap(true); + configmap(true), + keyFromConfigmap(false), + keyFromSecret(false); public final boolean allowMultipleDefinitions; @@ -39,69 +40,91 @@ public boolean mightConflictWith(EnvType type) { private final String name; private final String value; + private final String configmap; + private final String secret; + private final String field; private final EnvType type; private final String target; private final boolean oldStyle; - public static EnvType getEnvType(String secret, String configmap, String field) { - final EnvType type; - if (secret != null) { - type = EnvType.secret; - } else if (configmap != null) { - type = EnvType.configmap; - } else if (field != null) { - type = EnvType.field; - } else { - type = EnvType.var; - } - return type; + public static KubernetesEnvBuildItem createFromField(String name, String targetField, String target, + boolean... oldStyle) { + return create(name, null, null, null, targetField, target, oldStyle.length >= 1 && oldStyle[0]); + } + + public static KubernetesEnvBuildItem createFromConfigMap(String configMapName, String target, boolean... oldStyle) { + return create(configMapName, null, null, configMapName, null, target, oldStyle.length >= 1 && oldStyle[0]); } - public static KubernetesEnvBuildItem createSimpleVar(String name, String value, String target) { - return new KubernetesEnvBuildItem(EnvType.var, name, value, target, false); + public static KubernetesEnvBuildItem createFromSecret(String secretName, String target, boolean... oldStyle) { + return create(secretName, null, secretName, null, null, target, oldStyle.length >= 1 && oldStyle[0]); } - public static KubernetesEnvBuildItem create(EnvType type, String name, String value, String target) { - return create(type, name, value, target, false); + public static KubernetesEnvBuildItem createSimpleVar(String name, String value, String target, + boolean... oldStyle) { + return create(name, value, null, null, null, target, oldStyle.length >= 1 && oldStyle[0]); } - public static KubernetesEnvBuildItem create(EnvType type, String name, String value, String target, - boolean oldStyle) { - return new KubernetesEnvBuildItem(type, name, value, target, oldStyle); + public static KubernetesEnvBuildItem create(String name, String value, String secret, String configmap, String field, + String target, boolean... oldStyle) throws IllegalArgumentException { + final boolean secretPresent = secret != null; + final boolean configmapPresent = configmap != null; + final boolean valuePresent = value != null; + final boolean fieldPresent = field != null; + if (valuePresent) { + if (secretPresent && configmapPresent) { + throw new IllegalArgumentException(String.format( + "'%s' env var can't simultaneously take its value from '%s' configmap & '%s' secret", + name, value, configmap, secret)); + } + if (fieldPresent) { + throw new IllegalArgumentException(String.format( + "'%s' env var can't simultaneously have a '%s' value & take is value from the '%s' field", + name, value, field)); + } + } + final EnvType type; + if (secretPresent) { + type = valuePresent ? EnvType.keyFromSecret : EnvType.secret; + } else if (configmapPresent) { + type = valuePresent ? EnvType.keyFromConfigmap : EnvType.configmap; + } else if (field != null) { + type = EnvType.field; + } else { + type = EnvType.var; + } + return new KubernetesEnvBuildItem(name, value, configmap, secret, field, type, target, + oldStyle.length >= 1 && oldStyle[0]); } - KubernetesEnvBuildItem(EnvType type, String name, String value, String target, boolean oldStyle) { + KubernetesEnvBuildItem(String name, String value, String configmap, String secret, String field, EnvType type, + String target, boolean oldStyle) { this.name = name; this.value = value; + this.configmap = configmap; + this.secret = secret; + this.field = field; this.type = type; this.target = target; this.oldStyle = oldStyle; } public String getConfigMap() { - return getValueIfMatching(EnvType.configmap); + return configmap; } public String getSecret() { - return getValueIfMatching(EnvType.secret); + return secret; } public String getField() { - return getValueIfMatching(EnvType.field); - } - - public String getVar() { - return getValueIfMatching(EnvType.var); + return field; } public boolean isOldStyle() { return oldStyle; } - private String getValueIfMatching(EnvType type) { - return this.type == type ? value : null; - } - public String getName() { return name; } @@ -129,24 +152,29 @@ public boolean equals(Object o) { if (!name.equals(that.name)) return false; - if (!value.equals(that.value)) + if (value != null ? !value.equals(that.value) : that.value != null) return false; - if (type != that.type) + if (configmap != null ? !configmap.equals(that.configmap) : that.configmap != null) return false; - return target.equals(that.target); + if (secret != null ? !secret.equals(that.secret) : that.secret != null) + return false; + if (field != null ? !field.equals(that.field) : that.field != null) + return false; + return type == that.type; } @Override public int hashCode() { int result = name.hashCode(); - result = 31 * result + value.hashCode(); + result = 31 * result + (value != null ? value.hashCode() : 0); + result = 31 * result + (configmap != null ? configmap.hashCode() : 0); + result = 31 * result + (secret != null ? secret.hashCode() : 0); + result = 31 * result + (field != null ? field.hashCode() : 0); result = 31 * result + type.hashCode(); - result = 31 * result + target.hashCode(); return result; } public String toString() { return String.format("'%s' env var with value '%s'", this.getType().name(), this.getValue()); } - } diff --git a/extensions/kubernetes/spi/src/test/java/io/quarkus/kubernetes/spi/KubernetesEnvBuildItemTest.java b/extensions/kubernetes/spi/src/test/java/io/quarkus/kubernetes/spi/KubernetesEnvBuildItemTest.java new file mode 100644 index 00000000000000..c8f177e1f461ca --- /dev/null +++ b/extensions/kubernetes/spi/src/test/java/io/quarkus/kubernetes/spi/KubernetesEnvBuildItemTest.java @@ -0,0 +1,55 @@ +/** + * Copyright 2020 Red Hat, Inc. and/or its affiliates. + * + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.quarkus.kubernetes.spi; + +import static io.quarkus.kubernetes.spi.KubernetesEnvBuildItem.create; +import static io.quarkus.kubernetes.spi.KubernetesEnvBuildItem.EnvType.configmap; +import static io.quarkus.kubernetes.spi.KubernetesEnvBuildItem.EnvType.var; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.Test; + +/** + * @author Christophe Laprun + */ +public class KubernetesEnvBuildItemTest { + + private static final String TARGET = "target"; + private static final String VALUE = "value"; + private static final String NAME = "name"; + + @Test + public void testCreateSimpleVarFromEnvConfig() { + final KubernetesEnvBuildItem item = create(NAME, VALUE, null, null, null, TARGET); + assertEquals(var, item.getType()); + assertEquals(NAME, item.getName()); + assertEquals(VALUE, item.getValue()); + assertEquals(TARGET, item.getTarget()); + assertNull(item.getConfigMap()); + assertNull(item.getSecret()); + assertNull(item.getField()); + } + + @Test + public void testCreateLoadFromConfigMapFromEnvConfig() { + final KubernetesEnvBuildItem item = create(NAME, null, null, VALUE, null, TARGET); + assertEquals(configmap, item.getType()); + assertEquals(NAME, item.getName()); + assertNull(item.getValue()); + assertEquals(VALUE, item.getConfigMap()); + assertNull(item.getSecret()); + assertNull(item.getField()); + } +} diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarHolder.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarHolder.java index c5456ce42962fc..b84024b5c78f84 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarHolder.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarHolder.java @@ -1,7 +1,5 @@ package io.quarkus.kubernetes.deployment; -import static io.quarkus.kubernetes.spi.KubernetesEnvBuildItem.EnvType.*; - import java.util.Collection; import java.util.Map; @@ -44,21 +42,23 @@ default Collection convertToBuildItems() { // first process old-style configuration, this relies on each configuration having a name final String target = getTargetPlatformName(); getEnvVars().forEach((key, envConfig) -> { - envConfig.secret.ifPresent(s -> validator.process(KubernetesEnvBuildItem.create(secret, s, s, target, true))); - envConfig.configmap - .ifPresent(cm -> validator.process(KubernetesEnvBuildItem.create(configmap, cm, cm, target, true))); - envConfig.field.ifPresent(f -> validator.process(KubernetesEnvBuildItem.create(field, key, f, target, true))); - envConfig.value.ifPresent(v -> validator.process(KubernetesEnvBuildItem.create(var, key, v, target, true))); + validator.process(key, envConfig.value, envConfig.secret, envConfig.configmap, envConfig.field, target); + /* + * envConfig.secret.ifPresent(s -> validator.process(KubernetesEnvBuildItem.create(secret, s, s, target, true))); + * envConfig.configmap + * .ifPresent(cm -> validator.process(KubernetesEnvBuildItem.create(configmap, cm, cm, target, true))); + * envConfig.field.ifPresent(f -> validator.process(KubernetesEnvBuildItem.create(field, key, f, target, true))); + * envConfig.value.ifPresent(v -> validator.process(KubernetesEnvBuildItem.create(var, key, v, target, true))); + */ }); // override old-style with newer versions if present final EnvVarsConfig c = getEnv(); - c.vars.forEach((k, v) -> validator.process(KubernetesEnvBuildItem.create(var, k, v, target))); - c.fields.forEach((k, v) -> validator.process(KubernetesEnvBuildItem.create(field, k, v, target))); - c.configmaps.ifPresent( - cl -> cl.forEach(cm -> validator.process(KubernetesEnvBuildItem.create(configmap, cm, cm, target)))); - c.secrets.ifPresent( - sl -> sl.forEach(s -> validator.process(KubernetesEnvBuildItem.create(secret, s, s, target)))); + c.vars.forEach((k, v) -> validator.process(KubernetesEnvBuildItem.createSimpleVar(k, v, target))); + c.fields.forEach((k, v) -> validator.process(KubernetesEnvBuildItem.createFromField(k, v, target))); + c.configmaps + .ifPresent(cl -> cl.forEach(cm -> validator.process(KubernetesEnvBuildItem.createFromConfigMap(cm, target)))); + c.secrets.ifPresent(sl -> sl.forEach(s -> validator.process(KubernetesEnvBuildItem.createFromSecret(s, target)))); return validator.getBuildItems(); } diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarValidator.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarValidator.java index 2b320f6281467d..06db3a69976ccc 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarValidator.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarValidator.java @@ -15,6 +15,18 @@ public class EnvVarValidator { private final Map items = new HashMap<>(); private final Set knownNames = new HashSet<>(); private final Map> conflicting = new HashMap<>(); + private final Set errors = new HashSet<>(); + + void process(String name, Optional value, Optional secret, Optional configmap, + Optional field, String target) { + try { + final KubernetesEnvBuildItem kebi = KubernetesEnvBuildItem.create(name, value.orElse(null), + secret.orElse(null), configmap.orElse(null), field.orElse(null), target, true); + process(kebi); + } catch (IllegalArgumentException e) { + errors.add(e.getMessage()); + } + } /** * Processes the specified {@link KubernetesEnvBuildItem} to check whether it's valid with respect to the set of already @@ -84,22 +96,29 @@ private void addError(KubernetesEnvBuildItem item, KubernetesEnvBuildItem existi * @throws IllegalArgumentException if the processed items result in an invalid configuration */ Collection getBuildItems() { - if (conflicting.isEmpty()) { + if (conflicting.isEmpty() && errors.isEmpty()) { return items.values(); } throw new IllegalArgumentException(getError()); } private String getError() { - String error = "Found conflicts in environment variable definitions:\n"; - error += conflicting.entrySet().stream() - .map(e -> { - final String conflicting = e.getValue().stream() - .map(Object::toString) - .collect(Collectors.joining(" redefined as ")); - return String.format("\t\t- '%s': first defined as %s", e.getKey(), conflicting); - }) - .collect(Collectors.joining("\n")); + String error = "Errors:\n"; + if (!conflicting.isEmpty()) { + error += "Found conflicts in environment variable definitions:\n"; + error += conflicting.entrySet().stream() + .map(e -> { + final String conflicting = e.getValue().stream() + .map(Object::toString) + .collect(Collectors.joining(" redefined as ")); + return String.format("\t\t- '%s': first defined as %s", e.getKey(), conflicting); + }) + .collect(Collectors.joining("\n")); + } + if (!errors.isEmpty()) { + error += "Invalid declarations:\n"; + error += errors.stream().map(s -> "\t\t- " + s).collect(Collectors.joining("\n")); + } return error; } diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java index 24072b2fc8af9f..825dea3f1c4aa1 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java @@ -1,21 +1,6 @@ package io.quarkus.kubernetes.deployment; import static io.quarkus.kubernetes.deployment.Constants.*; -import static io.quarkus.kubernetes.deployment.Constants.DEFAULT_HTTP_PORT; -import static io.quarkus.kubernetes.deployment.Constants.DEFAULT_S2I_IMAGE_NAME; -import static io.quarkus.kubernetes.deployment.Constants.DEPLOYMENT; -import static io.quarkus.kubernetes.deployment.Constants.DEPLOYMENT_CONFIG; -import static io.quarkus.kubernetes.deployment.Constants.HTTP_PORT; -import static io.quarkus.kubernetes.deployment.Constants.KNATIVE; -import static io.quarkus.kubernetes.deployment.Constants.KUBERNETES; -import static io.quarkus.kubernetes.deployment.Constants.MINIKUBE; -import static io.quarkus.kubernetes.deployment.Constants.OPENSHIFT; -import static io.quarkus.kubernetes.deployment.Constants.OPENSHIFT_APP_RUNTIME; -import static io.quarkus.kubernetes.deployment.Constants.QUARKUS; -import static io.quarkus.kubernetes.deployment.Constants.QUARKUS_ANNOTATIONS_BUILD_TIMESTAMP; -import static io.quarkus.kubernetes.deployment.Constants.QUARKUS_ANNOTATIONS_COMMIT_ID; -import static io.quarkus.kubernetes.deployment.Constants.QUARKUS_ANNOTATIONS_VCS_URL; -import static io.quarkus.kubernetes.deployment.Constants.SERVICE; import static io.quarkus.kubernetes.spi.KubernetesDeploymentTargetBuildItem.*; import java.io.File; @@ -28,16 +13,7 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; import org.jboss.logging.Logger; @@ -52,29 +28,7 @@ import io.dekorate.kubernetes.config.Label; import io.dekorate.kubernetes.config.PortBuilder; import io.dekorate.kubernetes.configurator.AddPort; -import io.dekorate.kubernetes.decorator.AddAnnotationDecorator; -import io.dekorate.kubernetes.decorator.AddAwsElasticBlockStoreVolumeDecorator; -import io.dekorate.kubernetes.decorator.AddAzureDiskVolumeDecorator; -import io.dekorate.kubernetes.decorator.AddAzureFileVolumeDecorator; -import io.dekorate.kubernetes.decorator.AddConfigMapVolumeDecorator; -import io.dekorate.kubernetes.decorator.AddEnvVarDecorator; -import io.dekorate.kubernetes.decorator.AddImagePullSecretDecorator; -import io.dekorate.kubernetes.decorator.AddInitContainerDecorator; -import io.dekorate.kubernetes.decorator.AddLabelDecorator; -import io.dekorate.kubernetes.decorator.AddLivenessProbeDecorator; -import io.dekorate.kubernetes.decorator.AddMountDecorator; -import io.dekorate.kubernetes.decorator.AddPvcVolumeDecorator; -import io.dekorate.kubernetes.decorator.AddReadinessProbeDecorator; -import io.dekorate.kubernetes.decorator.AddRoleBindingResourceDecorator; -import io.dekorate.kubernetes.decorator.AddSecretVolumeDecorator; -import io.dekorate.kubernetes.decorator.AddServiceAccountResourceDecorator; -import io.dekorate.kubernetes.decorator.AddSidecarDecorator; -import io.dekorate.kubernetes.decorator.ApplyArgsDecorator; -import io.dekorate.kubernetes.decorator.ApplyCommandDecorator; -import io.dekorate.kubernetes.decorator.ApplyImagePullPolicyDecorator; -import io.dekorate.kubernetes.decorator.ApplyServiceAccountNamedDecorator; -import io.dekorate.kubernetes.decorator.ApplyWorkingDirDecorator; -import io.dekorate.kubernetes.decorator.RemoveAnnotationDecorator; +import io.dekorate.kubernetes.decorator.*; import io.dekorate.processor.SimpleFileReader; import io.dekorate.processor.SimpleFileWriter; import io.dekorate.project.BuildInfo; @@ -100,15 +54,7 @@ import io.quarkus.deployment.pkg.PackageConfig; import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem; import io.quarkus.deployment.util.FileUtil; -import io.quarkus.kubernetes.spi.KubernetesAnnotationBuildItem; -import io.quarkus.kubernetes.spi.KubernetesCommandBuildItem; -import io.quarkus.kubernetes.spi.KubernetesDeploymentTargetBuildItem; -import io.quarkus.kubernetes.spi.KubernetesEnvBuildItem; -import io.quarkus.kubernetes.spi.KubernetesHealthLivenessPathBuildItem; -import io.quarkus.kubernetes.spi.KubernetesHealthReadinessPathBuildItem; -import io.quarkus.kubernetes.spi.KubernetesLabelBuildItem; -import io.quarkus.kubernetes.spi.KubernetesPortBuildItem; -import io.quarkus.kubernetes.spi.KubernetesRoleBuildItem; +import io.quarkus.kubernetes.spi.*; class KubernetesProcessor { @@ -536,26 +482,13 @@ private void applyBuildItems(Session session, }); kubernetesEnvs.forEach(e -> { - final String value = e.getValue(); - final EnvBuilder envBuilder = new EnvBuilder() - .withValue(value); - switch (e.getType()) { - case var: - envBuilder.withName(EnvConverter.convertName(e.getName())); - break; - case field: - // env vars from fields need to have their name set in addition to their field field :) - final String name = EnvConverter.convertName(e.getName()); - envBuilder.withField(value).withName(name); - break; - case secret: - envBuilder.withSecret(value); - break; - case configmap: - envBuilder.withConfigmap(value); - break; - } - session.resources().decorate(e.getTarget(), new AddEnvVarDecorator(envBuilder.build())); + session.resources().decorate(e.getTarget(), new AddEnvVarDecorator(new EnvBuilder() + .withName(EnvConverter.convertName(e.getName())) + .withValue(e.getValue()) + .withSecret(e.getSecret()) + .withConfigmap(e.getConfigMap()) + .withField(e.getField()) + .build())); }); //Handle Command and arguments diff --git a/extensions/kubernetes/vanilla/deployment/src/test/java/io/quarkus/kubernetes/deployment/EnvVarValidatorTest.java b/extensions/kubernetes/vanilla/deployment/src/test/java/io/quarkus/kubernetes/deployment/EnvVarValidatorTest.java index e9bc2ccc892db2..211aa11e38565b 100644 --- a/extensions/kubernetes/vanilla/deployment/src/test/java/io/quarkus/kubernetes/deployment/EnvVarValidatorTest.java +++ b/extensions/kubernetes/vanilla/deployment/src/test/java/io/quarkus/kubernetes/deployment/EnvVarValidatorTest.java @@ -25,8 +25,7 @@ void getBuildItemsShouldReturnEmptyOnNoItems() { @Test void getBuildItemsOneItemShouldWork() { - final KubernetesEnvBuildItem initial = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.var, - "name", "value", "kubernetes"); + final KubernetesEnvBuildItem initial = KubernetesEnvBuildItem.createSimpleVar("name", "value", "kubernetes"); validator.process(initial); final Collection items = validator.getBuildItems(); assertEquals(1, items.size()); @@ -38,12 +37,8 @@ void getBuildItemsTwoConflictingItemsShouldFail() { final String name = "name"; final String value1 = "foo"; final String value2 = "bar"; - final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.var, name, - value1, - "kubernetes"); - final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.field, name, - value2, - "kubernetes"); + final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createSimpleVar(name, value1, "kubernetes"); + final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromField(name, value2, "kubernetes"); validator.process(first); validator.process(second); try { @@ -58,13 +53,8 @@ void getBuildItemsTwoConflictingItemsShouldFail() { @Test void getBuildItemsTwoRedundantItemsShouldResultInOnlyOneItem() { final String name = "name"; - final String value1 = "foo"; - final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.configmap, name, - value1, - "kubernetes"); - final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.configmap, name, - value1, - "kubernetes"); + final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createFromConfigMap(name, "kubernetes"); + final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromConfigMap(name, "kubernetes"); validator.process(first); validator.process(second); final Collection items = validator.getBuildItems(); @@ -76,12 +66,9 @@ void getBuildItemsTwoRedundantItemsShouldResultInOnlyOneItem() { void getBuildItemsSimilarlyNamedCompatibleItemsShouldWork() { final String name = "name"; final String value1 = "foo"; - final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.var, name, value1, - "kubernetes"); - final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.secret, name, name, - "kubernetes"); - final KubernetesEnvBuildItem third = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.configmap, name, name, - "kubernetes"); + final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createSimpleVar(name, value1, "kubernetes"); + final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromSecret(name, "kubernetes"); + final KubernetesEnvBuildItem third = KubernetesEnvBuildItem.createFromConfigMap(name, "kubernetes"); validator.process(first); validator.process(second); validator.process(third); @@ -103,11 +90,8 @@ void getBuildItemsSimilarlyNamedCompatibleItemsShouldWork() { void getBuildItemsSameItemsOldAndNewShouldWork() { final String name = "name"; final String value1 = "foo"; - final KubernetesEnvBuildItem oldStyleVar = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.var, name, - value1, - "kubernetes", true); - final KubernetesEnvBuildItem newStyleVar = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.var, name, - "newValue", + final KubernetesEnvBuildItem oldStyleVar = KubernetesEnvBuildItem.createSimpleVar(name, value1, "kubernetes", true); + final KubernetesEnvBuildItem newStyleVar = KubernetesEnvBuildItem.createSimpleVar(name, "newValue", "kubernetes", false); validator.process(oldStyleVar); validator.process(newStyleVar); @@ -129,10 +113,8 @@ void getBuildItemsTwoConflictingItemsUsingDifferentStylesShouldFail() { final String name = "name"; final String value1 = "foo"; final String value2 = "bar"; - final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.var, name, value1, - "kubernetes", true); - final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.create(KubernetesEnvBuildItem.EnvType.field, name, value2, - "kubernetes"); + final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createSimpleVar(name, value1, "kubernetes", true); + final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromField(name, value2, "kubernetes"); validator.process(first); validator.process(second); try {