Skip to content
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

CRC setup is reseted after closing its window #4411 #4437

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
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
Loading