-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23052 from ioforks/issue-21311
Ιmprove k8s deployment errors related to target platform
- Loading branch information
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...tes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesDeploymentClusterBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
package io.quarkus.kubernetes.spi; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
public final class KubernetesDeploymentClusterBuildItem extends MultiBuildItem { | ||
|
||
private final String kind; | ||
|
||
public KubernetesDeploymentClusterBuildItem(String kind) { | ||
this.kind = kind; | ||
} | ||
|
||
public String getKind() { | ||
return kind; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...es/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeDeployer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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.KnativeClient; | ||
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)) { | ||
if (client.getClient().isAdaptable(KnativeClient.class)) { | ||
deploymentCluster.produce(new KubernetesDeploymentClusterBuildItem(KNATIVE)); | ||
} else { | ||
throw new IllegalStateException( | ||
"Knative was requested as a deployment, but the target cluster is not a Knative cluster!"); | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
.../vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftDeployer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
package io.quarkus.kubernetes.deployment; | ||
|
||
import static io.quarkus.kubernetes.deployment.Constants.OPENSHIFT; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import io.fabric8.openshift.client.OpenShiftClient; | ||
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 OpenshiftDeployer { | ||
|
||
@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(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!"); | ||
} | ||
} | ||
}); | ||
} | ||
} |