Skip to content

Commit bbfd3c6

Browse files
authored
disable WDT domain type validation to allow custom WDT domain types (#120)
* disable WDT domain type validation to allow custom WDT domain types to be used. * removed unused import
1 parent b4d2a78 commit bbfd3c6

File tree

4 files changed

+8
-95
lines changed

4 files changed

+8
-95
lines changed

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

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.nio.file.Paths;
1010
import java.util.ArrayList;
1111
import java.util.Collections;
12-
import java.util.LinkedList;
1312
import java.util.List;
1413

1514
import com.oracle.weblogic.imagetool.api.model.CachedFile;
@@ -19,10 +18,7 @@
1918
import com.oracle.weblogic.imagetool.cachestore.CacheStoreFactory;
2019
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
2120
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
22-
import com.oracle.weblogic.imagetool.util.Constants;
2321
import com.oracle.weblogic.imagetool.util.DockerfileOptions;
24-
import com.oracle.weblogic.imagetool.util.HttpUtil;
25-
import com.oracle.weblogic.imagetool.wdt.DomainType;
2622
import picocli.CommandLine.Option;
2723

2824
public class WdtOptions {
@@ -50,12 +46,7 @@ void handleWdtArgsIfRequired(DockerfileOptions dockerfileOptions, String tmpDir,
5046
dockerfileOptions.setWdtModels(modelList);
5147

5248
dockerfileOptions.setWdtDomainType(wdtDomainType);
53-
if (wdtDomainType != DomainType.WLS) {
54-
if (installerType != FmwInstallerType.FMW) {
55-
throw new IOException("FMW installer is required for JRF domain");
56-
}
57-
dockerfileOptions.setRunRcu(runRcu);
58-
}
49+
dockerfileOptions.setRunRcu(runRcu);
5950

6051
if (wdtArchivePath != null) {
6152

@@ -83,52 +74,6 @@ void handleWdtArgsIfRequired(DockerfileOptions dockerfileOptions, String tmpDir,
8374
logger.exiting();
8475
}
8576

86-
/**
87-
* Builds a list of {@link CachedFile} objects based on user input which are processed.
88-
* to download the required install artifacts
89-
*
90-
* @return list of CachedFile
91-
* @throws Exception in case of error
92-
*/
93-
public List<CachedFile> gatherWdtRequiredInstallers() throws Exception {
94-
logger.entering();
95-
List<CachedFile> result = new LinkedList<>();
96-
if (wdtModelPath != null) {
97-
logger.finer("IMG-0001", InstallerType.WDT, wdtVersion);
98-
CachedFile wdtInstaller = new CachedFile(InstallerType.WDT, wdtVersion);
99-
result.add(wdtInstaller);
100-
addWdtUrl(wdtInstaller.getKey(), cacheStore, wdtVersion);
101-
}
102-
logger.exiting(result.size());
103-
return result;
104-
}
105-
106-
public CachedFile getWdtInstaller() {
107-
return new CachedFile(InstallerType.WDT, wdtVersion);
108-
}
109-
110-
private void addWdtUrl(String wdtKey, CacheStore cacheStore, String wdtVersion) throws Exception {
111-
logger.entering(wdtKey);
112-
String wdtUrlKey = wdtKey + "_url";
113-
if (cacheStore.getValueFromCache(wdtKey) == null) {
114-
//if (userId == null || password == null) {
115-
// throw new Exception("CachePolicy prohibits download. Add the required wdt installer to cache");
116-
//}
117-
List<String> wdtTags = HttpUtil.getWDTTags();
118-
String tagToMatch = "latest".equalsIgnoreCase(wdtVersion) ? wdtTags.get(0) :
119-
"weblogic-deploy-tooling-" + wdtVersion;
120-
if (wdtTags.contains(tagToMatch)) {
121-
String downloadLink = String.format(Constants.WDT_URL_FORMAT, tagToMatch);
122-
logger.info("IMG-0007", downloadLink);
123-
cacheStore.addToCache(wdtUrlKey, downloadLink);
124-
} else {
125-
throw new Exception("Couldn't find WDT download url for version:" + wdtVersion);
126-
}
127-
}
128-
logger.exiting();
129-
}
130-
131-
13277
private List<String> addWdtFilesAsList(Path fileArg, String type, String tmpDir) throws IOException {
13378
String[] listOfFiles = fileArg.toString().split(",");
13479
List<String> fileList = new ArrayList<>();
@@ -148,10 +93,6 @@ private List<String> addWdtFilesAsList(Path fileArg, String type, String tmpDir)
14893
}
14994

15095

151-
public DomainType getWdtDomainType() {
152-
return wdtDomainType;
153-
}
154-
15596
@Option(
15697
names = {"--wdtModel"},
15798
description = "path to the WDT model file that defines the Domain to create"
@@ -179,9 +120,10 @@ public DomainType getWdtDomainType() {
179120

180121
@Option(
181122
names = {"--wdtDomainType"},
182-
description = "WDT Domain Type. Default: WLS. Supported values: ${COMPLETION-CANDIDATES}"
123+
description = "WDT Domain Type (-domain_type). Default: WLS. Supported values: WLS, JRF, or RestrictedJRF"
183124
)
184-
private DomainType wdtDomainType = DomainType.WLS;
125+
@SuppressWarnings("FieldCanBeLocal")
126+
private String wdtDomainType = "WLS";
185127

186128
@Option(
187129
names = "--wdtRunRCU",

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/DockerfileOptions.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import com.oracle.weblogic.imagetool.installer.MiddlewareInstall;
1313
import com.oracle.weblogic.imagetool.installer.MiddlewareInstallPackage;
14-
import com.oracle.weblogic.imagetool.wdt.DomainType;
1514
import com.oracle.weblogic.imagetool.wdt.WdtOperation;
1615

1716
public class DockerfileOptions {
@@ -57,7 +56,7 @@ public class DockerfileOptions {
5756
private ArrayList<String> wdtArchiveList;
5857
private ArrayList<String> wdtVariableList;
5958
private WdtOperation wdtOperation;
60-
private DomainType wdtDomainType;
59+
private String wdtDomainType;
6160
private String wdtJavaOptions;
6261
private boolean wdtModelOnly;
6362
private boolean wdtRunRcu;
@@ -645,15 +644,15 @@ public DockerfileOptions setWdtCommand(WdtOperation value) {
645644
*/
646645
@SuppressWarnings("unused")
647646
public String domainType() {
648-
return wdtDomainType.name();
647+
return wdtDomainType;
649648
}
650649

651650
/**
652651
* Set the desired WDT domain type parameter.
653652
*
654653
* @param value WLS, JRF, ...
655654
*/
656-
public DockerfileOptions setWdtDomainType(DomainType value) {
655+
public DockerfileOptions setWdtDomainType(String value) {
657656
wdtDomainType = value;
658657
return this;
659658
}

imagetool/src/test/java/com/oracle/weblogic/imagetool/api/model/DomainTypeTest.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

imagetool/src/test/java/com/oracle/weblogic/imagetool/util/DockerfileBuilderTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import com.github.mustachejava.MustacheFactory;
1414
import com.oracle.weblogic.imagetool.api.model.FmwInstallerType;
1515
import com.oracle.weblogic.imagetool.installer.MiddlewareInstall;
16-
import com.oracle.weblogic.imagetool.wdt.DomainType;
1716
import org.junit.Test;
1817

1918
import static org.junit.Assert.assertTrue;
@@ -32,7 +31,7 @@ public void validateMustacheAliases() throws IOException {
3231
.setPatchingEnabled()
3332
.setOPatchPatchingEnabled()
3433
.setWdtEnabled()
35-
.setWdtDomainType(DomainType.WLS)
34+
.setWdtDomainType("WLS")
3635
.setWdtModels(Arrays.asList("model1.yaml", "model2.yaml"))
3736
.setPackageInstaller(Constants.YUM)
3837
.setMiddlewareInstall(install);

0 commit comments

Comments
 (0)