Skip to content

Commit 50f17da

Browse files
authored
Added new feature to create auxiliary image (#322)
* Added CreateAuxImage menu option to create WDT files image * added option to set WDT home location to override /auxiliary * refactor code for createAuxImage to remove duplicate code blocks * added integration test for CreateAuxImage * static code cleanup * allow image inspect to run on busybox images * use default overrides for --fromImage option * tweaks to option descriptions based on review comments * changed integration test to use actual permission string so build can be debugged * update WDT option descriptions * use default overrides for --wdtHome option
1 parent 7a0d98e commit 50f17da

26 files changed

+1259
-863
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/builder/BuildCommand.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@ public BuildCommand(String buildEngine, String contextFolder) {
4444
context = contextFolder;
4545
}
4646

47-
/**
48-
* If Docker is not on the user's path, set the full path to the executable.
49-
* @param value full path to Docker
50-
* @deprecated use --builder instead
51-
*/
52-
@Deprecated
53-
public void dockerPath(String value) {
54-
command.set(0, value);
55-
}
56-
5747
/**
5848
* Add Docker image tag name for this build command.
5949
* @param value name to be used as the image tag.

imagetool/src/main/java/com/oracle/weblogic/imagetool/cachestore/OPatchFile.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ public static OPatchFile getInstance(String patchId, String userid, String passw
6767
}
6868
}
6969

70-
// For the OPatch use case, only the provided version (--opatchBugNumber) is used to "select" a patch.
71-
// selectPatch will return null if there is more than one patch in the patches list.
72-
//AruPatch selectedPatch = AruPatch.selectPatch(patches, providedVersion, null, null);
73-
7470
AruPatch selectedPatch;
7571
if (patches.isEmpty()) {
7672
throw new NoPatchesFoundException(Utils.getMessage("IMG-0057", patchNumber));

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/ImageTool.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.oracle.weblogic.imagetool.api.model.CommandResponse;
99
import com.oracle.weblogic.imagetool.cli.cache.CacheCLI;
10+
import com.oracle.weblogic.imagetool.cli.menu.CreateAuxImage;
1011
import com.oracle.weblogic.imagetool.cli.menu.CreateImage;
1112
import com.oracle.weblogic.imagetool.cli.menu.InspectImage;
1213
import com.oracle.weblogic.imagetool.cli.menu.RebaseImage;
@@ -28,6 +29,7 @@
2829
subcommands = {
2930
CacheCLI.class,
3031
CreateImage.class,
32+
CreateAuxImage.class,
3133
UpdateImage.class,
3234
RebaseImage.class,
3335
InspectImage.class

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/cache/AddPatchEntry.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
package com.oracle.weblogic.imagetool.cli.cache;
55

6-
import java.util.ArrayList;
7-
import java.util.List;
6+
import java.util.Collections;
87

98
import com.oracle.weblogic.imagetool.api.model.CommandResponse;
109
import com.oracle.weblogic.imagetool.util.Utils;
@@ -20,16 +19,15 @@ public class AddPatchEntry extends CacheAddOperation {
2019

2120
@Override
2221
public CommandResponse call() throws Exception {
23-
24-
if (patchId != null && !patchId.isEmpty()) {
25-
List<String> patches = new ArrayList<>();
26-
patches.add(patchId);
27-
if (!Utils.validatePatchIds(patches, true)) {
28-
return CommandResponse.error("Patch ID validation failed");
22+
try {
23+
if (patchId != null && !patchId.isEmpty()) {
24+
Utils.validatePatchIds(Collections.singletonList(patchId), true);
25+
return addToCache(patchId);
26+
} else {
27+
return CommandResponse.error("IMG-0076", "--patchId");
2928
}
30-
return addToCache(patchId);
31-
} else {
32-
return CommandResponse.error("IMG-0076", "--patchId");
29+
} catch (Exception ex) {
30+
return CommandResponse.error(ex.getMessage());
3331
}
3432
}
3533

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
// Copyright (c) 2021, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package com.oracle.weblogic.imagetool.cli.menu;
5+
6+
import java.io.IOException;
7+
import java.nio.file.Path;
8+
import java.nio.file.Paths;
9+
import java.util.List;
10+
import javax.xml.xpath.XPathExpressionException;
11+
12+
import com.oracle.weblogic.imagetool.api.model.CachedFile;
13+
import com.oracle.weblogic.imagetool.aru.AruException;
14+
import com.oracle.weblogic.imagetool.installer.FmwInstallerType;
15+
import com.oracle.weblogic.imagetool.installer.InstallerType;
16+
import com.oracle.weblogic.imagetool.installer.MiddlewareInstall;
17+
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
18+
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
19+
import com.oracle.weblogic.imagetool.util.Constants;
20+
import com.oracle.weblogic.imagetool.util.Utils;
21+
import picocli.CommandLine.Option;
22+
23+
import static com.oracle.weblogic.imagetool.cachestore.CacheStoreFactory.cache;
24+
25+
public class CommonCreateOptions extends CommonPatchingOptions {
26+
27+
private static final LoggingFacade logger = LoggingFactory.getLogger(CommonCreateOptions.class);
28+
29+
/**
30+
* Copy the Java and Middleware installers into the build context directory and set Dockerfile options accordingly.
31+
*/
32+
void prepareNewImage() throws IOException, InterruptedException, XPathExpressionException, AruException {
33+
34+
logger.entering();
35+
copyOptionsFromImage();
36+
37+
if (dockerfileOptions.installJava()) {
38+
CachedFile jdk = new CachedFile(InstallerType.JDK, jdkVersion);
39+
Path installerPath = jdk.copyFile(cache(), buildDir());
40+
dockerfileOptions.setJavaInstaller(installerPath.getFileName().toString());
41+
}
42+
43+
if (dockerfileOptions.installMiddleware()) {
44+
MiddlewareInstall install =
45+
new MiddlewareInstall(installerType, installerVersion, installerResponseFiles);
46+
install.copyFiles(cache(), buildDir());
47+
dockerfileOptions.setMiddlewareInstall(install);
48+
} else {
49+
dockerfileOptions.setWdtBase(fromImage());
50+
}
51+
52+
// resolve required patches
53+
handlePatchFiles(installerType);
54+
55+
// If patching, patch OPatch first
56+
if (applyingPatches() && shouldUpdateOpatch()) {
57+
prepareOpatchInstaller(buildDir(), opatchBugNumber);
58+
}
59+
60+
Utils.setOracleHome(installerResponseFiles, dockerfileOptions);
61+
62+
// Set the inventory oraInst.loc file location (null == default location)
63+
dockerfileOptions.setInvLoc(inventoryPointerInstallLoc);
64+
65+
// Set the inventory location, so that it will be copied
66+
if (inventoryPointerFile != null) {
67+
Utils.setInventoryLocation(inventoryPointerFile, dockerfileOptions);
68+
Utils.copyLocalFile(Paths.get(inventoryPointerFile), Paths.get(buildDir(), "/oraInst.loc"));
69+
} else {
70+
Utils.copyResourceAsFile("/response-files/oraInst.loc", buildDir());
71+
}
72+
logger.exiting();
73+
}
74+
75+
String getInstallerVersion() {
76+
return installerVersion;
77+
}
78+
79+
@Option(
80+
names = {"--type"},
81+
description = "Installer type. Default: WLS. Supported values: ${COMPLETION-CANDIDATES}"
82+
)
83+
private FmwInstallerType installerType = FmwInstallerType.WLS;
84+
85+
@Option(
86+
names = {"--version"},
87+
description = "Installer version. Default: ${DEFAULT-VALUE}",
88+
required = true,
89+
defaultValue = Constants.DEFAULT_WLS_VERSION
90+
)
91+
private String installerVersion;
92+
93+
@Option(
94+
names = {"--jdkVersion"},
95+
description = "Version of server jdk to install. Default: ${DEFAULT-VALUE}",
96+
required = true,
97+
defaultValue = Constants.DEFAULT_JDK_VERSION
98+
)
99+
private String jdkVersion;
100+
101+
@Option(
102+
names = {"--installerResponseFile"},
103+
split = ",",
104+
description = "path to a response file. Override the default responses for the Oracle installer"
105+
)
106+
private List<Path> installerResponseFiles;
107+
108+
@Option(
109+
names = {"--inventoryPointerFile"},
110+
description = "path to a user provided inventory pointer file as input"
111+
)
112+
private String inventoryPointerFile;
113+
114+
@Option(
115+
names = {"--inventoryPointerInstallLoc"},
116+
description = "path to where the inventory pointer file (oraInst.loc) should be stored in the image"
117+
)
118+
private String inventoryPointerInstallLoc;
119+
}

0 commit comments

Comments
 (0)