Skip to content

Commit f40a2ac

Browse files
committed
get the latest from master
1 parent 78a49bf commit f40a2ac

File tree

14 files changed

+852
-406
lines changed

14 files changed

+852
-406
lines changed

CONTRIBUTING.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Contributing
2+
3+
Oracle welcomes contributions to this repository from anyone.
4+
5+
If you want to submit a pull request to fix a bug or enhance an existing
6+
feature, please first open an issue and link to that issue when you
7+
submit your pull request.
8+
9+
If you have any questions about a possible submission, feel free to open
10+
an issue too.
11+
12+
## Contributing to the Oracle WebLogic Image Tool repository
13+
14+
Pull requests can be made under
15+
[The Oracle Contributor Agreement](https://www.oracle.com/technetwork/community/oca-486395.html) (OCA).
16+
17+
For pull requests to be accepted, the bottom of your commit message must have
18+
the following line using your name and e-mail address as it appears in the
19+
OCA Signatories list.
20+
21+
```
22+
Signed-off-by: Your Name <[email protected]>
23+
```
24+
25+
This can be automatically added to pull requests by committing with:
26+
27+
```
28+
git commit --signoff
29+
```
30+
31+
Only pull requests from committers that can be verified as having
32+
signed the OCA can be accepted.
33+
34+
### Pull request process
35+
36+
1. Fork this repository
37+
1. Create a branch in your fork to implement the changes. We recommend using
38+
the issue number as part of your branch name, e.g. `1234-fixes`
39+
1. Ensure that any documentation is updated with the changes that are required
40+
by your fix.
41+
1. Ensure that any samples are updated if the base image has been changed.
42+
1. Submit the pull request. *Do not leave the pull request blank*. Explain exactly
43+
what your changes are meant to do and provide simple steps on how to validate
44+
your changes. Ensure that you reference the issue you created as well.
45+
We will assign the pull request to 2-3 people for review before it is merged.

THIRD_PARTY_LICENSES.txt

Lines changed: 328 additions & 0 deletions
Large diffs are not rendered by default.

imagetool/src/main/bin/setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#
2+
#Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3+
#
4+
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
5+
#
16
# source setup.sh
27
umask 27
38
#

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@
1010
import com.oracle.weblogic.imagetool.api.model.InstallerType;
1111
import com.oracle.weblogic.imagetool.api.model.WLSInstallerType;
1212
import com.oracle.weblogic.imagetool.impl.InstallerFile;
13-
import com.oracle.weblogic.imagetool.util.Constants;
14-
import com.oracle.weblogic.imagetool.util.HttpUtil;
15-
import com.oracle.weblogic.imagetool.util.Utils;
13+
import com.oracle.weblogic.imagetool.util.*;
1614
import picocli.CommandLine.Command;
1715
import picocli.CommandLine.Option;
1816

19-
import java.io.File;
20-
import java.io.FileInputStream;
21-
import java.io.IOException;
17+
import java.io.*;
2218
import java.nio.file.Files;
2319
import java.nio.file.Path;
2420
import java.nio.file.Paths;
@@ -28,7 +24,6 @@
2824
import java.util.LinkedList;
2925
import java.util.List;
3026
import java.util.Properties;
31-
import java.util.logging.FileHandler;
3227
import java.util.logging.Logger;
3328
import java.util.stream.Collectors;
3429

@@ -43,6 +38,7 @@ public class CreateImage extends ImageOperation {
4338
private final Logger logger = Logger.getLogger(CreateImage.class.getName());
4439

4540
public CreateImage() {
41+
super();
4642
}
4743

4844
public CreateImage(boolean isCLIMode) {
@@ -77,8 +73,7 @@ public CommandResponse call() throws Exception {
7773

7874
if (fromImage != null && !fromImage.isEmpty()) {
7975
logger.finer("User specified fromImage " + fromImage);
80-
cmdBuilder.add(Constants.BUILD_ARG);
81-
cmdBuilder.add("BASE_IMAGE=" + fromImage);
76+
dockerfileOptions.setBaseImage(fromImage);
8277

8378
tmpDir2 = Files.createTempDirectory(Paths.get(Utils.getBuildWorkingDir()),
8479
"wlsimgbuilder_temp", PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x")));
@@ -102,12 +97,12 @@ public CommandResponse call() throws Exception {
10297
if (useCache != CachePolicy.ALWAYS) {
10398
String pkgMgr = Utils.getPackageMgrStr(baseImageProperties.getProperty("ID", "ol"));
10499
if (!Utils.isEmptyString(pkgMgr)) {
105-
filterStartTags.add(pkgMgr);
100+
dockerfileOptions.setPackageInstaller(pkgMgr);
106101
}
107102
}
108103
} else {
109104
if (useCache != CachePolicy.ALWAYS) {
110-
filterStartTags.add("_YUM");
105+
dockerfileOptions.setPackageInstaller(Constants.YUM);
111106
}
112107
}
113108

@@ -121,7 +116,7 @@ public CommandResponse call() throws Exception {
121116
copyResponseFilesToDir(tmpDirPath);
122117

123118
// Create Dockerfile
124-
Utils.replacePlaceHolders(tmpDirPath + File.separator + "Dockerfile", "/docker-files/Dockerfile.create", filterStartTags, "/docker-files/Dockerfile.ph");
119+
Utils.writeDockerfile(tmpDirPath + File.separator + "Dockerfile", "Create_Image.mustache", dockerfileOptions);
125120

126121
// add directory to pass the context
127122
cmdBuilder.add(tmpDirPath);
@@ -205,7 +200,7 @@ private List<String> handleWDTArgsIfRequired(Path tmpDir) throws IOException {
205200
retVal.add("RCU_RUN_FLAG=" + "-run_rcu");
206201
}
207202
}
208-
filterStartTags.add("WDT_");
203+
dockerfileOptions.setWdtEnabled();
209204
Path targetLink = Files.copy(wdtModelPath, Paths.get(tmpDirPath, wdtModelPath.getFileName().toString())
210205
);
211206
retVal.add(Constants.BUILD_ARG);

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.oracle.weblogic.imagetool.impl.meta.CacheStoreFactory;
1414
import com.oracle.weblogic.imagetool.util.ARUUtil;
1515
import com.oracle.weblogic.imagetool.util.Constants;
16+
import com.oracle.weblogic.imagetool.util.DockerfileOptions;
1617
import com.oracle.weblogic.imagetool.util.Utils;
1718

1819
import java.io.File;
@@ -36,16 +37,19 @@
3637
public abstract class ImageOperation implements Callable<CommandResponse> {
3738

3839
private final Logger logger = Logger.getLogger(ImageOperation.class.getName());
39-
final List<String> filterStartTags = new ArrayList<>();
40+
// DockerfileOptions provides switches and values to the customize the Dockerfile template
41+
protected DockerfileOptions dockerfileOptions;
4042
protected CacheStore cacheStore = new CacheStoreFactory().get();
4143
private String nonProxyHosts = null;
4244
boolean isCLIMode;
4345
String password;
4446

4547
ImageOperation() {
48+
dockerfileOptions = new DockerfileOptions();
4649
}
4750

4851
ImageOperation(boolean isCLIMode) {
52+
this();
4953
this.isCLIMode = isCLIMode;
5054
}
5155

@@ -119,12 +123,7 @@ List<String> handlePatchFiles(Path tmpDir, Path tmpPatchesDir) throws Exception
119123
if (!patchLocations.isEmpty()) {
120124
retVal.add(Constants.BUILD_ARG);
121125
retVal.add("PATCHDIR=" + tmpDir.relativize(tmpPatchesDir).toString());
122-
filterStartTags.add("PATCH_");
123-
if (this instanceof CreateImage) {
124-
filterStartTags.add("CREATE_PATCH_");
125-
} else if (this instanceof UpdateImage) {
126-
filterStartTags.add("UPDATE_PATCH_");
127-
}
126+
dockerfileOptions.setPatchingEnabled();
128127
}
129128
logger.finer("Exiting ImageOperation.handlePatchFiles");
130129
return retVal;
@@ -182,12 +181,7 @@ void addOPatch1394ToImage(Path tmpDir, String opatchBugNumber) throws Exception
182181
String filePath =
183182
new PatchFile(useCache, Constants.OPATCH_PATCH_TYPE, Constants.OPATCH_PATCH_TYPE, opatchBugNumber, userId, password).resolve(cacheStore);
184183
Files.copy(Paths.get(filePath), Paths.get(tmpDir.toAbsolutePath().toString(), new File(filePath).getName()));
185-
filterStartTags.add("OPATCH_1394");
186-
if (this instanceof CreateImage) {
187-
filterStartTags.add("CREATE_OPATCH_1394");
188-
} else if (this instanceof UpdateImage) {
189-
filterStartTags.add("UPDATE_OPATCH_1394");
190-
}
184+
dockerfileOptions.setOPatchPatchingEnabled();
191185
}
192186

193187
WLSInstallerType installerType = WLSInstallerType.WLS;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class UpdateImage extends ImageOperation {
4141
private final Logger logger = Logger.getLogger(UpdateImage.class.getName());
4242

4343
public UpdateImage() {
44+
super();
4445
}
4546

4647
public UpdateImage(boolean isCLIMode) {
@@ -67,8 +68,7 @@ public CommandResponse call() throws Exception {
6768
if (fromImage == null || fromImage.isEmpty()) {
6869
return new CommandResponse(-1, "update requires a base image. use --fromImage to specify base image");
6970
} else {
70-
cmdBuilder.add(Constants.BUILD_ARG);
71-
cmdBuilder.add("BASE_IMAGE=" + fromImage);
71+
dockerfileOptions.setBaseImage(fromImage);
7272
}
7373

7474
tmpDir2 = Files.createTempDirectory(Paths.get(Utils.getBuildWorkingDir()), "wlsimgbuilder_temp",
@@ -117,7 +117,7 @@ public CommandResponse call() throws Exception {
117117
if (useCache != CachePolicy.ALWAYS) {
118118
String pkgMgr = Utils.getPackageMgrStr(baseImageProperties.getProperty("ID", "ol"));
119119
if (!Utils.isEmptyString(pkgMgr)) {
120-
filterStartTags.add(pkgMgr);
120+
dockerfileOptions.setPackageInstaller(pkgMgr);
121121
}
122122
}
123123

@@ -162,7 +162,7 @@ public CommandResponse call() throws Exception {
162162
cmdBuilder.addAll(handlePatchFiles(tmpDir, tmpPatchesDir));
163163

164164
// create dockerfile
165-
Utils.replacePlaceHolders(tmpDirPath + File.separator + "Dockerfile", "/docker-files/Dockerfile.update", filterStartTags, "/docker-files/Dockerfile.ph");
165+
Utils.writeDockerfile(tmpDirPath + File.separator + "Dockerfile", "Update_Image.mustache", dockerfileOptions);
166166

167167
// add directory to pass the context
168168
cmdBuilder.add(tmpDirPath);

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/Constants.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
2-
*
3-
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4-
*/
1+
// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
54
package com.oracle.weblogic.imagetool.util;
65

76
import java.util.List;
@@ -28,8 +27,6 @@ public final class Constants {
2827
public static final String CACHE_DIR_KEY = "cache.dir";
2928
public static final String DEFAULT_WLS_VERSION = "12.2.1.3.0";
3029
public static final String DEFAULT_JDK_VERSION = "8u202";
31-
public static final String WEBLOGIC_IMAGETOOL = "com/oracle/weblogicx/imagetool";
32-
public static final String METADATA_PREF_KEY = "metadata.file";
3330
public static final String DEFAULT_META_FILE = ".metadata";
3431
public static final String DELETE_ALL_FOR_SURE = "deleteAll4Sure";
3532

@@ -38,12 +35,16 @@ public final class Constants {
3835
).collect(Collectors.toList());
3936
public static final String BUILD_ARG = "--build-arg";
4037
public static final String FILE_CACHE = "FILE";
41-
public static final String PREF_CACHE = "PREF";
42-
public static final String CACHE_STORE_TYPE = "cacheStoreType";
4338
public static final String HTTP = "http";
4439
public static final String HTTPS = "https";
4540
public static final String PATCH_ID_REGEX = "^[pP]?(\\d+)";
4641

42+
//Option flags
43+
public static final String YUM = "_YUM";
44+
public static final String APTGET = "_APT";
45+
public static final String ZYPPER = "_SUSE";
46+
47+
4748
private Constants() {
4849
//restrict access
4950
}

0 commit comments

Comments
 (0)