diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvConverter.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvConverter.java index 412c5a8152963..531ae2cfc4f6c 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvConverter.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvConverter.java @@ -28,7 +28,7 @@ public static List convert(EnvVarsConfig e) { e.secrets.ifPresent(sl -> sl.forEach(s -> envs.add(new EnvBuilder().withName(convertName(s)).withSecret(s).build()))); e.configmaps .ifPresent(cl -> cl.forEach(c -> envs.add(new EnvBuilder().withName(convertName(c)).withConfigmap(c).build()))); - e.vars.forEach((k, v) -> envs.add(new EnvBuilder().withName(convertName(k)).withValue(v).build())); + e.vars.forEach((k, v) -> envs.add(new EnvBuilder().withName(convertName(k)).withValue(v.orElse("")).build())); e.fields.forEach((k, v) -> { // env vars from fields need to have their name set in addition to their field field :) final String field = convertName(k); 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 01a86ba2e8357..511fb1c080b62 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 @@ -48,7 +48,7 @@ default Collection convertToBuildItems() { // override old-style with newer versions if present final EnvVarsConfig c = getEnv(); - c.vars.forEach((k, v) -> validator.process(KubernetesEnvBuildItem.createSimpleVar(k, v, target))); + c.vars.forEach((k, v) -> validator.process(KubernetesEnvBuildItem.createSimpleVar(k, v.orElse(""), 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)))); diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarsConfig.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarsConfig.java index 340fc6aae4101..cdcf6e947a93a 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarsConfig.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarsConfig.java @@ -34,7 +34,7 @@ public class EnvVarsConfig { * The map associating environment name to its associated value. */ @ConfigItem - Map vars; + Map> vars; /** * The map recording the configuration of environment variable taking their value from resource (Secret or diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithNewStyleEnvTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithNewStyleEnvTest.java index 6d08b17615546..1aab78aab2658 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithNewStyleEnvTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithNewStyleEnvTest.java @@ -55,6 +55,9 @@ public void assertGeneratedResources() throws IOException { assertThat(container.getEnv()) .filteredOn(env -> "ENVVAR".equals(env.getName())) .singleElement().satisfies(env -> assertThat(env.getValue()).isEqualTo("value")); + assertThat(container.getEnv()) + .filteredOn(env -> "EMPTYVAR".equals(env.getName())) + .singleElement().satisfies(env -> assertThat(env.getValue()).isNullOrEmpty()); assertThat(container.getEnv()) .filteredOn(env -> "QUARKUS_KUBERNETES_CONFIG_ENABLED".equals(env.getName())) .singleElement().satisfies(env -> assertThat(env.getValue()).isEqualTo("true")); diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-new-style-env.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-new-style-env.properties index 966366bd8f608..834d0a80159ad 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-new-style-env.properties +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-new-style-env.properties @@ -1,5 +1,6 @@ quarkus.kubernetes.env.fields.fromfield=metadata.name quarkus.kubernetes.env.vars.envvar=value +quarkus.kubernetes.env.vars.emptyvar= quarkus.kubernetes.env.vars."quarkus.kubernetes-config.enabled"=true quarkus.kubernetes.env.configmaps=configName quarkus.kubernetes.env.secrets=secretName