Skip to content

Commit 23ff701

Browse files
jshum2479ddsharpe
authored andcommitted
enable multiple archives in WDT command line (#101)
1 parent 1a701a8 commit 23ff701

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/ImageOperation.java

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -348,19 +348,9 @@ List<String> handleWdtArgsIfRequired(String tmpDir) throws IOException {
348348
if (wdtModelPath != null) {
349349
dockerfileOptions.setWdtEnabled();
350350
dockerfileOptions.setWdtModelOnly(wdtModelOnly);
351-
String[] modelFiles = wdtModelPath.toString().split(",");
352-
List<String> modelList = new ArrayList<>();
353-
354-
for (String modelFile : modelFiles) {
355-
Path modelFilePath = Paths.get(modelFile);
356-
if (Files.isRegularFile(modelFilePath)) {
357-
String modelFilename = modelFilePath.getFileName().toString();
358-
Files.copy(modelFilePath, Paths.get(tmpDir, modelFilename));
359-
modelList.add(modelFilename);
360-
} else {
361-
throw new IOException("WDT model file " + modelFile + " not found");
362-
}
363-
}
351+
352+
List<String> modelList = addWDTFilesAsList(wdtModelPath, "model", tmpDir);
353+
364354
dockerfileOptions.setWdtModels(modelList);
365355

366356
dockerfileOptions.setWdtDomainType(wdtDomainType);
@@ -371,11 +361,11 @@ List<String> handleWdtArgsIfRequired(String tmpDir) throws IOException {
371361
dockerfileOptions.setRunRcu(runRcu);
372362
}
373363

374-
if (wdtArchivePath != null && Files.isRegularFile(wdtArchivePath)) {
375-
String wdtArchiveFilename = wdtArchivePath.getFileName().toString();
376-
Files.copy(wdtArchivePath, Paths.get(tmpDir, wdtArchiveFilename));
377-
//Until WDT supports multiple archives, take single file argument from CLI and convert to list
378-
dockerfileOptions.setWdtArchives(Collections.singletonList(wdtArchiveFilename));
364+
if (wdtArchivePath != null) {
365+
366+
List<String> archiveList = addWDTFilesAsList(wdtArchivePath, "archive", tmpDir);
367+
368+
dockerfileOptions.setWdtArchives(archiveList);
379369
}
380370
dockerfileOptions.setDomainHome(wdtDomainHome);
381371

@@ -394,6 +384,24 @@ List<String> handleWdtArgsIfRequired(String tmpDir) throws IOException {
394384
return retVal;
395385
}
396386

387+
private List<String> addWDTFilesAsList(Path fileArg, String type, String tmpDir) throws IOException {
388+
String[] listOfFiles = fileArg.toString().split(",");
389+
List<String> fileList = new ArrayList<>();
390+
391+
for (String individualFile : listOfFiles) {
392+
Path individualPath = Paths.get(individualFile);
393+
if (Files.isRegularFile(individualPath)) {
394+
String modelFilename = individualPath.getFileName().toString();
395+
Files.copy(individualPath, Paths.get(tmpDir, modelFilename));
396+
fileList.add(modelFilename);
397+
} else {
398+
String errMsg = String.format("WDT %s file %s not found ", type, individualFile);
399+
throw new IOException(errMsg);
400+
}
401+
}
402+
return fileList;
403+
}
404+
397405
/**
398406
* Parses wdtVersion and constructs the url to download WDT and adds the url to cache.
399407
*

0 commit comments

Comments
 (0)