Skip to content

Commit

Permalink
Merge pull request #71 from jfdenise/main
Browse files Browse the repository at this point in the history
No OpenShift deployment if no deployment provided
  • Loading branch information
jfdenise authored Apr 26, 2024
2 parents 27a094d + d3b7539 commit c97f99d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ public Integer call() throws Exception {
}
if (OutputFormat.OPENSHIFT.equals(provision.get())) {
OpenShiftSupport.deploy(deployments,
"app-from-glow",
GlowMessageWriter.DEFAULT,
target,
scanResults,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ static final String generateValidName(String name) {
}

public static void deploy(List<Path> deployments,
String defaultName,
GlowMessageWriter writer,
Path target,
ScanResults scanResults,
Expand All @@ -351,16 +350,21 @@ public static void deploy(List<Path> deployments,
Set<Layer> metadataOnlyLayers = scanResults.getMetadataOnlyLayers();
Map<Layer, Set<Env>> requiredBuildTime = scanResults.getSuggestions().getBuildTimeRequiredConfigurations();
String appName = "";
Path deploymentsDir = target.resolve("deployments");
Files.createDirectories(deploymentsDir);
for (Path p : deployments) {
Files.copy(p, deploymentsDir.resolve(p.getFileName()));
int ext = p.getFileName().toString().lastIndexOf(".");
appName += p.getFileName().toString().substring(0, ext);
appName = generateValidName(appName);
}
if (appName.isEmpty()) {
appName = defaultName;
String originalAppName = null;
if (deployments != null && !deployments.isEmpty()) {
Path deploymentsDir = target.resolve("deployments");
Files.createDirectories(deploymentsDir);
for (Path p : deployments) {
Files.copy(p, deploymentsDir.resolve(p.getFileName()));
int ext = p.getFileName().toString().lastIndexOf(".");
appName += p.getFileName().toString().substring(0, ext);
if (originalAppName == null) {
originalAppName = appName;
}
appName = generateValidName(appName);
}
} else {
throw new Exception("No application to deploy to OpenShift");
}
Map<String, String> env = new HashMap<>();
for (Set<Env> envs : scanResults.getSuggestions().getStronglySuggestedConfigurations().values()) {
Expand Down Expand Up @@ -448,7 +452,7 @@ public static void deploy(List<Path> deployments,
createBuild(writer, target, osClient, appName, initScript, cliScript, actualBuildEnv, config, serverImageBuildLabels);
writer.info("Deploying application image on OpenShift");
createAppDeployment(writer, target, osClient, appName, actualEnv, ha, config, deploymentKind);
writer.info("Application route: https://" + host + ("ROOT.war".equals(appName) ? "" : "/" + appName));
writer.info("Application route: https://" + host + ( "ROOT.war".equals(appName) ? "" : "/" + originalAppName));
}

private static void createBuild(GlowMessageWriter writer,
Expand Down

0 comments on commit c97f99d

Please sign in to comment.