77
88define ( [ 'models/wkt-project' , 'utils/k8s-domain-configmap-generator' , 'js-yaml' , 'utils/i18n' , 'utils/wkt-logger' ] ,
99 function ( project , K8sDomainConfigMapGenerator , jsYaml , i18n ) {
10+ const WDT_DIR_NAME = 'weblogic-deploy' ;
11+
1012 class K8sDomainV9ResourceGenerator {
1113 constructor ( ) {
1214 this . project = project ;
@@ -52,19 +54,8 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
5254 domainResource . spec . serverPod = serverPod ;
5355 }
5456
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 ) ;
6859
6960 if ( ! domainResource . spec . configuration ) {
7061 domainResource . spec . configuration = {
@@ -73,7 +64,26 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
7364 } else if ( ! domainResource . spec . configuration . model ) {
7465 domainResource . spec . configuration . model = { } ;
7566 }
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+ }
7787 }
7888
7989 if ( this . project . k8sDomain . clusters . value . length === 0 ) {
@@ -113,17 +123,6 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
113123 domainResource . spec . configuration . model . domainType = this . project . k8sDomain . domainType . value ;
114124 domainResource . spec . configuration . model . runtimeEncryptionSecret = this . project . k8sDomain . runtimeSecretName . value ;
115125
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-
127126 if ( this . k8sConfigMapGenerator . shouldCreateConfigMap ( ) ) {
128127 domainResource . spec . configuration . model . configMap = this . project . k8sDomain . modelConfigMapName . value ;
129128 }
@@ -237,24 +236,51 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
237236
238237 _getWdtRelatedPaths ( ) {
239238 let result ;
240-
241239 if ( this . project . settings . targetDomainLocation . value === 'mii' ) {
242-
243240 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+ }
244248 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 ;
255263 }
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+ }
258284 }
259285 }
260286 }
@@ -266,6 +292,15 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
266292 return project . settings . targetDomainLocation . value === 'mii' && project . image . useAuxImage . value ;
267293 }
268294
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+
269304 function getOperatorNameForTargetDomainLocation ( targetDomainLocation ) {
270305 switch ( targetDomainLocation ) {
271306 case 'mii' :
0 commit comments