Skip to content

Commit 210179e

Browse files
fixing domain resource generation for aux images with the V9 schema (#191)
* fixing domain resource generation for aux images with the V9 schema * making sure the use image use cases work properly
1 parent e57001e commit 210179e

File tree

6 files changed

+154
-49
lines changed

6 files changed

+154
-49
lines changed

electron/app/locales/en/webui.json

+4
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@
542542
"domain-design-image-registry-address-help": "The image registry hostname and port to use to log in to the registry, if required. This field's value is parsed from the Primary Image Tag field and an empty value assumes Docker Hub is the registry being used.",
543543
"domain-design-image-pull-policy-label": "Primary Image Pull Policy",
544544
"domain-design-image-pull-policy-help": "When to pull the domain's primary image from the image registry.",
545+
"domain-design-image-wdt-install-home-label": "WebLogic Deploy Tooling Install Home in Primary Image",
546+
"domain-design-image-wdt-install-home-help": "The location of the WebLogic Deploy Tooling installation within the primary image.",
547+
"domain-design-image-model-home-label": "WebLogic Deploy Tooling Model Home in Primary Image",
548+
"domain-design-image-model-home-help": "The directory location of the WebLogic Deploy Tooling model files within the primary image.",
545549
"domain-design-image-registry-pull-requires-authentication-label": "Specify Image Pull Credentials",
546550
"domain-design-image-registry-pull-requires-authentication-help": "Whether you want to specify authentication credentials for pulling the image from the registry.",
547551
"domain-design-image-registry-use-existing-pull-secret-label": "Use Existing Image Pull Secret",

webui/src/js/models/k8s-domain-definition.js

+10
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ define(['knockout', 'utils/observable-properties', 'utils/common-utilities', 'ut
4646

4747
this.imagePullPolicy = props.createProperty('IfNotPresent');
4848

49+
// These fields are exposed to the user only when using an existing Primary Image and
50+
// not using an Auxiliary Image at all.
51+
//
52+
this.imageModelHome = props.createProperty('/u01/wdt/models');
53+
this.imageWDTInstallHome = props.createProperty('/u01/wdt/weblogic-deploy');
54+
55+
4956
// Auxiliary image-related properties
5057
this.auxImageRegistryPullRequireAuthentication = props.createProperty(false);
5158
this.auxImageRegistryUseExistingPullSecret = props.createProperty(true);
@@ -56,6 +63,9 @@ define(['knockout', 'utils/observable-properties', 'utils/common-utilities', 'ut
5663
this.auxImageRegistryPullEmail = props.createProperty();
5764
this.auxImageRegistryPullEmail.addValidator(...validationHelper.getEmailAddressValidators());
5865
this.auxImagePullPolicy = props.createProperty('IfNotPresent');
66+
67+
// These fields are exposed to the user only when using an existing Auxiliary Image.
68+
//
5969
this.auxImageSourceModelHome = props.createProperty('/auxiliary/models');
6070
this.auxImageSourceWDTInstallHome = props.createProperty('/auxiliary/weblogic-deploy');
6171

webui/src/js/utils/k8s-domain-v8-resource-generator.js

+38-9
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function(project, K8sDomainConfigMapGenerator, jsYaml, i18n) {
139139
} else {
140140
// Only set these if they are specified; otherwise, rely on the default values
141141
if (wdtRelatedPaths.wdtHome) {
142-
domainResource.spec.configuration.model.wdtHome = wdtRelatedPaths.wdtHome;
142+
domainResource.spec.configuration.model.wdtInstallHome = wdtRelatedPaths.wdtHome;
143143
}
144144
if (wdtRelatedPaths.modelHome) {
145145
domainResource.spec.configuration.model.modelHome = wdtRelatedPaths.modelHome;
@@ -216,30 +216,59 @@ function(project, K8sDomainConfigMapGenerator, jsYaml, i18n) {
216216

217217
result = { };
218218
if (usingAuxImage()) {
219-
const wdtHome = this.project.image.wdtHomePath.value;
220-
const modelHome = this.project.image.modelHomePath.value;
219+
let wdtHome;
220+
let modelHome;
221+
if (creatingAuxImage()) {
222+
wdtHome = this.project.image.wdtHomePath.value;
223+
modelHome = this.project.image.modelHomePath.value;
224+
} else {
225+
modelHome = this.project.k8sDomain.auxImageSourceModelHome.value;
226+
wdtHome = this.project.k8sDomain.auxImageSourceWDTInstallHome.value;
227+
const match = wdtHome.match(/(\/.+?)\/weblogic-deploy\/?/);
228+
if (match) {
229+
wdtHome = match[1];
230+
}
231+
}
221232
result.targetWdtHomeDirName = 'weblogic-deploy';
222233
result.sourceWdtHome = window.api.path.join(wdtHome, result.targetWdtHomeDirName);
223234
result.sourceModelHome = modelHome;
224235
result.targetModelHomeDirName = window.api.path.basename(modelHome);
225236
} else {
226-
// Only set these if they are not the default
227-
if (this.project.image.wdtHomePath.hasValue()) {
228-
result.wdtHome = this.project.image.wdtHomePath.value;
229-
}
230-
if (this.project.image.modelHomePath.hasValue()) {
231-
result.modelHome = this.project.image.modelHomePath.value;
237+
if (usingExistingPrimaryImage()) {
238+
if (this.project.k8sDomain.imageWDTInstallHome.hasValue()) {
239+
result.wdtHome = this.project.k8sDomain.imageWDTInstallHome.value;
240+
}
241+
if (this.project.k8sDomain.imageModelHome.hasValue()) {
242+
result.modelHome = this.project.k8sDomain.imageModelHome.value;
243+
}
244+
} else {
245+
// Only set these if they are not the default
246+
if (this.project.image.wdtHomePath.hasValue()) {
247+
result.wdtHome = this.project.image.wdtHomePath.value;
248+
}
249+
if (this.project.image.modelHomePath.hasValue()) {
250+
result.modelHome = this.project.image.modelHomePath.value;
251+
}
232252
}
233253
}
234254
}
235255
return result;
236256
}
237257
}
238258

259+
function usingExistingPrimaryImage() {
260+
return project.settings.targetDomainLocation.value === 'mii' && !project.image.createPrimaryImage.value
261+
&& !project.image.useAuxImage.value;
262+
}
263+
239264
function usingAuxImage() {
240265
return project.settings.targetDomainLocation.value === 'mii' && project.image.useAuxImage.value;
241266
}
242267

268+
function creatingAuxImage() {
269+
return usingAuxImage() && project.image.createAuxImage.value;
270+
}
271+
243272
function getAuxImageCopyCommand(wdtRelatedPaths) {
244273
const auxImageInternalTarget = '$AUXILIARY_IMAGE_TARGET_PATH';
245274

webui/src/js/utils/k8s-domain-v9-resource-generator.js

+74-39
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
define(['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':

webui/src/js/viewModels/domain-design-view.js

+12
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ function (project, accUtils, utils, ko, i18n, screenUtils, BufferingDataProvider
129129
return this.labelMapper(key);
130130
}, this);
131131

132+
this.showPrimaryImageHomeFields = ko.computed(() => {
133+
return this.project.settings.targetDomainLocation.observable() === 'mii' &&
134+
!this.project.image.createPrimaryImage.observable() &&
135+
!this.project.image.useAuxImage.observable();
136+
}, this);
137+
132138
this.isPrimaryImageTagReadOnly = ko.computed(() => {
133139
return this.project.image.createPrimaryImage.observable();
134140
}, this);
@@ -137,6 +143,12 @@ function (project, accUtils, utils, ko, i18n, screenUtils, BufferingDataProvider
137143
return this.project.image.createAuxImage.observable();
138144
}, this);
139145

146+
this.showAuxImageSourceFields = ko.computed(() => {
147+
return this.project.settings.targetDomainLocation.observable() === 'mii' &&
148+
this.project.image.useAuxImage.observable() &&
149+
!this.project.image.createAuxImage.observable();
150+
}, this);
151+
140152
this.auxImageTagHelp = ko.computed(() => {
141153
let key = 'use-aux-image-tag-help';
142154
if (this.project.image.createAuxImage.observable()) {

webui/src/js/views/domain-design-view.html

+16-1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@ <h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('image-title')]]">
141141
help.instruction="[[labelMapper('image-pull-policy-help')]]">
142142
</oj-select-single>
143143
</oj-form-layout>
144+
145+
<oj-bind-if test="[[showPrimaryImageHomeFields]]">
146+
<oj-form-layout max-columns="2" direction="row">
147+
<oj-input-text label-hint="[[labelMapper('image-wdt-install-home-label')]]"
148+
value="{{project.k8sDomain.imageWDTInstallHome.observable}}"
149+
help.instruction="[[labelMapper('image-wdt-install-home-help')]]">
150+
</oj-input-text>
151+
<oj-input-text label-hint="[[labelMapper('image-model-home-label')]]"
152+
value="{{project.k8sDomain.imageModelHome.observable}}"
153+
help.instruction="[[labelMapper('image-model-home-help')]]">
154+
</oj-input-text>
155+
</oj-form-layout>
156+
</oj-bind-if>
157+
144158
<oj-form-layout max-columns="2" direction="row">
145159
<oj-switch label-hint="[[labelMapper('image-registry-pull-requires-authentication-label')]]"
146160
value="{{project.k8sDomain.imageRegistryPullRequireAuthentication.observable}}"
@@ -232,7 +246,8 @@ <h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('aux-image-title')
232246
help.instruction="[[labelMapper('aux-image-pull-policy-help')]]">
233247
</oj-select-single>
234248
</oj-form-layout>
235-
<oj-bind-if test="[[project.image.createAuxImage.observable() === false]]">
249+
250+
<oj-bind-if test="[[showAuxImageSourceFields]]">
236251
<oj-form-layout max-columns="2" direction="row">
237252
<oj-input-text label-hint="[[labelMapper('aux-image-source-wdt-home-label')]]"
238253
value="{{project.k8sDomain.auxImageSourceWDTInstallHome.observable}}"

0 commit comments

Comments
 (0)