1
+ // Copyright (c) 2021, Oracle and/or its affiliates.
2
+ // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3
+
4
+ package com .oracle .weblogic .imagetool .cli .menu ;
5
+
6
+ import java .io .IOException ;
7
+ import java .nio .file .Path ;
8
+ import java .nio .file .Paths ;
9
+ import java .util .List ;
10
+ import javax .xml .xpath .XPathExpressionException ;
11
+
12
+ import com .oracle .weblogic .imagetool .api .model .CachedFile ;
13
+ import com .oracle .weblogic .imagetool .aru .AruException ;
14
+ import com .oracle .weblogic .imagetool .installer .FmwInstallerType ;
15
+ import com .oracle .weblogic .imagetool .installer .InstallerType ;
16
+ import com .oracle .weblogic .imagetool .installer .MiddlewareInstall ;
17
+ import com .oracle .weblogic .imagetool .logging .LoggingFacade ;
18
+ import com .oracle .weblogic .imagetool .logging .LoggingFactory ;
19
+ import com .oracle .weblogic .imagetool .util .Constants ;
20
+ import com .oracle .weblogic .imagetool .util .Utils ;
21
+ import picocli .CommandLine .Option ;
22
+
23
+ import static com .oracle .weblogic .imagetool .cachestore .CacheStoreFactory .cache ;
24
+
25
+ public class CommonCreateOptions extends CommonPatchingOptions {
26
+
27
+ private static final LoggingFacade logger = LoggingFactory .getLogger (CommonCreateOptions .class );
28
+
29
+ /**
30
+ * Copy the Java and Middleware installers into the build context directory and set Dockerfile options accordingly.
31
+ */
32
+ void prepareNewImage () throws IOException , InterruptedException , XPathExpressionException , AruException {
33
+
34
+ logger .entering ();
35
+ copyOptionsFromImage ();
36
+
37
+ if (dockerfileOptions .installJava ()) {
38
+ CachedFile jdk = new CachedFile (InstallerType .JDK , jdkVersion );
39
+ Path installerPath = jdk .copyFile (cache (), buildDir ());
40
+ dockerfileOptions .setJavaInstaller (installerPath .getFileName ().toString ());
41
+ }
42
+
43
+ if (dockerfileOptions .installMiddleware ()) {
44
+ MiddlewareInstall install =
45
+ new MiddlewareInstall (installerType , installerVersion , installerResponseFiles );
46
+ install .copyFiles (cache (), buildDir ());
47
+ dockerfileOptions .setMiddlewareInstall (install );
48
+ } else {
49
+ dockerfileOptions .setWdtBase (fromImage ());
50
+ }
51
+
52
+ // resolve required patches
53
+ handlePatchFiles (installerType );
54
+
55
+ // If patching, patch OPatch first
56
+ if (applyingPatches () && shouldUpdateOpatch ()) {
57
+ prepareOpatchInstaller (buildDir (), opatchBugNumber );
58
+ }
59
+
60
+ Utils .setOracleHome (installerResponseFiles , dockerfileOptions );
61
+
62
+ // Set the inventory oraInst.loc file location (null == default location)
63
+ dockerfileOptions .setInvLoc (inventoryPointerInstallLoc );
64
+
65
+ // Set the inventory location, so that it will be copied
66
+ if (inventoryPointerFile != null ) {
67
+ Utils .setInventoryLocation (inventoryPointerFile , dockerfileOptions );
68
+ Utils .copyLocalFile (Paths .get (inventoryPointerFile ), Paths .get (buildDir (), "/oraInst.loc" ));
69
+ } else {
70
+ Utils .copyResourceAsFile ("/response-files/oraInst.loc" , buildDir ());
71
+ }
72
+ logger .exiting ();
73
+ }
74
+
75
+ String getInstallerVersion () {
76
+ return installerVersion ;
77
+ }
78
+
79
+ @ Option (
80
+ names = {"--type" },
81
+ description = "Installer type. Default: WLS. Supported values: ${COMPLETION-CANDIDATES}"
82
+ )
83
+ private FmwInstallerType installerType = FmwInstallerType .WLS ;
84
+
85
+ @ Option (
86
+ names = {"--version" },
87
+ description = "Installer version. Default: ${DEFAULT-VALUE}" ,
88
+ required = true ,
89
+ defaultValue = Constants .DEFAULT_WLS_VERSION
90
+ )
91
+ private String installerVersion ;
92
+
93
+ @ Option (
94
+ names = {"--jdkVersion" },
95
+ description = "Version of server jdk to install. Default: ${DEFAULT-VALUE}" ,
96
+ required = true ,
97
+ defaultValue = Constants .DEFAULT_JDK_VERSION
98
+ )
99
+ private String jdkVersion ;
100
+
101
+ @ Option (
102
+ names = {"--installerResponseFile" },
103
+ split = "," ,
104
+ description = "path to a response file. Override the default responses for the Oracle installer"
105
+ )
106
+ private List <Path > installerResponseFiles ;
107
+
108
+ @ Option (
109
+ names = {"--inventoryPointerFile" },
110
+ description = "path to a user provided inventory pointer file as input"
111
+ )
112
+ private String inventoryPointerFile ;
113
+
114
+ @ Option (
115
+ names = {"--inventoryPointerInstallLoc" },
116
+ description = "path to where the inventory pointer file (oraInst.loc) should be stored in the image"
117
+ )
118
+ private String inventoryPointerInstallLoc ;
119
+ }
0 commit comments