Skip to content

correcting handling of kube config path and key name of kubeContext for managed clusters #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2023
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
2 changes: 1 addition & 1 deletion electron/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion webui/src/js/models/kubectl-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 14 additions & 4 deletions webui/src/js/viewModels/kubectl-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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));
}
});
};
Expand All @@ -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);
}
});
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 0 additions & 9 deletions webui/src/js/views/kubectl-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
<div class="wkt-content-layout">
<div class="wkt-content-top-bar wkt-no-tabs">
<h6><oj-bind-text value="[[labelMapper('title')]]"></oj-bind-text></h6>
<oj-button id="verifyKubectlConnectionButton"
disabled="[[disableVerify]]"
chroming="callToAction"
on-oj-action="[[verifyKubectlConnectivity]]"
:title="[[labelMapper('hints-verifyKubectlConnectivity')]]">
<span>
<oj-bind-text value="[[labelMapper('button-verifyKubectlConnectivity')]]"></oj-bind-text>
</span>
</oj-button>
</div>
<div class="wkt-content">
<div class="oj-panel wkt-notop">
Expand Down