Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 43 additions & 39 deletions webui/src/js/utils/k8s-domain-deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,55 +247,59 @@ function (project, wktConsole, k8sHelper, i18n, projectIo, dialogHelper, K8sDoma
return Promise.resolve(false);
}

// Create Secrets
busyDialogMessage = i18n.t('k8s-domain-deployer-create-secrets-in-progress',
{domainName: domainUid, namespace: domainNamespace});
dialogHelper.updateBusyDialog(busyDialogMessage, 10 / totalSteps);
const secrets = this.project.k8sDomain.secrets.value;
if (secrets && secrets.length > 0) {
for (const secret of secrets) {
let secretName = '';
const secretData = {};
for (const [key, value] of Object.entries(secret)) {
if (key === 'name') {
secretName = value;
} else if (key !== 'uid') {
// skip artificial uid field...
secretData[key] = value;
// Create Secrets, if needed
if (this.project.settings.targetDomainLocation.value === 'mii') {
busyDialogMessage = i18n.t('k8s-domain-deployer-create-secrets-in-progress',
{domainName: domainUid, namespace: domainNamespace});
dialogHelper.updateBusyDialog(busyDialogMessage, 10 / totalSteps);
const secrets = this.project.k8sDomain.secrets.value;
if (secrets && secrets.length > 0) {
for (const secret of secrets) {
let secretName = '';
const secretData = {};
for (const [key, value] of Object.entries(secret)) {
if (key === 'name') {
secretName = value;
} else if (key !== 'uid') {
// skip artificial uid field...
secretData[key] = value;
}
}
wktLogger.debug('Creating secret %s', secretName);

const createSecretResults =
await window.api.ipc.invoke('k8s-create-generic-secret', kubectlExe, domainNamespace, secretName, secretData, kubectlOptions);
if (!createSecretResults.isSuccess) {
const errMessage = i18n.t('k8s-domain-deployer-create-secret-failed-error-message',
{secretName: secretName, namespace: domainNamespace, error: createSecretResults.reason});
dialogHelper.closeBusyDialog();
await window.api.ipc.invoke('show-error-message', errTitle, errMessage);
return Promise.resolve(false);
}
}
wktLogger.debug('Creating secret %s', secretName);
}
}

const createSecretResults =
await window.api.ipc.invoke('k8s-create-generic-secret', kubectlExe, domainNamespace, secretName, secretData, kubectlOptions);
if (!createSecretResults.isSuccess) {
const errMessage = i18n.t('k8s-domain-deployer-create-secret-failed-error-message',
{secretName: secretName, namespace: domainNamespace, error: createSecretResults.reason});
// Create ConfigMap, if needed
if (this.project.settings.targetDomainLocation.value === 'mii') {
if (!this.project.k8sDomain.configMapIsEmpty()) {
const configMapData = this.k8sDomainConfigMapGenerator.generate().join('\n');
wktLogger.debug(configMapData);
busyDialogMessage = i18n.t('k8s-domain-deployer-create-config-map-in-progress',
{domainName: domainUid, domainNamespace: domainNamespace});
dialogHelper.updateBusyDialog(busyDialogMessage, 11 / totalSteps);
const mapResults = await (window.api.ipc.invoke('k8s-apply', kubectlExe, configMapData, kubectlOptions));
if (!mapResults.isSuccess) {
const configMapName = this.project.k8sDomain.modelConfigMapName.value;
const errMessage = i18n.t('k8s-domain-deployer-create-config-map-failed-error-message',
{configMapName: configMapName, domainNamespace: domainNamespace, error: mapResults.reason});
dialogHelper.closeBusyDialog();
await window.api.ipc.invoke('show-error-message', errTitle, errMessage);
return Promise.resolve(false);
}
}
}

// Create ConfigMap, if needed
if (!this.project.k8sDomain.configMapIsEmpty()) {
const configMapData = this.k8sDomainConfigMapGenerator.generate().join('\n');
wktLogger.debug(configMapData);
busyDialogMessage = i18n.t('k8s-domain-deployer-create-config-map-in-progress',
{domainName: domainUid, domainNamespace: domainNamespace});
dialogHelper.updateBusyDialog(busyDialogMessage, 11 / totalSteps);
const mapResults = await (window.api.ipc.invoke('k8s-apply', kubectlExe, configMapData, kubectlOptions));
if (!mapResults.isSuccess) {
const configMapName = this.project.k8sDomain.modelConfigMapName.value;
const errMessage = i18n.t('k8s-domain-deployer-create-config-map-failed-error-message',
{configMapName: configMapName, domainNamespace: domainNamespace, error: mapResults.reason});
dialogHelper.closeBusyDialog();
await window.api.ipc.invoke('show-error-message', errTitle, errMessage);
return Promise.resolve(false);
}
}

// Deploy domain
busyDialogMessage = i18n.t('k8s-domain-deployer-deploy-in-progress',
{domainName: domainUid, domainNamespace: domainNamespace});
Expand Down
7 changes: 4 additions & 3 deletions webui/src/js/utils/k8s-domain-resource-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
'use strict';

define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml', 'utils/i18n'],
function(project, K8sDomainConfigMapGenerator, jsYaml, i18n) {
define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml', 'utils/i18n', 'utils/wkt-logger'],
function(project, K8sDomainConfigMapGenerator, jsYaml, i18n, logger) {
class K8sDomainResourceGenerator {
constructor() {
this.project = project;
Expand Down Expand Up @@ -36,7 +36,8 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
}
};

if (this.project.k8sDomain.domainHome.hasValue()) {
logger.debug('Domain home path: %s', this.project.k8sDomain.domainHome.value)
if (this.project.k8sDomain.domainHome.value) {
domainResource.spec.domainHome = this.project.k8sDomain.domainHome.value;
}

Expand Down
6 changes: 5 additions & 1 deletion webui/src/js/viewModels/domain-design-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function (project, accUtils, utils, ko, i18n, BufferingDataProvider,
return this.project.settings.targetDomainLocation.observable() === 'pv';
});

this.isModelInImage = ko.computed(() => {
return this.project.settings.targetDomainLocation.observable() === 'mii';
});

this.domainHomeHelpLabel = ko.computed(() => {
const domainHomeHelpKey = this.isDomainInPV() ? 'domain-home-help' : 'domain-home-readonly-help';
return this.labelMapper(domainHomeHelpKey);
Expand Down Expand Up @@ -143,7 +147,7 @@ function (project, accUtils, utils, ko, i18n, BufferingDataProvider,
{keyAttributes: 'uid', sortComparators: propertyComparators}));

this.hasEncryptionSecret = () => {
return this.project.settings.targetDomainLocation.value === 'mii';
return this.isModelInImage();
};

this.secretsTableColumnMetadata = () => {
Expand Down
148 changes: 76 additions & 72 deletions webui/src/js/views/domain-design-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,80 +176,84 @@ <h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('clusters-title')]
</oj-table>
</div>

<div class="oj-panel">
<h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('configmap-title')]]"></oj-bind-text></h6>
<oj-bind-if test="[[modelHasNoProperties() === false]]">
<oj-form-layout max-columns="1">
<oj-input-text label-hint="[[labelMapper('configmap-label')]]"
value="{{project.k8sDomain.modelConfigMapName.observable}}"
help.instruction="[[labelMapper('configmap-help')]]">
</oj-input-text>
</oj-form-layout>
</oj-bind-if>
<oj-bind-if test="[[isModelInImage() === true]]">
<div class="oj-panel">
<h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('configmap-title')]]"></oj-bind-text></h6>
<oj-bind-if test="[[modelHasNoProperties() === false]]">
<oj-form-layout max-columns="1">
<oj-input-text label-hint="[[labelMapper('configmap-label')]]"
value="{{project.k8sDomain.modelConfigMapName.observable}}"
help.instruction="[[labelMapper('configmap-help')]]">
</oj-input-text>
</oj-form-layout>
</oj-bind-if>

<oj-table id="properties-table"
class="wkt-domain-properties-table"
aria-label="ConfigMap Properties Table"
data="{{configMapDP}}"
display="grid"
horizontal-grid-visible="enabled"
vertical-grid-visible="enabled"
edit-mode="rowEdit"
layout="fixed"
columns='[[propertyTableColumnMetadata()]]'>
<template slot="rowTemplate" data-oj-as="row">
<tr data-bind="attr: {'data-uid': row.data.uid}">
<oj-bind-if test='[[row.mode=="navigation"]]'>
<td><oj-bind-text value="[[row.data.Name]]"></oj-bind-text></td>
<td><oj-bind-text value="[[row.data.Value]]"></oj-bind-text></td>
<td><oj-bind-text value="[[row.data.Override]]"></oj-bind-text></td>
</oj-bind-if>
<oj-bind-if test='[[row.mode=="edit"]]'>
<td><oj-input-text value="[[row.data.Name]]" disabled="true"></oj-input-text></td>
<td><oj-input-text value="[[row.data.Value]]" disabled="true"></oj-input-text></td>
<td><oj-input-text value="{{row.data.Override}}"></oj-input-text></td>
</oj-bind-if>
</tr>
</template>
</oj-table>
</div>
<oj-table id="properties-table"
class="wkt-domain-properties-table"
aria-label="ConfigMap Properties Table"
data="{{configMapDP}}"
display="grid"
horizontal-grid-visible="enabled"
vertical-grid-visible="enabled"
edit-mode="rowEdit"
layout="fixed"
columns='[[propertyTableColumnMetadata()]]'>
<template slot="rowTemplate" data-oj-as="row">
<tr data-bind="attr: {'data-uid': row.data.uid}">
<oj-bind-if test='[[row.mode=="navigation"]]'>
<td><oj-bind-text value="[[row.data.Name]]"></oj-bind-text></td>
<td><oj-bind-text value="[[row.data.Value]]"></oj-bind-text></td>
<td><oj-bind-text value="[[row.data.Override]]"></oj-bind-text></td>
</oj-bind-if>
<oj-bind-if test='[[row.mode=="edit"]]'>
<td><oj-input-text value="[[row.data.Name]]" disabled="true"></oj-input-text></td>
<td><oj-input-text value="[[row.data.Value]]" disabled="true"></oj-input-text></td>
<td><oj-input-text value="{{row.data.Override}}"></oj-input-text></td>
</oj-bind-if>
</tr>
</template>
</oj-table>
</div>
</oj-bind-if>

<div class="oj-panel">
<h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('secrets-title')]]"></oj-bind-text></h6>
<oj-table id="secrets-table"
class="wkt-domain-secrets-table"
aria-label="Secrets Table"
data="[[secretsDP]]"
display="grid"
horizontal-grid-visible="enabled"
vertical-grid-visible="enabled"
edit-mode="rowEdit"
layout="fixed"
columns='[[secretsTableColumnMetadata()]]'>
<template slot="rowTemplate" data-oj-as="row">
<tr>
<oj-bind-if test='[[row.mode=="navigation"]]'>
<td><oj-bind-text value="[[row.data.name]]"></oj-bind-text></td>
</oj-bind-if>
<oj-bind-if test='[[row.mode=="edit"]]'>
<td><oj-input-text value="{{row.data.name}}" disabled="true"></oj-input-text></td>
</oj-bind-if>
<td>
<oj-input-password value="{{row.data.username}}"
mask-icon="visible"
readonly='[[row.mode=="navigation"]]' >
</oj-input-password>
</td>
<td>
<oj-input-password value="{{row.data.password}}"
mask-icon="visible"
readonly='[[row.mode=="navigation"]]' >
</oj-input-password>
</td>
</tr>
</template>
</oj-table>
</div>
<oj-bind-if test="[[isModelInImage() === true]]">
<div class="oj-panel">
<h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('secrets-title')]]"></oj-bind-text></h6>
<oj-table id="secrets-table"
class="wkt-domain-secrets-table"
aria-label="Secrets Table"
data="[[secretsDP]]"
display="grid"
horizontal-grid-visible="enabled"
vertical-grid-visible="enabled"
edit-mode="rowEdit"
layout="fixed"
columns='[[secretsTableColumnMetadata()]]'>
<template slot="rowTemplate" data-oj-as="row">
<tr>
<oj-bind-if test='[[row.mode=="navigation"]]'>
<td><oj-bind-text value="[[row.data.name]]"></oj-bind-text></td>
</oj-bind-if>
<oj-bind-if test='[[row.mode=="edit"]]'>
<td><oj-input-text value="{{row.data.name}}" disabled="true"></oj-input-text></td>
</oj-bind-if>
<td>
<oj-input-password value="{{row.data.username}}"
mask-icon="visible"
readonly='[[row.mode=="navigation"]]' >
</oj-input-password>
</td>
<td>
<oj-input-password value="{{row.data.password}}"
mask-icon="visible"
readonly='[[row.mode=="navigation"]]' >
</oj-input-password>
</td>
</tr>
</template>
</oj-table>
</div>
</oj-bind-if>

<oj-collapsible expanded='false'>
<h6 slot="header" class="wkt-subheading"><oj-bind-text value="[[labelMapper('page-design-advanced-label')]]"></oj-bind-text></h6>
Expand Down