Skip to content

Commit 2429268

Browse files
committed
(GH-670) Guard installType and installDirectory
Add more explanation to the settings for installDirectory and installType using new VS Code Settings API that explains when to use each setting. Add a guard clause early on in the activation process that warns when settings are used that are incompatible. The extension works when there is both pdk and agent present, and when only one is present. The problem here is that the settings for the extension are not helping the user choose successful configurations and allowing mixing of settings that then produce incorrect paths to the parts of puppet we need. The intention for auto was to not use installDirectory or installType, so that the extension would choose whether to use pdk or agent and which paths to use itself. This was intended to make the default 'happy path' the situation where a user has pdk installed to the default path and not require the user to set any settings.
1 parent 12de07f commit 2429268

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,17 +472,21 @@
472472
},
473473
"puppet.installDirectory": {
474474
"type": "string",
475-
"default": null,
476-
"description": "The fully qualified path to the Puppet install directory. This can be a PDK or Puppet Agent installation. For example: 'C:\\Program Files\\Puppet Labs\\Puppet' or '/opt/puppetlabs/puppet'. If this is not set the extension will attempt to detect the installation directory"
475+
"markdownDescription": "The fully qualified path to the Puppet install directory. This can be a PDK or Puppet Agent installation. For example: 'C:\\Program Files\\Puppet Labs\\Puppet' or '/opt/puppetlabs/puppet'. If this is not set the extension will attempt to detect the installation directory. Do **not** use when `#puppet.installType#` is set to `auto`"
477476
},
478477
"puppet.installType": {
479478
"type": "string",
480479
"default": "auto",
481-
"description": "The type of Puppet installation. Either the Puppet Development Kit (pdk) or the Puppet Agent (agent). Choose 'auto' to have the extension detect which to use automatically based on default install locations",
480+
"markdownDescription": "The type of Puppet installation. Either the Puppet Development Kit (pdk) or the Puppet Agent (agent). Choose `auto` to have the extension detect which to use automatically based on default install locations",
482481
"enum": [
483482
"auto",
484483
"pdk",
485484
"agent"
485+
],
486+
"enumDescriptions": [
487+
"The exention will use the PDK or the Puppet Agent based on default install locations. When both are present, it will use the PDK",
488+
"Use the PDK as an installation source",
489+
"Use the Puppet Agent as an installation source"
486490
]
487491
},
488492
"puppet.notification.nodeGraph": {

src/settings.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,22 @@ export function SettingsFromWorkspace(): ISettings {
170170
pdk: workspaceConfig.get<IPDKSettings>('pdk', defaults.pdk),
171171
};
172172

173+
if (settings.installDirectory && settings.installType === PuppetInstallType.AUTO) {
174+
const message =
175+
"Do not use 'installDirectory' and set 'installType' to auto. The 'installDirectory' setting" +
176+
' is meant for custom installation directories that will not be discovered by the extension';
177+
const title = 'Configuration Information';
178+
const helpLink = 'https://puppet-vscode.github.io/docs/extension-settings';
179+
vscode.window.showErrorMessage(message, { modal: false }, { title: title }).then((item) => {
180+
if (item === undefined) {
181+
return;
182+
}
183+
if (item.title === title) {
184+
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(helpLink));
185+
}
186+
});
187+
}
188+
173189
/**
174190
* Legacy Workspace Settings
175191
*

0 commit comments

Comments
 (0)