Skip to content

Commit

Permalink
Allow "install" phase for properties for websocket ports
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Jul 5, 2024
1 parent 33c030e commit 175d640
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
22 changes: 14 additions & 8 deletions src/qz/build/provision/Step.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private Step sanitize() {
.enforcePhase(Type.CERT, Phase.STARTUP)
.enforcePhase(Type.SOFTWARE, Phase.INSTALL)
.enforcePhase(Type.REMOVER, Phase.INSTALL)
.enforcePhase(Type.PROPERTY, Phase.CERTGEN)
.enforcePhase(Type.PROPERTY, Phase.CERTGEN, Phase.INSTALL)
.validateRemover();
}

Expand Down Expand Up @@ -283,15 +283,21 @@ private Step validateArch() {
return this;
}

private Step enforcePhase(Type matchType, Phase requiredPhase) {
private Step enforcePhase(Type matchType, Phase ... requiredPhases) {
if(requiredPhases.length == 0) {
throw new UnsupportedOperationException("At least one Phase must be specified");
}
if(type == matchType) {
if(phase == null) {
phase = requiredPhase;
log.debug("Phase is null, defaulting to '{}' based on Type '{}'", phase, type);
} else if (phase != requiredPhase) {
log.debug("Phase '{}' is unsupported for Type '{}', defaulting to '{}'", phase, type,
phase = requiredPhase);
for(Phase requiredPhase : requiredPhases) {
if (phase == null) {
phase = requiredPhase;
log.debug("Phase is null, defaulting to '{}' based on Type '{}'", phase, type);
return this;
} else if (phase == requiredPhase) {
return this;
}
}
log.debug("Phase '{}' is unsupported for Type '{}', defaulting to '{}'", phase, type, phase = requiredPhases[0]);
}
return this;
}
Expand Down
11 changes: 10 additions & 1 deletion test/qz/installer/provision/resources/provision.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,23 @@
"data": "cert1.crt"
},
{
"description": "[PROPERTY] at 'certgen' (qz-tray.properties)",
"description": "[PROPERTY] at wrong phase (qz-tray.properties)",
"type": "property",
"phase": "startup",
"os": "*",
"data": "foo=bar"
},
{
"description": "[PROPERTY] at 'install' (qz-tray.properties)",
"type": "property",
"phase": "install",
"os": "*",
"data": "websocket.secure.ports=9191,9292,9393,9494"
},
{
"description": "[PROPERTY] at 'certgen' (qz-tray.properties)",
"type": "property",
"phase": "install",
"os": "*",
"data": "websocket.insecure.ports=9192,9293,9394,9495"
},
Expand Down

0 comments on commit 175d640

Please sign in to comment.