Skip to content

Commit

Permalink
CRC setup is reseted after closing its window redhat-developer#4411
Browse files Browse the repository at this point in the history
  • Loading branch information
vrubezhny committed Sep 6, 2024
1 parent 0552c88 commit 5f2bcd7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
23 changes: 8 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2234,21 +2234,6 @@
"order": 1,
"title": "OpenShift Toolkit",
"properties": {
"openshiftToolkit": {
"type": "object",
"title": "Additional settings",
"description": "OpenShift Toolkit configuration",
"properties": {
"openshiftToolkit.disable-context-info-status-bar": {
"type": "boolean",
"description": "Disable displaying the current Kubernetes context in VS Code's status bar."
},
"openshiftToolkit.disable-namespace-info-status-bar": {
"type": "boolean",
"description": "Disable displaying the active namespace in VS Code's status bar."
}
}
},
"openshiftToolkit.showWelcomePage": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -2287,6 +2272,14 @@
"type": "number",
"default": 4,
"description": "MiB of memory to allocate for stdout buffer when executing a binary"
},
"openshiftToolkit.disable-context-info-status-bar": {
"type": "boolean",
"description": "Disable displaying the current Kubernetes context in VS Code's status bar."
},
"openshiftToolkit.disable-namespace-info-status-bar": {
"type": "boolean",
"description": "Disable displaying the active namespace in VS Code's status bar."
}
}
},
Expand Down
21 changes: 20 additions & 1 deletion src/webview/cluster/clusterViewLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,32 @@ export default class ClusterViewLoader {
}
}

/**
* Cleans up the CRC configuration settings.
*
* This is a workarount to https://github.com/redhat-developer/vscode-openshift-tools/issues/4411
* After the CRC setting values are removed, if the 'openshiftToolkit' object exists in 'settings.json',
* containing the same settings as the CRC ones, the new values will be written AFTER the mensioned object,
* so their values will override the ones defined in the object.
*/
static async clearCrcSettings() {
const cfg = vscode.workspace.getConfiguration('openshiftToolkit');
await cfg.update('crcBinaryLocation', undefined, vscode.ConfigurationTarget.Global);
await cfg.update('crcPullSecretPath', undefined, vscode.ConfigurationTarget.Global);
await cfg.update('crcCpuCores', undefined, vscode.ConfigurationTarget.Global);
await cfg.update('crcMemoryAllocated', undefined, vscode.ConfigurationTarget.Global);
await cfg.update('crcNameserver', undefined); // Previously it was saved as `Workspace`
await cfg.update('crcNameserver', undefined, vscode.ConfigurationTarget.Global);
}

static async crcSaveSettings(event) {
await ClusterViewLoader.clearCrcSettings();
const cfg = vscode.workspace.getConfiguration('openshiftToolkit');
await cfg.update('crcBinaryLocation', event.crcLoc, vscode.ConfigurationTarget.Global);
await cfg.update('crcPullSecretPath', event.pullSecret, vscode.ConfigurationTarget.Global);
await cfg.update('crcCpuCores', event.cpuSize, vscode.ConfigurationTarget.Global);
await cfg.update('crcMemoryAllocated', Number.parseInt(event.memory, 10), vscode.ConfigurationTarget.Global);
await cfg.update('crcNameserver', event.nameserver);
await cfg.update('crcNameserver', event.nameserver, vscode.ConfigurationTarget.Global);
}

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

0 comments on commit 5f2bcd7

Please sign in to comment.