Skip to content

Commit 7726fb7

Browse files
authored
allow the user to skip update for OPatch version (#160)
1 parent 793cd17 commit 7726fb7

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
lines changed

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ boolean applyingPatches() {
168168
return latestPSU || !patches.isEmpty();
169169
}
170170

171+
/**
172+
* Should OPatch version be updated.
173+
* OPatch should be updated to the latest version available unless the user
174+
* requests that OPatch should not be updated.
175+
* @return true if OPatch should be updated.
176+
*/
177+
boolean shouldUpdateOpatch() {
178+
if (skipOpatchUpdate) {
179+
logger.fine("OPatch update was skipped at user's request");
180+
}
181+
return !skipOpatchUpdate;
182+
}
183+
171184
/**
172185
* Builds a list of build args to pass on to docker with the required patches.
173186
* Also, creates links to patches directory under build context instead of copying over.
@@ -382,7 +395,13 @@ String getPassword() {
382395
names = {"--pull"},
383396
description = "Always attempt to pull a newer version of base images during the build"
384397
)
385-
boolean buildPull = false;
398+
private boolean buildPull = false;
399+
400+
@Option(
401+
names = {"--skipOpatchUpdate"},
402+
description = "Do not update OPatch version, even if a newer version is available."
403+
)
404+
private boolean skipOpatchUpdate = false;
386405

387406
@SuppressWarnings("unused")
388407
@Unmatched

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public CommandResponse call() throws Exception {
7474
handlePatchFiles(null);
7575

7676
// If patching, patch OPatch first
77-
if (applyingPatches()) {
77+
if (applyingPatches() && shouldUpdateOpatch()) {
7878
installOpatchInstaller(tmpDir, opatchBugNumber);
7979
}
8080

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public CommandResponse call() throws Exception {
136136
handlePatchFiles(null);
137137

138138
// If patching, patch OPatch first
139-
if (applyingPatches()) {
139+
if (applyingPatches() && shouldUpdateOpatch()) {
140140
installOpatchInstaller(tmpDir, opatchBugNumber);
141141
}
142142

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,18 @@ public CommandResponse call() throws Exception {
8484
String userId = getUserId();
8585
String password = getPassword();
8686

87-
OPatchFile opatchFile = new OPatchFile(opatchBugNumber, userId, password, cache());
88-
String opatchFilePath = opatchFile.resolve(cache());
89-
90-
// if there is a newer version of OPatch than contained in the image, update OPatch
91-
if (Utils.compareVersions(opatchVersion, opatchFile.getVersion()) < 0) {
92-
logger.info("IMG-0008", opatchVersion, opatchFile.getVersion());
93-
String filename = new File(opatchFilePath).getName();
94-
Files.copy(Paths.get(opatchFilePath), Paths.get(tmpDir, filename));
95-
dockerfileOptions.setOPatchPatchingEnabled();
96-
dockerfileOptions.setOPatchFileName(filename);
87+
if (shouldUpdateOpatch()) {
88+
OPatchFile opatchFile = new OPatchFile(opatchBugNumber, userId, password, cache());
89+
String opatchFilePath = opatchFile.resolve(cache());
90+
91+
// if there is a newer version of OPatch than contained in the image, update OPatch
92+
if (Utils.compareVersions(opatchVersion, opatchFile.getVersion()) < 0) {
93+
logger.info("IMG-0008", opatchVersion, opatchFile.getVersion());
94+
String filename = new File(opatchFilePath).getName();
95+
Files.copy(Paths.get(opatchFilePath), Paths.get(tmpDir, filename));
96+
dockerfileOptions.setOPatchPatchingEnabled();
97+
dockerfileOptions.setOPatchFileName(filename);
98+
}
9799
}
98100

99101
logger.finer("Verifying Patches to WLS ");

imagetool/src/main/resources/ImageTool.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,4 @@ IMG-0061=Could not find key {0} in the cache for patch {1}
6363
IMG-0062=An OPatch version could not be found in the cache store and you have not provided Oracle Support credentials. Please provide --user with one of the password options or populate the cache store manually.
6464
IMG-0063=Found matching patch for {0}, but version is {1}
6565
IMG-0064=Failed to copy file, {0}, from cache to build context directory, {1}
66+
IMG-0065=Skipping OPatch version update, --skipOPatchUpdate

0 commit comments

Comments
 (0)