Skip to content

Commit 52d3f7a

Browse files
authored
Deprecated --type argument for AddPatchEntry (#179)
1 parent e1db1e8 commit 52d3f7a

File tree

5 files changed

+27
-39
lines changed

5 files changed

+27
-39
lines changed

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

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import com.oracle.weblogic.imagetool.api.model.CommandResponse;
1212
import com.oracle.weblogic.imagetool.cachestore.CacheStoreException;
13-
import com.oracle.weblogic.imagetool.installer.FmwInstallerType;
1413
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
1514
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
1615
import com.oracle.weblogic.imagetool.util.Utils;
@@ -31,6 +30,10 @@ public class AddPatchEntry extends CacheOperation {
3130
@Override
3231
public CommandResponse call() throws Exception {
3332

33+
if (type != null) {
34+
logger.warning("[[cyan: --type]] is [[brightred: DEPRECATED]] and will be removed in an upcoming release.");
35+
}
36+
3437
if (patchId != null && !patchId.isEmpty()
3538
&& location != null && Files.exists(location)
3639
&& Files.isRegularFile(location)) {
@@ -61,27 +64,13 @@ public CommandResponse call() throws Exception {
6164
* @return CLI command response
6265
*/
6366
private CommandResponse addToCache(String patchNumber) throws CacheStoreException {
64-
logger.info("adding key " + patchNumber);
65-
66-
// Check if it is an Opatch patch
67-
//String opatchNumber = Utils.getOpatchVersionFromZip(location.toAbsolutePath().toString());
68-
//if (opatchNumber != null) {
69-
// int lastSeparator = key.lastIndexOf(CacheStore.CACHE_KEY_SEPARATOR);
70-
// key = key.substring(0, lastSeparator) + CacheStore.CACHE_KEY_SEPARATOR + Constants.OPATCH_PATCH_TYPE;
71-
//}
72-
logger.info("adding key " + patchNumber);
7367
if (cache().getValueFromCache(patchNumber) != null) {
74-
String error = String.format("Cache key %s already exists, remove it first", patchNumber);
75-
logger.severe(error);
76-
throw new IllegalArgumentException(error);
68+
return new CommandResponse(-1, "IMG-0076", patchNumber);
7769
}
7870
cache().addToCache(patchNumber, location.toAbsolutePath().toString());
79-
String msg = String.format("Added Patch entry %s=%s for %s", patchNumber, location.toAbsolutePath(), type);
80-
logger.info(msg);
81-
return new CommandResponse(0, msg);
71+
return new CommandResponse(0, Utils.getMessage("IMG-0075", patchNumber, location.toAbsolutePath()));
8272
}
8373

84-
8574
@Option(
8675
names = {"--patchId"},
8776
description = "Patch number. Ex: 28186730",
@@ -91,12 +80,10 @@ private CommandResponse addToCache(String patchNumber) throws CacheStoreExceptio
9180

9281
@Option(
9382
names = {"--type"},
94-
description = "Type of patch. Valid values: ${COMPLETION-CANDIDATES}",
95-
required = true,
96-
defaultValue = "wls"
83+
description = "Type of patch. DEPRECATED"
9784
)
98-
private FmwInstallerType type;
99-
85+
@Deprecated
86+
private String type;
10087

10188
@Option(
10289
names = {"--path"},

imagetool/src/main/resources/ImageTool.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ IMG-0047=cache is empty
4949
IMG-0048=Installer already exists {0}={1}. Try removing it, before adding it again: deleteEntry --key={0}
5050
IMG-0049=Could not find value for --path, file not found: {0}
5151
IMG-0050=Successfully added to cache. {0}={1}
52-
IMG-0051=Deleted entry {0}={1}
52+
IMG-0051=Deleted entry [[cyan: {0}]]={1}
5353
IMG-0052=Nothing to delete for key: {0}
5454
IMG-0053=[[brightgreen: Build successful.]] Build time={0}s. Image tag={1}
5555
IMG-0054=[[brightgreen: Dry run complete.]] No image created.
@@ -73,3 +73,5 @@ IMG-0071=WDT Operation is set to UPDATE, but the DOMAIN_HOME environment variabl
7373
IMG-0072=ORACLE_HOME environment variable is not defined in the base image: {0}
7474
IMG-0073=Invalid file {0} listed for Verrazzano model
7575
IMG-0074=OPatch will not be updated, fromImage has version {0}, available version is {1}
76+
IMG-0075=Added patch entry [[cyan: {0}]]={1}
77+
IMG-0076=Cache key {0} already exists, remove it first

site/cache.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ List and set cache options
2020
| Option | Description |
2121
| --- | --- |
2222
|`listItems`| List cache contents. |
23-
|`addInstaller` | Add cache entry for `wls`, `fmw`, `jdk`, or `wdt` installer. |
24-
| `addPatch` | Add cache entry for `wls` or `fmw` patch, or `psu`. |
23+
|`addInstaller` | Add an installer to the cache. |
24+
| `addPatch` | Add a patch to the cache. |
2525
| `addEntry` | Add a cache entry. Use with caution. |
2626
| `help` | Display help information for the specified command.|
2727

@@ -46,13 +46,13 @@ List and set cache options
4646
imagetool cache addInstaller --type jdk --version 8u202 --path /path/to/local/jdk.tar.gz
4747
```
4848
49-
- `addPatch`: Add a patch to the cache. This command verifies if the path points to a valid patch by querying the Oracle Support portal.
49+
- `addPatch`: Add a patch to the cache.
5050
```
51-
imagetool cache addPatch --type wls --patchId 12345678_12.2.1.3.0 --path /path/to/patch.zip
51+
imagetool cache addPatch --patchId 12345678_12.2.1.3.0 --path /path/to/patch.zip
5252
```
53-
**Note**: When adding a patch to the cache store, the `patchId` should be in the following format: `99999999_9.9.9.9.99999` The first 8 digits is the patch ID, followed by an underscore, and then the release number. This is needed if you want to distinguish a patch that has different patch versions.
53+
**Note**: When adding a patch to the cache store, the `patchId` should be in the following format: `99999999_9.9.9.9.99999` The first 8 digits is the patch ID, followed by an underscore, and then the release number to identify the patch between different patch versions.
5454
55-
For example, patch `29135930` has several different versions in Oracle Support, one for each release in which the bug is fixed.
55+
For example, patch `29135930` has several different versions in Oracle Support, one for each release or PSU in which the bug is fixed.
5656
5757
| Patch Name | Release |
5858
| ---------|---------|

tests/src/test/java/com/oracle/weblogic/imagetool/tests/BaseTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static String getEnvironmentProperty(String name) {
4949
return result;
5050
}
5151

52-
protected static void validateEnvironmentSettings() throws Exception {
52+
protected static void validateEnvironmentSettings() {
5353
logger.info("Initializing the tests ...");
5454

5555
projectRoot = System.getProperty("user.dir");
@@ -230,9 +230,8 @@ protected ExecResult addInstallerToCache(String type, String version, String pat
230230
return executeAndVerify(command, false);
231231
}
232232

233-
protected ExecResult addPatchToCache(String type, String patchId, String version, String path) throws Exception {
234-
String command = imagetool + " cache addPatch --type " + type + " --patchId " + patchId + "_"
235-
+ version + " --path " + path;
233+
protected ExecResult addPatchToCache(String patchId, String version, String path) throws Exception {
234+
String command = imagetool + " cache addPatch --patchId " + patchId + "_" + version + " --path " + path;
236235
return executeAndVerify(command, false);
237236
}
238237

tests/src/test/java/com/oracle/weblogic/imagetool/tests/ITImagetool.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void cacheAddPatch() throws Exception {
178178

179179
String patchPath = getStagingDir() + FS + P27342434_INSTALLER;
180180
deleteEntryFromCache(P27342434_ID + "_" + WLS_VERSION);
181-
addPatchToCache("wls", P27342434_ID, WLS_VERSION, patchPath);
181+
addPatchToCache(P27342434_ID, WLS_VERSION, patchPath);
182182

183183
// verify the result
184184
ExecResult result = listItemsInCache();
@@ -247,7 +247,7 @@ void createWLSImgUseCache() throws Exception {
247247
// need to add the required patches 28186730 for Opatch before create wls images
248248
String patchPath = getStagingDir() + FS + P28186730_INSTALLER;
249249
deleteEntryFromCache(P28186730_ID + "_" + OPATCH_VERSION);
250-
addPatchToCache("wls", P28186730_ID, OPATCH_VERSION, patchPath);
250+
addPatchToCache(P28186730_ID, OPATCH_VERSION, patchPath);
251251
ExecResult resultT = listItemsInCache();
252252

253253
String versionTag = "test8img";
@@ -323,12 +323,12 @@ void createWlsImgUsingWdt() throws Exception {
323323
// delete the cache entry first
324324
deleteEntryFromCache(P28186730_ID + "_" + OPATCH_VERSION);
325325
String patchPath = getStagingDir() + FS + P28186730_INSTALLER;
326-
addPatchToCache("wls", P28186730_ID, OPATCH_VERSION, patchPath);
326+
addPatchToCache(P28186730_ID, OPATCH_VERSION, patchPath);
327327

328328
// add the patch to the cache
329329
deleteEntryFromCache(P27342434_ID + "_" + WLS_VERSION);
330330
patchPath = getStagingDir() + FS + P27342434_INSTALLER;
331-
addPatchToCache("wls", P27342434_ID, WLS_VERSION, patchPath);
331+
addPatchToCache(P27342434_ID, WLS_VERSION, patchPath);
332332

333333
// build the wdt archive
334334
buildWdtArchive();
@@ -412,7 +412,7 @@ void createFmwImgNonDefault() throws Exception {
412412
// add the patch to the cache
413413
String patchPath = getStagingDir() + FS + P22987840_INSTALLER;
414414
deleteEntryFromCache(P22987840_ID + "_" + WLS_VERSION_1221);
415-
addPatchToCache("fmw", P22987840_ID, WLS_VERSION_1221, patchPath);
415+
addPatchToCache(P22987840_ID, WLS_VERSION_1221, patchPath);
416416

417417
String command = imagetool + " create --jdkVersion " + JDK_VERSION_8u212 + " --version=" + WLS_VERSION_1221
418418
+ " --tag " + build_tag + ":" + testMethodName + " --patches " + P22987840_ID + " --type fmw";
@@ -577,7 +577,7 @@ void createWlsImgUsingMultiModels() throws Exception {
577577
// delete the cache entry first
578578
deleteEntryFromCache(P28186730_ID + "_" + OPATCH_VERSION);
579579
String patchPath = getStagingDir() + FS + P28186730_INSTALLER;
580-
addPatchToCache("wls", P28186730_ID, OPATCH_VERSION, patchPath);
580+
addPatchToCache(P28186730_ID, OPATCH_VERSION, patchPath);
581581

582582
// build the wdt archive
583583
buildWdtArchive();

0 commit comments

Comments
 (0)