Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Knative/OpenShift client environment check #28172

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.List;
import java.util.Optional;

import io.fabric8.knative.client.KnativeClient;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.kubernetes.client.spi.KubernetesClientBuildItem;
Expand All @@ -23,7 +22,8 @@ public void checkEnvironment(Optional<SelectedKubernetesDeploymentTargetBuildIte
return;
}
if (target.getEntry().getName().equals(KNATIVE)) {
if (client.getClient().isAdaptable(KnativeClient.class)) {
// use 'isSupported' once https://github.com/fabric8io/kubernetes-client/issues/4447 is resolved
if (client.getClient().hasApiGroup("knative.dev", false)) {
michalvavrik marked this conversation as resolved.
Show resolved Hide resolved
deploymentCluster.produce(new KubernetesDeploymentClusterBuildItem(KNATIVE));
} else {
throw new IllegalStateException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ public void checkEnvironment(Optional<SelectedKubernetesDeploymentTargetBuildIte
return;
}
if (target.getEntry().getName().equals(OPENSHIFT)) {
if (client.getClient().isAdaptable(OpenShiftClient.class)) {
deploymentCluster.produce(new KubernetesDeploymentClusterBuildItem(OPENSHIFT));
} else {
throw new IllegalStateException(
"Openshift was requested as a deployment, but the target cluster is not an Openshift cluster!");
try (var openShiftClient = client.getClient().adapt(OpenShiftClient.class)) {
if (openShiftClient.isSupported()) {
deploymentCluster.produce(new KubernetesDeploymentClusterBuildItem(OPENSHIFT));
} else {
throw new IllegalStateException(
"Openshift was requested as a deployment, but the target cluster is not an Openshift cluster!");
}
} catch (Exception e) {
throw new RuntimeException(
"Failed to configure OpenShift. Make sure you have the Quarkus OpenShift extension.", e);
}
}
});
Expand Down