diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/devconsole/KubernetesDevConsoleProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/devui/KubernetesDevUIProcessor.java similarity index 69% rename from extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/devconsole/KubernetesDevConsoleProcessor.java rename to extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/devui/KubernetesDevUIProcessor.java index b454a7f41b9db..9ca45e477528d 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/devconsole/KubernetesDevConsoleProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/devui/KubernetesDevUIProcessor.java @@ -1,7 +1,8 @@ -package io.quarkus.kubernetes.deployment.devconsole; +package io.quarkus.kubernetes.deployment.devui; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; @@ -11,43 +12,48 @@ import io.quarkus.bootstrap.app.CuratedApplication; import io.quarkus.bootstrap.app.QuarkusBootstrap; import io.quarkus.builder.BuildResult; -import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.IsDevelopment; import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem; import io.quarkus.dev.console.DevConsoleManager; -import io.quarkus.devconsole.spi.DevConsoleTemplateInfoBuildItem; +import io.quarkus.devui.spi.JsonRPCProvidersBuildItem; +import io.quarkus.devui.spi.page.CardPageBuildItem; +import io.quarkus.devui.spi.page.Page; import io.quarkus.kubernetes.deployment.SelectedKubernetesDeploymentTargetBuildItem; +import io.quarkus.kubernetes.runtime.devui.KubernetesManifestService; import io.quarkus.kubernetes.spi.GeneratedKubernetesResourceBuildItem; -public class KubernetesDevConsoleProcessor { - +public class KubernetesDevUIProcessor { static volatile List manifests; static final Holder holder = new Holder(); - @BuildStep - void builder(BuildProducer infos) { - manifests = null; // ensures that the manifests are re-generated when a live-load is performed - infos.produce(new DevConsoleTemplateInfoBuildItem("holder", holder)); - } + @BuildStep(onlyIf = IsDevelopment.class) + CardPageBuildItem create(CurateOutcomeBuildItem bi) { + CardPageBuildItem pageBuildItem = new CardPageBuildItem(); + pageBuildItem.addPage(Page.webComponentPageBuilder() + .title("Kubernetes Manifests") + .componentLink("qwc-kubernetes-manifest.js") + .icon("font-awesome-solid:rocket")); - public static class GeneratedKubernetesResourceHandler implements BiConsumer, BuildResult> { - @Override - public void accept(Map context, BuildResult buildResult) { - // the idea here is to only display the content of the manifest file that will be selected for deployment - var selectedTargetBI = buildResult - .consumeOptional(SelectedKubernetesDeploymentTargetBuildItem.class); - if (selectedTargetBI == null) { - return; - } + return pageBuildItem; + } - var generatedFilesBI = buildResult - .consumeMulti(GeneratedKubernetesResourceBuildItem.class); - for (var bi : generatedFilesBI) { - if (bi.getName().startsWith(selectedTargetBI.getEntry().getName()) - && bi.getName().endsWith(".yml")) { - context.put(bi.getName(), bi.getContent()); + @BuildStep(onlyIf = IsDevelopment.class) + JsonRPCProvidersBuildItem createJsonRPCServiceForCache() { + DevConsoleManager.register("kubernetes-generate-manifest", ignored -> { + try { + List manifests = holder.getManifests(); + // Avoid relying on databind. + Map map = new LinkedHashMap<>(); + for (Manifest manifest : manifests) { + map.put(manifest.getName(), manifest.getContent()); } + return map; + } catch (Exception e) { + throw new RuntimeException(e); } - } + }); + return new JsonRPCProvidersBuildItem(KubernetesManifestService.class); } public static final class Holder { @@ -78,6 +84,27 @@ public List getManifests() throws BootstrapException { } } + public static class GeneratedKubernetesResourceHandler implements BiConsumer, BuildResult> { + @Override + public void accept(Map context, BuildResult buildResult) { + // the idea here is to only display the content of the manifest file that will be selected for deployment + var selectedTargetBI = buildResult + .consumeOptional(SelectedKubernetesDeploymentTargetBuildItem.class); + if (selectedTargetBI == null) { + return; + } + + var generatedFilesBI = buildResult + .consumeMulti(GeneratedKubernetesResourceBuildItem.class); + for (var bi : generatedFilesBI) { + if (bi.getName().startsWith(selectedTargetBI.getEntry().getName()) + && bi.getName().endsWith(".yml")) { + context.put(bi.getName(), bi.getContent()); + } + } + } + } + public static final class Manifest { private final String name; private final String content; diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/devui/KubernetesDevUiProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/devui/KubernetesDevUiProcessor.java deleted file mode 100644 index 3af5513d3173a..0000000000000 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/devui/KubernetesDevUiProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -package io.quarkus.kubernetes.deployment.devui; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import io.quarkus.deployment.IsDevelopment; -import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem; -import io.quarkus.dev.console.DevConsoleManager; -import io.quarkus.devui.spi.JsonRPCProvidersBuildItem; -import io.quarkus.devui.spi.page.CardPageBuildItem; -import io.quarkus.devui.spi.page.Page; -import io.quarkus.kubernetes.deployment.devconsole.KubernetesDevConsoleProcessor; -import io.quarkus.kubernetes.runtime.devui.KubernetesManifestService; - -public class KubernetesDevUiProcessor { - - static final KubernetesDevConsoleProcessor.Holder holder = new KubernetesDevConsoleProcessor.Holder(); - - @BuildStep(onlyIf = IsDevelopment.class) - CardPageBuildItem create(CurateOutcomeBuildItem bi) { - CardPageBuildItem pageBuildItem = new CardPageBuildItem(); - pageBuildItem.addPage(Page.webComponentPageBuilder() - .title("Kubernetes Manifests") - .componentLink("qwc-kubernetes-manifest.js") - .icon("font-awesome-solid:rocket")); - - return pageBuildItem; - } - - @BuildStep(onlyIf = IsDevelopment.class) - JsonRPCProvidersBuildItem createJsonRPCServiceForCache() { - DevConsoleManager.register("kubernetes-generate-manifest", ignored -> { - try { - List manifests = holder.getManifests(); - // Avoid relying on databind. - Map map = new LinkedHashMap<>(); - for (KubernetesDevConsoleProcessor.Manifest manifest : manifests) { - map.put(manifest.getName(), manifest.getContent()); - } - return map; - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - return new JsonRPCProvidersBuildItem(KubernetesManifestService.class); - } -} diff --git a/extensions/kubernetes/vanilla/deployment/src/main/resources/dev-templates/embedded.html b/extensions/kubernetes/vanilla/deployment/src/main/resources/dev-templates/embedded.html deleted file mode 100644 index c98aab7f5c860..0000000000000 --- a/extensions/kubernetes/vanilla/deployment/src/main/resources/dev-templates/embedded.html +++ /dev/null @@ -1,3 +0,0 @@ - - - Kubernetes Manifests diff --git a/extensions/kubernetes/vanilla/deployment/src/main/resources/dev-templates/manifests.html b/extensions/kubernetes/vanilla/deployment/src/main/resources/dev-templates/manifests.html deleted file mode 100644 index 9239ee1b9412f..0000000000000 --- a/extensions/kubernetes/vanilla/deployment/src/main/resources/dev-templates/manifests.html +++ /dev/null @@ -1,41 +0,0 @@ -{#include main fluid=true} -{#title}Kubernetes Manifests{/title} -{#styleref} - -{/styleref} -{#scriptref} - - - -{/scriptref} -{#script} - var editor = CodeMirror.fromTextArea(document.getElementById("code"), { - mode: "yaml", - readOnly: true, - styleActiveLine: true, - lineNumbers: true, - lineWrapping: true, - }); - editor.setSize("100%", "100%"); -{/script} -{#body} - -{#for manifest in info:holder.manifests.orEmpty} - - -
-
-
-
- {manifest.name} -
-
- -
-
-
-
-
-{/for} -{/body} -{/include}