(GH-110) Handle missing PSDesiredStateConfiguration module for ps group resource #112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
Prior to this change, the PowerShell group resource would fail unexpectedly for operations that didn't include the group, like invoking a different resource.
When the resource's script failed to import the PSDesiredStateConfiguration module, the script errors would bubble up through any DSC invocation. For
get
,set
, andtest
operations, this is desirable, but not forlist
, where a missing module means that the group can't provide any resources. Instead of breaking execution for other resources, the script should exit with code0
forlist
operations.PR Context
This change:
Adds logic to the beginning of the resource's script, checking for the PSDesiredStateConfiguration module.
If the module isn't found, the script raises an error.
For the list operation, the script exits with code
0
- being unable to list the DSC Resources is expected on systems that may not have the module installed and aren't trying to list PowerShell DSC Resources explicitly.For now, the script has no way to distinguish between being called for a general list operation, like before a
dsc resource get
command, and a specific list operation, likedsc resource list DSC/PowerShellGroup
. It would make sense for the operation to exit with code1
for the latter.For non-list operations, the script exits with code
1
.