Skip to content

Commit

Permalink
Merge pull request #30008 from iocanel/broken-openshift-deployer
Browse files Browse the repository at this point in the history
Fix handling of deployment target when using quarkus-openshift
  • Loading branch information
geoand authored Jan 5, 2023
2 parents c3aa25b + 9dafe22 commit 8ddf9f3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class KnativeProcessor {
public void checkKnative(ApplicationInfoBuildItem applicationInfo, KnativeConfig config,
BuildProducer<KubernetesDeploymentTargetBuildItem> deploymentTargets,
BuildProducer<KubernetesResourceMetadataBuildItem> resourceMeta) {
List<String> targets = KubernetesConfigUtil.getUserSpecifiedDeploymentTargets();
List<String> targets = KubernetesConfigUtil.getConfiguratedDeploymentTargets();
boolean knativeEnabled = targets.contains(KNATIVE);
deploymentTargets.produce(
new KubernetesDeploymentTargetBuildItem(KNATIVE, KNATIVE_SERVICE, KNATIVE_SERVICE_GROUP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,21 @@ public class KubernetesConfigUtil {

private static final Logger log = Logger.getLogger(KubernetesConfigUtil.class);

public static List<String> getUserSpecifiedDeploymentTargets() {
String deploymentTargets = getConfiguredDeploymentTarget().orElse("");
/**
* Get the explicit configured deployment target, if any.
* The explicit deployment target is determined using: `quarkus.kubernetes.deployment-target=<deployment-target>`
*/
public static Optional<String> 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=<deployment-target>`
*/
public static List<String> getExplictilyDeploymentTargets() {
String deploymentTargets = getExplicitlyConfiguredDeploymentTarget().orElse("");
if (deploymentTargets.isEmpty()) {
return Collections.emptyList();
}
Expand Down Expand Up @@ -71,7 +84,25 @@ public static Optional<String> 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=<deployment-target>`
* 2. the presenve of `quarkus.<deployment-target>.deploy=true`
*/
public static List<String> 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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private DeploymentTargetEntry determineDeploymentTarget(

boolean checkForMissingRegistry = true;
boolean checkForNamespaceGroupAlignment = false;
List<String> userSpecifiedDeploymentTargets = KubernetesConfigUtil.getUserSpecifiedDeploymentTargets();
List<String> userSpecifiedDeploymentTargets = KubernetesConfigUtil.getExplictilyDeploymentTargets();
if (userSpecifiedDeploymentTargets.isEmpty()) {
selectedTarget = targets.getEntriesSortedByPriority().get(0);
if (targets.getEntriesSortedByPriority().size() > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class OpenshiftProcessor {
public void checkOpenshift(ApplicationInfoBuildItem applicationInfo, Capabilities capabilities, OpenshiftConfig config,
BuildProducer<KubernetesDeploymentTargetBuildItem> deploymentTargets,
BuildProducer<KubernetesResourceMetadataBuildItem> resourceMeta) {
List<String> targets = KubernetesConfigUtil.getUserSpecifiedDeploymentTargets();
List<String> targets = KubernetesConfigUtil.getConfiguratedDeploymentTargets();
boolean openshiftEnabled = targets.contains(OPENSHIFT);

DeploymentResourceKind deploymentResourceKind = config.getDeploymentResourceKind(capabilities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void checkVanillaKubernetes(ApplicationInfoBuildItem applicationInfo, Cap
BuildProducer<KubernetesResourceMetadataBuildItem> resourceMeta) {
String kind = config.getDeploymentResourceKind(capabilities).kind;

List<String> userSpecifiedDeploymentTargets = KubernetesConfigUtil.getUserSpecifiedDeploymentTargets();
List<String> userSpecifiedDeploymentTargets = KubernetesConfigUtil.getConfiguratedDeploymentTargets();
if (userSpecifiedDeploymentTargets.isEmpty() || userSpecifiedDeploymentTargets.contains(KUBERNETES)) {
// when nothing was selected by the user, we enable vanilla Kubernetes by
// default
Expand Down

0 comments on commit 8ddf9f3

Please sign in to comment.