Skip to content

Commit 14904ef

Browse files
authored
Fixed bug in REBASE that prevented copy of WDT_HOME (#367)
1 parent 4de21ea commit 14904ef

File tree

2 files changed

+36
-26
lines changed

2 files changed

+36
-26
lines changed

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

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2022, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package com.oracle.weblogic.imagetool.cli.menu;
@@ -30,45 +30,42 @@ public CommandResponse call() throws Exception {
3030
logger.entering();
3131
Instant startTime = Instant.now();
3232

33-
String oldOracleHome;
34-
String oldJavaHome;
3533
String newOracleHome = null;
3634
String newJavaHome = null;
37-
String domainHome;
38-
String modelHome;
39-
boolean modelOnly;
4035

4136
try {
4237
initializeOptions();
4338

44-
if (sourceImage != null && !sourceImage.isEmpty()) {
45-
logger.finer("IMG-0002", sourceImage);
46-
dockerfileOptions.setSourceImage(sourceImage);
39+
if (Utils.isEmptyString(sourceImage)) {
40+
// sourceImage is a required parameter. This error will only occur if the user passes an empty string.
41+
return CommandResponse.error(Utils.getMessage("IMG-0117"));
42+
}
4743

48-
logger.info("IMG-0091", sourceImage);
49-
Properties baseImageProperties = Utils.getBaseImageProperties(buildEngine, sourceImage,
50-
"/probe-env/inspect-image.sh", buildDir());
44+
logger.finer("IMG-0002", sourceImage);
45+
dockerfileOptions.setSourceImage(sourceImage);
5146

52-
oldOracleHome = baseImageProperties.getProperty("oracleHome", null);
53-
oldJavaHome = baseImageProperties.getProperty("javaHome", null);
54-
domainHome = baseImageProperties.getProperty("domainHome", null);
55-
modelHome = baseImageProperties.getProperty("wdtModelHome", null);
56-
modelOnly = Boolean.parseBoolean(baseImageProperties.getProperty("wdtModelOnly", null));
57-
} else {
58-
return CommandResponse.error("Source Image not set");
59-
}
47+
logger.info("IMG-0091", sourceImage);
48+
Properties sourceImageProperties = Utils.getBaseImageProperties(buildEngine, sourceImage,
49+
"/probe-env/inspect-image.sh", buildDir());
50+
51+
String oldOracleHome = sourceImageProperties.getProperty("oracleHome", null);
52+
String oldJavaHome = sourceImageProperties.getProperty("javaHome", null);
53+
String domainHome = sourceImageProperties.getProperty("domainHome", null);
54+
String wdtHome = sourceImageProperties.getProperty("wdtHome", null);
55+
String modelHome = sourceImageProperties.getProperty("wdtModelHome", null);
56+
boolean modelOnly = Boolean.parseBoolean(sourceImageProperties.getProperty("wdtModelOnly", null));
6057

58+
// If the user specified --targetImage, collect and apply the properties for the new image.
6159
if (!Utils.isEmptyString(targetImage)) {
6260
logger.finer("IMG-0002", targetImage);
6361
dockerfileOptions.setTargetImage(targetImage);
6462
dockerfileOptions.setRebaseToTarget(true);
6563

66-
Properties baseImageProperties = Utils.getBaseImageProperties(buildEngine, targetImage,
64+
Properties targetImageProperties = Utils.getBaseImageProperties(buildEngine, targetImage,
6765
"/probe-env/inspect-image.sh", buildDir());
68-
69-
newOracleHome = baseImageProperties.getProperty("oracleHome", null);
70-
newJavaHome = baseImageProperties.getProperty("javaHome", null);
71-
66+
newOracleHome = targetImageProperties.getProperty("oracleHome", null);
67+
newJavaHome = targetImageProperties.getProperty("javaHome", null);
68+
useFileOwnerFromTarget(targetImageProperties);
7269
} else {
7370
dockerfileOptions.setRebaseToNew(true);
7471
}
@@ -94,6 +91,7 @@ public CommandResponse call() throws Exception {
9491

9592
dockerfileOptions
9693
.setDomainHome(domainHome)
94+
.setWdtHome(wdtHome)
9795
.setWdtModelHome(modelHome)
9896
.setWdtModelOnly(modelOnly);
9997

@@ -117,6 +115,17 @@ public CommandResponse call() throws Exception {
117115
return successfulBuildResponse(startTime);
118116
}
119117

118+
private void useFileOwnerFromTarget(Properties imageProperties) {
119+
String userid = imageProperties.getProperty("oracleHomeUser", null);
120+
String groupid = imageProperties.getProperty("oracleHomeGroup", null);
121+
if (!Utils.isEmptyString(userid)) {
122+
dockerfileOptions.setUserId(userid);
123+
}
124+
if (!Utils.isEmptyString(groupid)) {
125+
dockerfileOptions.setGroupId(groupid);
126+
}
127+
}
128+
120129
@Option(
121130
names = {"--sourceImage"},
122131
required = true,

imagetool/src/main/resources/ImageTool.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ IMG-0086=Failed to find patch number [[brightred: {0}]] on Oracle servers, verif
8888
IMG-0087=The Oracle Home directory in --fromImage={0} has an owner and group of {1}:{2}. You must update the image with the same user and group setting from when it was created. Example: --chown={1}:{2}
8989
IMG-0088=Build command failed with error: {0}
9090
IMG-0089=WDT_MODEL_HOME was not set in the source image, using default model location: {0}
91-
IMG-0090=Rebasing WDT models. A domain was not found in the source image at {0}
91+
IMG-0090=Rebasing WDT models only. A domain was not found in the source image at {0}
9292
IMG-0091=Reading settings from the source image {0}
9393
IMG-0092=ORACLE_HOME already exists in {0} (--fromImage), skipping middleware installs
9494
IMG-0093=Patching skipped. Using CREATE to patch --fromImage with an existing ORACLE_HOME is not supported. To create a patched image, use CREATE with a linux base image and apply the WebLogic install and patches at the same time.
@@ -115,3 +115,4 @@ IMG-0113=The directory specified with WLSIMG_BLDDIR must be writable: {0}
115115
IMG-0114=Unable to parse section {0} of additionalBuildCommands: {1}
116116
IMG-0115=Unable to reach Oracle patch server to check for patch conflicts, skipping online conflict check. OPatch will check patches locally during the build.
117117
IMG-0116=A patch conflict was detected. The patches listed within the brackets conflict with each other. These fixes cannot be applied without a merge patch from Oracle:
118+
IMG-0117=The value for --sourceImage must not be empty.

0 commit comments

Comments
 (0)