(GH-172) Enable use of class-based DSC Resources by munging PSModulePath #173
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.
Prior to this PR, it was not possible to use the DSC Base Provider to invoke class-based DSC Resources. DSC
1.1(the version of DSC used by Windows PowerShell5.1) cannot callInvoke-DscResourcefor class- based resources by module path, only by module name; further more, the module containing the DSC Resource must be available in the system levelPSModulePathenvironment variable; munging the process levelPSModulePathdoes not work.This PR updates the DSC Base Provider to:
dscmeta_resource_implementationvalue from a the Puppet Resource API type definition of a resource and inject it into the invocable resource definitionmunge_psmodulepathmethod to return the PowerShell code to modify the system-levelPSModulePathif the invocable resource is is implemented as a PowerShell class; if the resource is any other implementation it instead returns nilinvoke_paramsmethod to set theModuleNamekey to the PowerShell module's name instead of the path to the module's manifest if the resource is implemented as a PowerShell classmunge_psmodulepathinto the output from theps_script_contentmethod to ensure it will be called when invoking the resourcefinallyblock which resets thePSModulePathif it was munged earlier in the invocation script, regardless of whether or not the invocation errorsTODO:
munge_psmodulepath