From 86f181c414f626dc83bb2b0f8f5b2e0d3211be83 Mon Sep 17 00:00:00 2001 From: Tres Finocchiaro Date: Sun, 7 Jul 2024 12:38:28 -0400 Subject: [PATCH] Move websocket ports back to "certgen" and clone to "install" at ingestion time --- src/qz/build/provision/ProvisionBuilder.java | 17 +++++++++++++++++ src/qz/build/provision/Step.java | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/src/qz/build/provision/ProvisionBuilder.java b/src/qz/build/provision/ProvisionBuilder.java index b13ec8d30..dcc359a5a 100644 --- a/src/qz/build/provision/ProvisionBuilder.java +++ b/src/qz/build/provision/ProvisionBuilder.java @@ -9,10 +9,13 @@ import org.codehaus.jettison.json.JSONObject; import qz.build.provision.params.Arch; import qz.build.provision.params.Os; +import qz.build.provision.params.Phase; import qz.build.provision.params.Type; import qz.build.provision.params.types.Script; import qz.build.provision.params.types.Software; import qz.common.Constants; +import qz.installer.provision.invoker.PropertyInvoker; +import qz.utils.ArgValue; import qz.utils.SystemUtilities; import java.io.File; @@ -20,6 +23,9 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.HashMap; + +import static qz.common.Constants.PROVISION_FILE; public class ProvisionBuilder { protected static final Logger log = LogManager.getLogger(ProvisionBuilder.class); @@ -111,6 +117,17 @@ private void ingestStep(JSONObject jsonStep, Path relativePath) throws JSONExcep if(copyResource(step)) { log.info("[SUCCESS] Step successfully processed '{}'", step); jsonSteps.put(step.toJSON()); + // Special case for custom websocket ports + if(step.getType() == Type.PROPERTY && step.getPhase() == Phase.CERTGEN) { + HashMap pairs = PropertyInvoker.parsePropertyPairs(step); + if(pairs.get(ArgValue.WEBSOCKET_SECURE_PORTS.getMatch()) != null || + pairs.get(ArgValue.WEBSOCKET_INSECURE_PORTS.getMatch()) != null) { + + } + // Clone to install step + jsonSteps.put(step.cloneTo(Phase.INSTALL).toJSON()); + } + } else { log.error("[SKIPPED] Resources could not be saved '{}'", step); } diff --git a/src/qz/build/provision/Step.java b/src/qz/build/provision/Step.java index 8717001f8..fb21656e7 100644 --- a/src/qz/build/provision/Step.java +++ b/src/qz/build/provision/Step.java @@ -306,4 +306,9 @@ private static UnsupportedOperationException formatted(String message, Object .. String formatted = String.format(message, args); return new UnsupportedOperationException(formatted); } + Step cloneTo(Phase phase) { + return relativePath != null ? + new Step(relativePath, description, type, os, arch, phase, data, args) : + new Step(relativeClass, description, type, os, arch, phase, data, args); + } }