7
7
8
8
define ( [ 'models/wkt-project' , 'utils/k8s-domain-configmap-generator' , 'js-yaml' , 'utils/i18n' , 'utils/wkt-logger' ] ,
9
9
function ( project , K8sDomainConfigMapGenerator , jsYaml , i18n ) {
10
+ const WDT_DIR_NAME = 'weblogic-deploy' ;
11
+
10
12
class K8sDomainV9ResourceGenerator {
11
13
constructor ( ) {
12
14
this . project = project ;
@@ -52,19 +54,8 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
52
54
domainResource . spec . serverPod = serverPod ;
53
55
}
54
56
55
- if ( usingAuxImage ( ) ) {
56
- const auxiliaryImage = {
57
- image : this . project . image . auxImageTag . value ,
58
- } ;
59
- if ( this . project . k8sDomain . auxImagePullPolicy . hasValue ( ) ) {
60
- auxiliaryImage . imagePullPolicy = this . project . k8sDomain . auxImagePullPolicy . value ;
61
- }
62
- if ( this . project . k8sDomain . auxImageSourceWDTInstallHome . hasValue ( ) ) {
63
- auxiliaryImage . sourceWDTInstallHome = this . project . k8sDomain . auxImageSourceWDTInstallHome . value ;
64
- }
65
- if ( this . project . k8sDomain . auxImageSourceModelHome . hasValue ( ) ) {
66
- auxiliaryImage . sourceModelHome = this . project . k8sDomain . auxImageSourceModelHome . value ;
67
- }
57
+ if ( this . project . settings . targetDomainLocation . value === 'mii' ) {
58
+ const wdtRelatedPaths = this . _getWdtRelatedPaths ( domainResource ) ;
68
59
69
60
if ( ! domainResource . spec . configuration ) {
70
61
domainResource . spec . configuration = {
@@ -73,7 +64,26 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
73
64
} else if ( ! domainResource . spec . configuration . model ) {
74
65
domainResource . spec . configuration . model = { } ;
75
66
}
76
- domainResource . spec . configuration . model . auxiliaryImages = [ auxiliaryImage ] ;
67
+
68
+ if ( usingAuxImage ( ) ) {
69
+ const auxiliaryImage = {
70
+ image : this . project . image . auxImageTag . value ,
71
+ } ;
72
+ if ( this . project . k8sDomain . auxImagePullPolicy . hasValue ( ) ) {
73
+ auxiliaryImage . imagePullPolicy = this . project . k8sDomain . auxImagePullPolicy . value ;
74
+ }
75
+ auxiliaryImage . sourceWDTInstallHome = wdtRelatedPaths . sourceWDTInstallHome ;
76
+ auxiliaryImage . sourceModelHome = wdtRelatedPaths . sourceModelHome ;
77
+
78
+ domainResource . spec . configuration . model . auxiliaryImages = [ auxiliaryImage ] ;
79
+ } else {
80
+ if ( wdtRelatedPaths . wdtInstallHome ) {
81
+ domainResource . spec . configuration . model . wdtInstallHome = wdtRelatedPaths . wdtInstallHome ;
82
+ }
83
+ if ( wdtRelatedPaths . modelHome ) {
84
+ domainResource . spec . configuration . model . modelHome = wdtRelatedPaths . modelHome ;
85
+ }
86
+ }
77
87
}
78
88
79
89
if ( this . project . k8sDomain . clusters . value . length === 0 ) {
@@ -113,17 +123,6 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
113
123
domainResource . spec . configuration . model . domainType = this . project . k8sDomain . domainType . value ;
114
124
domainResource . spec . configuration . model . runtimeEncryptionSecret = this . project . k8sDomain . runtimeSecretName . value ;
115
125
116
- if ( ! usingAuxImage ( ) ) {
117
- const wdtRelatedPaths = this . _getWdtRelatedPaths ( domainResource ) ;
118
- // Only set these if they are specified; otherwise, rely on the default values
119
- if ( wdtRelatedPaths . wdtHome ) {
120
- domainResource . spec . configuration . model . wdtHome = wdtRelatedPaths . wdtHome ;
121
- }
122
- if ( wdtRelatedPaths . modelHome ) {
123
- domainResource . spec . configuration . model . modelHome = wdtRelatedPaths . modelHome ;
124
- }
125
- }
126
-
127
126
if ( this . k8sConfigMapGenerator . shouldCreateConfigMap ( ) ) {
128
127
domainResource . spec . configuration . model . configMap = this . project . k8sDomain . modelConfigMapName . value ;
129
128
}
@@ -237,24 +236,51 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
237
236
238
237
_getWdtRelatedPaths ( ) {
239
238
let result ;
240
-
241
239
if ( this . project . settings . targetDomainLocation . value === 'mii' ) {
242
-
243
240
result = { } ;
241
+
242
+ // WKO 4.0+ has different behavior and parameters than 3.x
243
+ //
244
+ let wdtInstallHome = this . project . image . wdtHomePath . value ;
245
+ if ( ! wdtInstallHome . endsWith ( WDT_DIR_NAME ) ) {
246
+ wdtInstallHome = window . api . path . join ( wdtInstallHome , WDT_DIR_NAME ) ;
247
+ }
244
248
if ( usingAuxImage ( ) ) {
245
- const wdtHome = this . project . image . wdtHomePath . value ;
246
- const modelHome = this . project . image . modelHomePath . value ;
247
- result . targetWdtHomeDirName = 'weblogic-deploy' ;
248
- result . sourceWdtHome = window . api . path . join ( wdtHome , result . targetWdtHomeDirName ) ;
249
- result . sourceModelHome = modelHome ;
250
- result . targetModelHomeDirName = window . api . path . basename ( modelHome ) ;
251
- } else {
252
- // Only set these if they are not the default
253
- if ( this . project . image . wdtHomePath . hasValue ( ) ) {
254
- result . wdtHome = this . project . image . wdtHomePath . value ;
249
+ if ( usingExistingAuxImage ( ) ) {
250
+ // If the source fields are exposed in the UI, use the values from those fields.
251
+ //
252
+ if ( this . project . k8sDomain . auxImageSourceWDTInstallHome . hasValue ( ) ) {
253
+ result . sourceWDTInstallHome = this . project . k8sDomain . auxImageSourceWDTInstallHome . value ;
254
+ }
255
+ if ( this . project . k8sDomain . auxImageSourceModelHome . hasValue ( ) ) {
256
+ result . sourceModelHome = this . project . k8sDomain . auxImageSourceModelHome . value ;
257
+ }
258
+ } else {
259
+ // If creating a new image, then use the values from the image page.
260
+ //
261
+ result . sourceWDTInstallHome = wdtInstallHome ;
262
+ result . sourceModelHome = this . project . image . modelHomePath . value ;
255
263
}
256
- if ( this . project . image . modelHomePath . hasValue ( ) ) {
257
- result . modelHome = this . project . image . modelHomePath . value ;
264
+ // We intentionally do not set the wdtInstallHome and modelHome parameters
265
+ // since the default values will always be correct in V9 when using aux images.
266
+ //
267
+ } else {
268
+ if ( usingExistingPrimaryImage ( ) ) {
269
+ // If these fields are exposed in the UI, use them if they have non-default values.
270
+ //
271
+ if ( this . project . k8sDomain . imageWDTInstallHome . hasValue ( ) ) {
272
+ result . wdtInstallHome = this . project . k8sDomain . imageWDTInstallHome . value ;
273
+ }
274
+ if ( this . project . k8sDomain . imageModelHome . hasValue ( ) ) {
275
+ result . modelHome = this . project . k8sDomain . imageModelHome . value ;
276
+ }
277
+ } else {
278
+ if ( this . project . image . modelHomePath . hasValue ( ) ) {
279
+ result . wdtInstallHome = wdtInstallHome ;
280
+ }
281
+ if ( this . project . image . modelHomePath . hasValue ( ) ) {
282
+ result . modelHome = this . project . image . modelHomePath . value ;
283
+ }
258
284
}
259
285
}
260
286
}
@@ -266,6 +292,15 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
266
292
return project . settings . targetDomainLocation . value === 'mii' && project . image . useAuxImage . value ;
267
293
}
268
294
295
+ function usingExistingPrimaryImage ( ) {
296
+ return project . settings . targetDomainLocation . value === 'mii' && ! project . image . createPrimaryImage . value
297
+ && ! project . image . useAuxImage . value ;
298
+ }
299
+
300
+ function usingExistingAuxImage ( ) {
301
+ return usingAuxImage ( ) && ! project . image . createAuxImage . value ;
302
+ }
303
+
269
304
function getOperatorNameForTargetDomainLocation ( targetDomainLocation ) {
270
305
switch ( targetDomainLocation ) {
271
306
case 'mii' :
0 commit comments