Skip to content

Commit b0ec88b

Browse files
correcting handling of kube config path and key name of kubeContext for managed clusters (#209)
1 parent e257dca commit b0ec88b

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

electron/app/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class Main {
423423
defaultPath: path.join(app.getPath('home'), '.kube'),
424424
buttonLabel: i18n.t('button-select'),
425425
properties: [ 'openFile', 'multiSelections', 'dontAddToRecent' ]
426-
}, path.delimiter);
426+
});
427427
});
428428

429429
ipcMain.handle('get-helm-exe', async (event) => {

webui/src/js/models/kubectl-definition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ define(['utils/observable-properties'],
2222
executableFilePath: props.createProperty(window.api.k8s.getKubectlFilePath()),
2323
kubeConfigContextToUse: props.createProperty(),
2424
helmExecutableFilePath: props.createProperty(window.api.k8s.getHelmFilePath()),
25-
vzManagedClusters: props.createListProperty(['uid', 'name', 'kubeConfig', 'KubeContext']).persistByKey('uid'),
25+
vzManagedClusters: props.createListProperty(['uid', 'name', 'kubeConfig', 'kubeContext']).persistByKey('uid'),
2626

2727
readFrom: function(json) {
2828
props.createGroup(name, this).readFrom(json);

webui/src/js/viewModels/kubectl-page.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function(accUtils, ko, project, i18n, ArrayDataProvider, BufferingDataProvider,
4848
},
4949
{
5050
headerText: this.labelMapper('vz-managed-cluster-kubeconfig-heading'),
51-
sortProperty: 'kubeConfig'
51+
'sortable': 'disable'
5252
},
5353
{
5454
headerText: this.labelMapper('vz-managed-cluster-kubecontext-heading'),
@@ -107,8 +107,10 @@ function(accUtils, ko, project, i18n, ArrayDataProvider, BufferingDataProvider,
107107

108108
this.chooseKubeConfig = () => {
109109
getKubeConfig().then(kubeConfigPath => {
110-
if (kubeConfigPath) {
110+
if (Array.isArray(kubeConfigPath)) {
111111
this.project.kubectl.kubeConfig.observable(kubeConfigPath);
112+
} else if (typeof kubeConfigPath ==='string' && kubeConfigPath.length > 0) {
113+
this.project.kubectl.kubeConfig.observable(kubeConfigPath.split(window.api.path.delimiter));
112114
}
113115
});
114116
};
@@ -117,8 +119,15 @@ function(accUtils, ko, project, i18n, ArrayDataProvider, BufferingDataProvider,
117119
const index = context.item.index;
118120
const managedClusterData = this.project.kubectl.vzManagedClusters.observable()[index];
119121
getKubeConfig().then(kubeConfigPath => {
120-
if (kubeConfigPath) {
121-
const newManagedClusterData = { ...managedClusterData, kubeConfig:kubeConfigPath };
122+
let kubeConfig;
123+
if (Array.isArray(kubeConfigPath)) {
124+
kubeConfig = kubeConfigPath;
125+
} else if (typeof kubeConfigPath === 'string' && kubeConfigPath.length > 0) {
126+
kubeConfig = kubeConfigPath.split(window.api.path.delimiter);
127+
}
128+
129+
if (kubeConfig) {
130+
const newManagedClusterData = { ...managedClusterData, kubeConfig };
122131
this.project.kubectl.vzManagedClusters.observable.replace(managedClusterData, newManagedClusterData);
123132
}
124133
});
@@ -251,6 +260,7 @@ function(accUtils, ko, project, i18n, ArrayDataProvider, BufferingDataProvider,
251260
const index = context.item.index;
252261
const managedClusterData = this.project.kubectl.vzManagedClusters.observable()[index];
253262
await k8sHelper.startVerifyClusterConnectivity(managedClusterData.kubeConfig, managedClusterData.kubeContext);
263+
await k8sHelper.startVerifyClusterConnectivity(managedClusterData.kubeConfig, managedClusterData.kubeContext);
254264
};
255265

256266
this.createLink = function (url, label) {

webui/src/js/views/kubectl-page.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@
55
<div class="wkt-content-layout">
66
<div class="wkt-content-top-bar wkt-no-tabs">
77
<h6><oj-bind-text value="[[labelMapper('title')]]"></oj-bind-text></h6>
8-
<oj-button id="verifyKubectlConnectionButton"
9-
disabled="[[disableVerify]]"
10-
chroming="callToAction"
11-
on-oj-action="[[verifyKubectlConnectivity]]"
12-
:title="[[labelMapper('hints-verifyKubectlConnectivity')]]">
13-
<span>
14-
<oj-bind-text value="[[labelMapper('button-verifyKubectlConnectivity')]]"></oj-bind-text>
15-
</span>
16-
</oj-button>
178
</div>
189
<div class="wkt-content">
1910
<div class="oj-panel wkt-notop">

0 commit comments

Comments
 (0)