Skip to content

Commit ff206d1

Browse files
committed
Merge branch 'from-image-properties' into 'main'
New feature --fromImageProperties allows user to provide fromImage properties without docker run step See merge request weblogic-cloud/weblogic-image-tool!499
2 parents 3b0979e + 46c72b1 commit ff206d1

File tree

7 files changed

+47
-6
lines changed

7 files changed

+47
-6
lines changed

imagetool/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<parent>
1414
<artifactId>imagetool-parent</artifactId>
1515
<groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
16-
<version>1.14.5-SNAPSHOT</version>
16+
<version>1.15.0-SNAPSHOT</version>
1717
<relativePath>../pom.xml</relativePath>
1818
</parent>
1919

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

+27-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
package com.oracle.weblogic.imagetool.cli.menu;
55

66
import java.io.FileNotFoundException;
7+
import java.io.FileReader;
78
import java.io.IOException;
9+
import java.io.Reader;
810
import java.nio.file.Files;
911
import java.nio.file.Path;
1012
import java.nio.file.Paths;
@@ -198,6 +200,22 @@ void initializeOptions() throws InvalidCredentialException, IOException, Invalid
198200
logger.exiting();
199201
}
200202

203+
private Properties getBaseImageProperties() throws IOException, InterruptedException {
204+
Properties props;
205+
if (isOptionSet("--fromImageProperties")) {
206+
props = new Properties();
207+
try (Reader reader = new FileReader(fromImageProperties.toFile())) {
208+
props.load(reader);
209+
logger.info("IMG-0123", fromImageProperties);
210+
logger.finer(props);
211+
}
212+
} else {
213+
props = Utils.getBaseImageProperties(buildEngine, fromImage,
214+
"/probe-env/inspect-image.sh", buildDir());
215+
}
216+
return props;
217+
}
218+
201219
/**
202220
* Set the docker options (dockerfile template bean) by extracting information from the fromImage.
203221
*
@@ -208,8 +226,7 @@ public void copyOptionsFromImage() throws IOException, InterruptedException {
208226
if (isOptionSet("--fromImage")) {
209227
logger.info("IMG-0002", fromImage);
210228

211-
Properties baseImageProperties = Utils.getBaseImageProperties(buildEngine, fromImage,
212-
"/probe-env/inspect-image.sh", buildDir());
229+
Properties baseImageProperties = getBaseImageProperties();
213230

214231
String existingJavaHome = baseImageProperties.getProperty("javaHome", null);
215232
if (existingJavaHome != null) {
@@ -344,6 +361,14 @@ public Architecture getTargetArchitecture() {
344361
)
345362
private String fromImage;
346363

364+
@Option(
365+
names = {"--fromImageProperties"},
366+
paramLabel = "<Properties Filename>",
367+
description = "Properties that describe the --fromImage. "
368+
+ "If not provided, docker run will be used to inspect the --fromImage image."
369+
)
370+
private Path fromImageProperties;
371+
347372
@Option(
348373
names = {"--httpProxyUrl"},
349374
paramLabel = "<HTTP proxy URL>",

imagetool/src/main/java/com/oracle/weblogic/imagetool/logging/LoggingFacade.java

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
package com.oracle.weblogic.imagetool.logging;
55

6+
import java.util.Map;
67
import java.util.logging.ConsoleHandler;
78
import java.util.logging.FileHandler;
89
import java.util.logging.Handler;
@@ -195,6 +196,20 @@ public void finer(String msg, Throwable thrown) {
195196
}
196197
}
197198

199+
/**
200+
* Logs a message at the FINER level.
201+
*
202+
* @param map the message to log
203+
*/
204+
public void finer(Map<Object,Object> map) {
205+
if (isFinerEnabled()) {
206+
CallerDetails details = inferCaller();
207+
StringBuilder builder = new StringBuilder();
208+
map.forEach((k, v) -> builder.append(k).append("=").append(v).append(";"));
209+
logger.logp(Level.FINER, details.clazz, details.method, builder.toString());
210+
}
211+
}
212+
198213
/**
199214
* Logs a message at the FINEST level.
200215
*

imagetool/src/main/resources/ImageTool.properties

+1
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,4 @@ IMG-0119=All parameters and options provided after the -- will be passed to the
121121
IMG-0120=Retries exhausted, unable to download patch from Oracle. Try again later or manually add the patch to the cache to skip this download step.
122122
IMG-0121=Did not recognize architecture name {0}. Defaulted to AMD64.
123123
IMG-0122=Invalid patch {0} for version {1}. A patch cannot be both generic and architecture specific. Remove the invalid entry from the cache, like {0}_{1}_xxx64.
124+
IMG-0123=User specified fromImage properties with file: {0}

installer/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<parent>
1414
<artifactId>imagetool-parent</artifactId>
1515
<groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
16-
<version>1.14.5-SNAPSHOT</version>
16+
<version>1.15.0-SNAPSHOT</version>
1717
<relativePath>../pom.xml</relativePath>
1818
</parent>
1919

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<modelVersion>4.0.0</modelVersion>
99
<groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
1010
<artifactId>imagetool-parent</artifactId>
11-
<version>1.14.5-SNAPSHOT</version>
11+
<version>1.15.0-SNAPSHOT</version>
1212
<packaging>pom</packaging>
1313

1414
<name>WebLogic Image Tool</name>

tests/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<parent>
1313
<artifactId>imagetool-parent</artifactId>
1414
<groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
15-
<version>1.14.5-SNAPSHOT</version>
15+
<version>1.15.0-SNAPSHOT</version>
1616
<relativePath>../pom.xml</relativePath>
1717
</parent>
1818

0 commit comments

Comments
 (0)