diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeProcessor.java index 4521092657436..5dbdae6a96256 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeProcessor.java @@ -84,7 +84,7 @@ public class KnativeProcessor { public void checkKnative(ApplicationInfoBuildItem applicationInfo, KnativeConfig config, BuildProducer deploymentTargets, BuildProducer resourceMeta) { - List targets = KubernetesConfigUtil.getUserSpecifiedDeploymentTargets(); + List targets = KubernetesConfigUtil.getConfiguratedDeploymentTargets(); boolean knativeEnabled = targets.contains(KNATIVE); deploymentTargets.produce( new KubernetesDeploymentTargetBuildItem(KNATIVE, KNATIVE_SERVICE, KNATIVE_SERVICE_GROUP, diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfigUtil.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfigUtil.java index 94ff4dbc039bb..0208f3f9f69cb 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfigUtil.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfigUtil.java @@ -42,8 +42,21 @@ public class KubernetesConfigUtil { private static final Logger log = Logger.getLogger(KubernetesConfigUtil.class); - public static List getUserSpecifiedDeploymentTargets() { - String deploymentTargets = getConfiguredDeploymentTarget().orElse(""); + /** + * Get the explicit configured deployment target, if any. + * The explicit deployment target is determined using: `quarkus.kubernetes.deployment-target=` + */ + public static Optional getExplicitlyConfiguredDeploymentTarget() { + Config config = ConfigProvider.getConfig(); + return config.getOptionalValue(DEPLOYMENT_TARGET, String.class); + } + + /** + * The the explicitly configured deployment target list. + * The configured deployment targets are determined using: `quarkus.kubernetes.deployment-target=` + */ + public static List getExplictilyDeploymentTargets() { + String deploymentTargets = getExplicitlyConfiguredDeploymentTarget().orElse(""); if (deploymentTargets.isEmpty()) { return Collections.emptyList(); } @@ -71,7 +84,25 @@ public static Optional getConfiguredDeploymentTarget() { .filter(s -> s != null) .findFirst(); - return config.getOptionalValue(DEPLOYMENT_TARGET, String.class).or(() -> indirectTarget); + return getExplicitlyConfiguredDeploymentTarget().or(() -> indirectTarget); + } + + /** + * The the configured deployment target list. + * The configured deployment targets are determined using: + * 1. the value of `quarkus.kubernetes.deployment-target=` + * 2. the presenve of `quarkus..deploy=true` + */ + public static List getConfiguratedDeploymentTargets() { + String deploymentTargets = getConfiguredDeploymentTarget().orElse(""); + if (deploymentTargets.isEmpty()) { + return Collections.emptyList(); + } + return Arrays.stream(deploymentTargets + .split(",")) + .map(String::trim) + .map(String::toLowerCase) + .collect(Collectors.toList()); } /** diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java index afff125908f2a..3dcab91d48a0c 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java @@ -154,7 +154,7 @@ private DeploymentTargetEntry determineDeploymentTarget( boolean checkForMissingRegistry = true; boolean checkForNamespaceGroupAlignment = false; - List userSpecifiedDeploymentTargets = KubernetesConfigUtil.getUserSpecifiedDeploymentTargets(); + List userSpecifiedDeploymentTargets = KubernetesConfigUtil.getExplictilyDeploymentTargets(); if (userSpecifiedDeploymentTargets.isEmpty()) { selectedTarget = targets.getEntriesSortedByPriority().get(0); if (targets.getEntriesSortedByPriority().size() > 1) { diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java index ab4d53a5e0af4..2fc01290b51a9 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java @@ -73,7 +73,7 @@ public class OpenshiftProcessor { public void checkOpenshift(ApplicationInfoBuildItem applicationInfo, Capabilities capabilities, OpenshiftConfig config, BuildProducer deploymentTargets, BuildProducer resourceMeta) { - List targets = KubernetesConfigUtil.getUserSpecifiedDeploymentTargets(); + List targets = KubernetesConfigUtil.getConfiguratedDeploymentTargets(); boolean openshiftEnabled = targets.contains(OPENSHIFT); DeploymentResourceKind deploymentResourceKind = config.getDeploymentResourceKind(capabilities); diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VanillaKubernetesProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VanillaKubernetesProcessor.java index 536ef3f2d35f2..60e5fc20c28e1 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VanillaKubernetesProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VanillaKubernetesProcessor.java @@ -64,7 +64,7 @@ public void checkVanillaKubernetes(ApplicationInfoBuildItem applicationInfo, Cap BuildProducer resourceMeta) { String kind = config.getDeploymentResourceKind(capabilities).kind; - List userSpecifiedDeploymentTargets = KubernetesConfigUtil.getUserSpecifiedDeploymentTargets(); + List userSpecifiedDeploymentTargets = KubernetesConfigUtil.getConfiguratedDeploymentTargets(); if (userSpecifiedDeploymentTargets.isEmpty() || userSpecifiedDeploymentTargets.contains(KUBERNETES)) { // when nothing was selected by the user, we enable vanilla Kubernetes by // default