Skip to content

Commit 5ff9e8e

Browse files
committed
CRC setup is reseted after closing its window #4411
Fixes: #4411 Issues: #4413, #4414 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
1 parent ce1b673 commit 5ff9e8e

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

package.json

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,21 +2234,6 @@
22342234
"order": 1,
22352235
"title": "OpenShift Toolkit",
22362236
"properties": {
2237-
"openshiftToolkit": {
2238-
"type": "object",
2239-
"title": "Additional settings",
2240-
"description": "OpenShift Toolkit configuration",
2241-
"properties": {
2242-
"openshiftToolkit.disable-context-info-status-bar": {
2243-
"type": "boolean",
2244-
"description": "Disable displaying the current Kubernetes context in VS Code's status bar."
2245-
},
2246-
"openshiftToolkit.disable-namespace-info-status-bar": {
2247-
"type": "boolean",
2248-
"description": "Disable displaying the active namespace in VS Code's status bar."
2249-
}
2250-
}
2251-
},
22522237
"openshiftToolkit.showWelcomePage": {
22532238
"type": "boolean",
22542239
"default": true,
@@ -2287,6 +2272,14 @@
22872272
"type": "number",
22882273
"default": 4,
22892274
"description": "MiB of memory to allocate for stdout buffer when executing a binary"
2275+
},
2276+
"openshiftToolkit.disable-context-info-status-bar": {
2277+
"type": "boolean",
2278+
"description": "Disable displaying the current Kubernetes context in VS Code's status bar."
2279+
},
2280+
"openshiftToolkit.disable-namespace-info-status-bar": {
2281+
"type": "boolean",
2282+
"description": "Disable displaying the active namespace in VS Code's status bar."
22902283
}
22912284
}
22922285
},

src/webview/cluster/clusterViewLoader.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,32 @@ export default class ClusterViewLoader {
368368
}
369369
}
370370

371+
/**
372+
* Cleans up the CRC configuration settings.
373+
*
374+
* This is a workarount to https://github.com/redhat-developer/vscode-openshift-tools/issues/4411
375+
* After the CRC setting values are removed, if the 'openshiftToolkit' object exists in 'settings.json',
376+
* containing the same settings as the CRC ones, the new values will be written AFTER the mensioned object,
377+
* so their values will override the ones defined in the object.
378+
*/
379+
static async clearCrcSettings() {
380+
const cfg = vscode.workspace.getConfiguration('openshiftToolkit');
381+
await cfg.update('crcBinaryLocation', undefined, vscode.ConfigurationTarget.Global);
382+
await cfg.update('crcPullSecretPath', undefined, vscode.ConfigurationTarget.Global);
383+
await cfg.update('crcCpuCores', undefined, vscode.ConfigurationTarget.Global);
384+
await cfg.update('crcMemoryAllocated', undefined, vscode.ConfigurationTarget.Global);
385+
await cfg.update('crcNameserver', undefined); // Previously it was saved as `Workspace`
386+
await cfg.update('crcNameserver', undefined, vscode.ConfigurationTarget.Global);
387+
}
388+
371389
static async crcSaveSettings(event) {
390+
await ClusterViewLoader.clearCrcSettings();
372391
const cfg = vscode.workspace.getConfiguration('openshiftToolkit');
373392
await cfg.update('crcBinaryLocation', event.crcLoc, vscode.ConfigurationTarget.Global);
374393
await cfg.update('crcPullSecretPath', event.pullSecret, vscode.ConfigurationTarget.Global);
375394
await cfg.update('crcCpuCores', event.cpuSize, vscode.ConfigurationTarget.Global);
376395
await cfg.update('crcMemoryAllocated', Number.parseInt(event.memory, 10), vscode.ConfigurationTarget.Global);
377-
await cfg.update('crcNameserver', event.nameserver);
396+
await cfg.update('crcNameserver', event.nameserver, vscode.ConfigurationTarget.Global);
378397
}
379398

380399
static async loadView(title: string): Promise<vscode.WebviewPanel> {

0 commit comments

Comments
 (0)