forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
KnativeDeployer.java
37 lines (32 loc) · 1.61 KB
/
KnativeDeployer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package io.quarkus.kubernetes.deployment;
import static io.quarkus.kubernetes.deployment.Constants.KNATIVE;
import java.util.List;
import java.util.Optional;
import io.fabric8.knative.client.DefaultKnativeClient;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.kubernetes.client.spi.KubernetesClientBuildItem;
import io.quarkus.kubernetes.spi.GeneratedKubernetesResourceBuildItem;
import io.quarkus.kubernetes.spi.KubernetesDeploymentClusterBuildItem;
public class KnativeDeployer {
@BuildStep
public void checkEnvironment(Optional<SelectedKubernetesDeploymentTargetBuildItem> selectedDeploymentTarget,
List<GeneratedKubernetesResourceBuildItem> resources,
KubernetesClientBuildItem client, BuildProducer<KubernetesDeploymentClusterBuildItem> deploymentCluster) {
selectedDeploymentTarget.ifPresent(target -> {
if (!KubernetesDeploy.INSTANCE.checkSilently()) {
return;
}
if (target.getEntry().getName().equals(KNATIVE)) {
try (DefaultKnativeClient knativeClient = client.getClient().adapt(DefaultKnativeClient.class)) {
if (knativeClient.isSupported()) {
deploymentCluster.produce(new KubernetesDeploymentClusterBuildItem(KNATIVE));
} else {
throw new IllegalStateException(
"Knative was requested as a deployment, but the target cluster is not a Knative cluster!");
}
}
}
});
}
}