Skip to content

Commit e8e9c3d

Browse files
committed
intermediate savepoint
1 parent 7370ae5 commit e8e9c3d

35 files changed

+2759
-1803
lines changed

electron/app/js/helmUtils.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async function installWko(helmExe, name, namespace, helmChartValues, helmOptions
114114
return _runHelmWko(helmExe, name, namespace, args, helmOptions, 'helm-install-wko-failed-error-message');
115115
}
116116

117-
async function upgradeWko(helmExe, name, namespace, helmChartValues, helmOptions) {
117+
async function updateWko(helmExe, name, namespace, helmChartValues, helmOptions) {
118118
const args = [ 'upgrade', name, _wkoHelmChartName, '--namespace', namespace, '--reuse-values' ];
119119
processHelmChartValues(args, helmChartValues);
120120
processHelmOptions(args, helmOptions);
@@ -123,6 +123,14 @@ async function upgradeWko(helmExe, name, namespace, helmChartValues, helmOptions
123123
return _runHelmWko(helmExe, name, namespace, args, helmOptions, 'helm-upgrade-wko-failed-error-message');
124124
}
125125

126+
async function uninstallWko(helmExe, name, namespace, helmOptions) {
127+
const args = [ 'uninstall', name, '--namespace', namespace ];
128+
processHelmOptions(args, helmOptions);
129+
130+
return _runHelmWko(helmExe, name, namespace, args, helmOptions, 'helm-uninstall-wko-failed-error-message');
131+
}
132+
133+
126134
async function helmListAllNamespaces(helmExe, helmOptions) {
127135
const args = [ 'list', '--all-namespaces' ];
128136
processHelmOptions(args, helmOptions);
@@ -245,7 +253,8 @@ function formatArrayOfObjectsSetArgument(name, objectArray) {
245253
module.exports = {
246254
addOrUpdateWkoHelmChart,
247255
installWko,
248-
upgradeWko,
256+
uninstallWko,
257+
updateWko,
249258
helmListAllNamespaces,
250259
installIngressController,
251260
addOrUpdateHelmChart,

electron/app/js/ipcRendererPreload.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ contextBridge.exposeInMainWorld(
7070
'start-push-aux-image',
7171
'start-k8s-verify-connection',
7272
'start-wko-install',
73+
'start-wko-uninstall',
74+
'start-wko-update',
7375
'start-ingress-install',
7476
'add-ingress-routes',
7577
'app-download-progress',
@@ -164,15 +166,16 @@ contextBridge.exposeInMainWorld(
164166
'k8s-apply',
165167
'k8s-label-namespace',
166168
'k8s-get-service-details',
167-
'k8s-get-operator-version-from-dm',
169+
'k8s-get-operator-version-from-domain-config-map',
168170
'k8s-get-k8s-config',
169171
'k8s-get-k8s-cluster-info',
170172
'k8s-get-wko-domain-status',
171173
'k8s-get-operator-status',
172174
'k8s-get-operator-log',
173175
'helm-add-wko-chart',
174176
'helm-install-wko',
175-
'helm-upgrade-wko',
177+
'helm-uninstall-wko',
178+
'helm-update-wko',
176179
'get-ingress-tlskeyfile',
177180
'get-ingress-tlscertfile',
178181
'helm-list-all-namespaces',
@@ -211,6 +214,7 @@ contextBridge.exposeInMainWorld(
211214
getDockerFilePath: () => fsUtils.getExecutableFilePath('docker', exeMode),
212215
getPodmanFilePath: () => fsUtils.getExecutableFilePath('podman', exeMode),
213216
getKubeConfig: () => k8sUtils.getKubeConfig(),
217+
getImageTagComponents: (imageTag) => k8sUtils.splitImageNameAndVersion(imageTag),
214218
getKubectlFilePath: () => fsUtils.getExecutableFilePath('kubectl'),
215219
getHelmFilePath: () => fsUtils.getExecutableFilePath('helm', exeMode),
216220
getOpenSSLFilePath: () => fsUtils.getExecutableFilePath('openssl'),

electron/app/js/k8sUtils.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,45 @@ function getRegistryAddressFromImageTag(tag) {
3939
return result;
4040
}
4141

42+
// Need to handle all possible flavors of the tag:
43+
//
44+
// - my-registry/foo/image
45+
// - my-registry/foo/image:1.0
46+
// - 2001:0db8:85a3:0000:0000:8a2e:0370:7334/foo/image
47+
// - 2001:0db8:85a3:0000:0000:8a2e:0370:7334/foo/image:1.0
48+
// - my-registry:8888/foo/image
49+
// - my-registry:8888/foo/image:1.0
50+
//
51+
function splitImageNameAndVersion(imageTag) {
52+
let imageName = imageTag;
53+
let imageVersion = 'latest';
54+
if (imageTag) {
55+
const lastColon = imageTag.lastIndexOf(':');
56+
const firstSlash = imageTag.indexOf('/');
57+
58+
// If no colon, then the imageTag is the imageName...
59+
if (lastColon !== -1) {
60+
// There may or may not be a slash in the image tag. The important
61+
// thing we have to check is if the first slash (if there is one)
62+
// is before or after the last colon.
63+
//
64+
// If before, the colon found is separating the image name from the version.
65+
//
66+
// If after, the colon found is part of the registry address. It could be
67+
// separating the port number from the DNS name/IP address, or it could be
68+
// part of an IPv6 address. Either way, there is no version specified.
69+
//
70+
if (firstSlash < lastColon) {
71+
imageName = imageTag.slice(0, lastColon);
72+
imageVersion = imageTag.slice(lastColon + 1);
73+
}
74+
}
75+
}
76+
return { name: imageName, version: imageVersion };
77+
}
78+
4279
module.exports = {
4380
getKubeConfig,
44-
getRegistryAddressFromImageTag
81+
getRegistryAddressFromImageTag,
82+
splitImageNameAndVersion
4583
};

electron/app/js/kubectlUtils.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const { getLogger } = require('./wktLogging');
1414
const { getHttpsProxyUrl, getBypassProxyHosts } = require('./userSettings');
1515
const { getErrorMessage } = require('./errorUtils');
1616
const osUtils = require('./osUtils');
17+
const k8sUtils = require('./k8sUtils');
1718

1819
/* global process */
1920
async function validateKubectlExe(kubectlExe) {
@@ -198,7 +199,7 @@ async function getOperatorLogs(kubectlExe, operatorNamespace, options) {
198199
});
199200
}
200201

201-
async function getOperatorVersionFromDomainCM(kubectlExe, domainNamespace, options) {
202+
async function getOperatorVersionFromDomainConfigMap(kubectlExe, domainNamespace, options) {
202203
const args = [ 'get', 'configmap', 'weblogic-scripts-cm', '-n', domainNamespace, '-o', 'jsonpath={.metadata.labels.weblogic\\.operatorVersion}'];
203204

204205
const httpsProxyUrl = getHttpsProxyUrl();
@@ -222,7 +223,6 @@ async function getOperatorVersionFromDomainCM(kubectlExe, domainNamespace, optio
222223
});
223224
}
224225

225-
226226
async function verifyClusterConnectivity(kubectlExe, options) {
227227
const args = [ 'version', '--short' ];
228228
const httpsProxyUrl = getHttpsProxyUrl();
@@ -644,23 +644,13 @@ function getOperatorImageTag(operatorDeployment) {
644644
}
645645

646646
function getOperatorImageWithoutVersion(imageTag) {
647-
let imageName = imageTag;
648-
if (imageTag) {
649-
imageName = imageTag.split(':')[0];
650-
}
651-
return imageName;
647+
const imageComponents = k8sUtils.splitImageNameAndVersion(imageTag);
648+
return imageComponents.name;
652649
}
653650

654651
function getOperatorImageVersion(imageTag) {
655-
let version;
656-
if (imageTag) {
657-
if (imageTag.indexOf(':') !== -1) {
658-
version = imageTag.split(':')[1];
659-
} else {
660-
version = 'latest';
661-
}
662-
}
663-
return version;
652+
const imageComponents = k8sUtils.splitImageNameAndVersion(imageTag);
653+
return imageComponents.version;
664654
}
665655

666656
function doesNamedObjectExist(objectListJson, name) {
@@ -777,7 +767,7 @@ module.exports = {
777767
getK8sClusterInfo,
778768
getWkoDomainStatus,
779769
getOperatorStatus,
780-
getOperatorVersionFromDomainCM,
770+
getOperatorVersionFromDomainConfigMap,
781771
getOperatorLogs,
782772
validateNamespacesExist,
783773
validateDomainExist,

electron/app/js/wktWindow.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,36 @@ class WktAppMenu {
327327
sendToWindow(focusedWindow,'start-wko-install');
328328
}
329329
},
330+
{
331+
id: 'updateOperator',
332+
label: i18n.t('menu-go-update-operator'),
333+
visible: this._isWkoTarget,
334+
enabled: !this._hasOpenDialog,
335+
click(item, focusedWindow) {
336+
if (!focusedWindow) {
337+
return dialog.showErrorBox(
338+
i18n.t('menu-go-update-operator-error-title'),
339+
i18n.t('menu-go-update-operator-error-message')
340+
);
341+
}
342+
sendToWindow(focusedWindow,'start-wko-update');
343+
}
344+
},
345+
{
346+
id: 'uninstallOperator',
347+
label: i18n.t('menu-go-uninstall-operator'),
348+
visible: this._isWkoTarget,
349+
enabled: !this._hasOpenDialog,
350+
click(item, focusedWindow) {
351+
if (!focusedWindow) {
352+
return dialog.showErrorBox(
353+
i18n.t('menu-go-uninstall-operator-error-title'),
354+
i18n.t('menu-go-uninstall-operator-error-message')
355+
);
356+
}
357+
sendToWindow(focusedWindow,'start-wko-uninstall');
358+
}
359+
},
330360
{
331361
id: 'deployDomain',
332362
label: i18n.t('menu-go-deploy-domain'),

electron/app/locales/en/electron.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
"menu-go-install-operator": "Install WebLogic Kubernetes Operator",
4949
"menu-go-install-operator-error-title": "No Active Project Window",
5050
"menu-go-install-operator-error-message": "Cannot install WebLogic Kubernetes Operator since there is no active window, and therefore no project with the WebLogic Kubernetes Operator configuration to install.",
51+
"menu-go-update-operator": "Update WebLogic Kubernetes Operator",
52+
"menu-go-update-operator-error-title": "No Active Project Window",
53+
"menu-go-update-operator-error-message": "Cannot update WebLogic Kubernetes Operator since there is no active window, and therefore no project with the WebLogic Kubernetes Operator configuration to update.",
54+
"menu-go-uninstall-operator": "Uninstall WebLogic Kubernetes Operator",
55+
"menu-go-uninstall-operator-error-title": "No Active Project Window",
56+
"menu-go-uninstall-operator-error-message": "Cannot uninstall WebLogic Kubernetes Operator since there is no active window, and therefore no project with the WebLogic Kubernetes Operator configuration to uninstall.",
5157
"menu-go-deploy-domain": "Deploy WebLogic Domain to Kubernetes",
5258
"menu-go-deploy-domain-error-title": "No Active Project Window",
5359
"menu-go-deploy-domain-error-message": "Cannot deploy WebLogic domain to Kubernetes since there is no active window, and therefore no project with a WebLogic domain configuration to deploy.",
@@ -272,6 +278,7 @@
272278
"helm-repo-add-failed-error-message": "Unable to add Helm repo {{helmRepo}}: {{error}}",
273279
"helm-install-ingress-failed-error-message": "Unable to install Helm release {{name}} in Kubernetes namespace {{namespace}} using Helm chart {{helmChart}}: {{error}}",
274280
"helm-install-wko-failed-error-message": "Unable to install Helm release {{name}} in Kubernetes namespace {{namespace}} using Helm chart {{helmChart}}: {{error}}",
281+
"helm-uninstall-wko-failed-error-message": "Unable to uninstall Helm release {{name}} in Kubernetes namespace {{namespace}} using Helm chart {{helmChart}}: {{error}}",
275282
"helm-upgrade-wko-failed-error-message": "Unable to upgrade Helm release {{name}} in Kubernetes namespace {{namespace}} using Helm chart {{helmChart}}: {{error}}",
276283
"helm-list-failed-error-message": "Helm list --all-namespaces failed: {{error}}",
277284
"helm-write-values-file-failed-error-message": "Unable to run helm install due to an error writing the data to a temporary file: {{error}}",

0 commit comments

Comments
 (0)