From 2fac7f777bf06354b24d77fad4b0de131c993328 Mon Sep 17 00:00:00 2001 From: Robert Patrick Date: Tue, 28 Feb 2023 08:33:43 -0600 Subject: [PATCH] correcting handling of kube config path and key name of kubeContext for managed clusters --- electron/app/main.js | 2 +- webui/src/js/models/kubectl-definition.js | 2 +- webui/src/js/viewModels/kubectl-page.js | 18 ++++++++++++++---- webui/src/js/views/kubectl-page.html | 9 --------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/electron/app/main.js b/electron/app/main.js index 0da5eef22..a1be39503 100644 --- a/electron/app/main.js +++ b/electron/app/main.js @@ -423,7 +423,7 @@ class Main { defaultPath: path.join(app.getPath('home'), '.kube'), buttonLabel: i18n.t('button-select'), properties: [ 'openFile', 'multiSelections', 'dontAddToRecent' ] - }, path.delimiter); + }); }); ipcMain.handle('get-helm-exe', async (event) => { diff --git a/webui/src/js/models/kubectl-definition.js b/webui/src/js/models/kubectl-definition.js index 51a9546a2..5a4e3ee3a 100644 --- a/webui/src/js/models/kubectl-definition.js +++ b/webui/src/js/models/kubectl-definition.js @@ -22,7 +22,7 @@ define(['utils/observable-properties'], executableFilePath: props.createProperty(window.api.k8s.getKubectlFilePath()), kubeConfigContextToUse: props.createProperty(), helmExecutableFilePath: props.createProperty(window.api.k8s.getHelmFilePath()), - vzManagedClusters: props.createListProperty(['uid', 'name', 'kubeConfig', 'KubeContext']).persistByKey('uid'), + vzManagedClusters: props.createListProperty(['uid', 'name', 'kubeConfig', 'kubeContext']).persistByKey('uid'), readFrom: function(json) { props.createGroup(name, this).readFrom(json); diff --git a/webui/src/js/viewModels/kubectl-page.js b/webui/src/js/viewModels/kubectl-page.js index 8bf8a1d04..ab22da5a3 100644 --- a/webui/src/js/viewModels/kubectl-page.js +++ b/webui/src/js/viewModels/kubectl-page.js @@ -48,7 +48,7 @@ function(accUtils, ko, project, i18n, ArrayDataProvider, BufferingDataProvider, }, { headerText: this.labelMapper('vz-managed-cluster-kubeconfig-heading'), - sortProperty: 'kubeConfig' + 'sortable': 'disable' }, { headerText: this.labelMapper('vz-managed-cluster-kubecontext-heading'), @@ -107,8 +107,10 @@ function(accUtils, ko, project, i18n, ArrayDataProvider, BufferingDataProvider, this.chooseKubeConfig = () => { getKubeConfig().then(kubeConfigPath => { - if (kubeConfigPath) { + if (Array.isArray(kubeConfigPath)) { this.project.kubectl.kubeConfig.observable(kubeConfigPath); + } else if (typeof kubeConfigPath ==='string' && kubeConfigPath.length > 0) { + this.project.kubectl.kubeConfig.observable(kubeConfigPath.split(window.api.path.delimiter)); } }); }; @@ -117,8 +119,15 @@ function(accUtils, ko, project, i18n, ArrayDataProvider, BufferingDataProvider, const index = context.item.index; const managedClusterData = this.project.kubectl.vzManagedClusters.observable()[index]; getKubeConfig().then(kubeConfigPath => { - if (kubeConfigPath) { - const newManagedClusterData = { ...managedClusterData, kubeConfig:kubeConfigPath }; + let kubeConfig; + if (Array.isArray(kubeConfigPath)) { + kubeConfig = kubeConfigPath; + } else if (typeof kubeConfigPath === 'string' && kubeConfigPath.length > 0) { + kubeConfig = kubeConfigPath.split(window.api.path.delimiter); + } + + if (kubeConfig) { + const newManagedClusterData = { ...managedClusterData, kubeConfig }; this.project.kubectl.vzManagedClusters.observable.replace(managedClusterData, newManagedClusterData); } }); @@ -251,6 +260,7 @@ function(accUtils, ko, project, i18n, ArrayDataProvider, BufferingDataProvider, const index = context.item.index; const managedClusterData = this.project.kubectl.vzManagedClusters.observable()[index]; await k8sHelper.startVerifyClusterConnectivity(managedClusterData.kubeConfig, managedClusterData.kubeContext); + await k8sHelper.startVerifyClusterConnectivity(managedClusterData.kubeConfig, managedClusterData.kubeContext); }; this.createLink = function (url, label) { diff --git a/webui/src/js/views/kubectl-page.html b/webui/src/js/views/kubectl-page.html index 0202f2642..2ec6f72d7 100644 --- a/webui/src/js/views/kubectl-page.html +++ b/webui/src/js/views/kubectl-page.html @@ -5,15 +5,6 @@
- - - - -