From cb6fff44c07a319ace4f66985a8d7dc92d27bd68 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 9 Mar 2021 09:41:22 +0200 Subject: [PATCH] Don't run Kubernetes manifest generation in tests In tests, various Build Items are population with the proper values (like the output target), so it's best to not run the Kubernetes manifest generation at all in order to avoid getting NPEs Fixes: #15555 --- .../quarkus/kubernetes/deployment/KubernetesProcessor.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 80271ffa20495..e1fe9b8fc5e92 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 @@ -32,6 +32,7 @@ import io.dekorate.utils.Strings; import io.quarkus.deployment.Capabilities; import io.quarkus.deployment.Feature; +import io.quarkus.deployment.IsTest; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.ApplicationInfoBuildItem; @@ -75,7 +76,7 @@ public EnabledKubernetesDeploymentTargetsBuildItem enabledKubernetesDeploymentTa return new EnabledKubernetesDeploymentTargetsBuildItem(entries); } - @BuildStep + @BuildStep(onlyIfNot = IsTest.class) public void build(ApplicationInfoBuildItem applicationInfo, OutputTargetBuildItem outputTarget, PackageConfig packageConfig, @@ -92,9 +93,6 @@ public void build(ApplicationInfoBuildItem applicationInfo, List allConfigurators = new ArrayList<>(configurators); List allDecorators = new ArrayList<>(decorators); - if (launchMode.getLaunchMode() == LaunchMode.TEST) { - return; - } if (kubernetesPorts.isEmpty()) { log.debug("The service is not an HTTP service so no Kubernetes manifests will be generated");