-
Notifications
You must be signed in to change notification settings - Fork 31
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
dsc get fails when using powershellgroup resources #260
Comments
This PR by Michael should fix this problem. |
This behavior is specific to mof-based PSDSC Resources. It's actually both a very common and a very frustrating problem for integrating with legacy PSDSC resources, even in v1.1. From an API contract perspective, the root problem is that the implementation of the MOF-based resource doesn't respect its declared API surface:
In the case of I ran into this when I was working on |
That makes sense. Is the overall strategic intent for resource content to be refactored in new languages with strong API contracts? Selfishly, I'd like the end result to be a lot like how Terraform behaves with the executable managing implementation graph ordering, config file parsing, resource exectuation, and downloading and managing the resource providers. I also like that they have 'official' resource providers owned by the corporate partners. |
DSCv3 definitely aims to have stronger API contracts. General command-based DSC Resources, which can be authored in any language - a go binary, a python script, a bash script, a sub-command for a dotnet CLI tool - are required to define a JSON Schema that is used as the API contract for the resource properties. DSC can then validate the data a user passes in before sending it to the resource and, equally important, validate the data a resource returns against that schema. |
@michaeltlombardi and @anmenaga - Is there a timetable on the alpha.4 or alpha.5 release? I'm trying to do a very early demo with my customer to get feedback on what they would like to see as well as talk through the current concept and all the examples I've tried so far fail when using the alpha.3 release. |
@jchancellor-ms - We've started the release process for |
@anmenaga this still fails, but not because of the property, but |
|
Prerequisites
Steps to reproduce
Based on powershell sample here - (https://learn.microsoft.com/en-us/powershell/dsc/reference/psdscresources/resources/windowsfeature/example?view=dsc-2.0) - Invoke-DSCResource 's get method only accepts a subset of the properties and isn't smart enough to throw the unnecessary items away.
This results in errors similar to the following: "Get-TargetResource: A parameter cannot be found that matches parameter name 'Ensure'" when running dsc get.
I was able to work around this temporarily by adding the following code to the powershellgroup.resource.ps1 file after line 165. However, a more formal fix should probably be reviewed to determine if things like Credentials need to be retained and how to get them for each resource type.
$nonGetProperties = ((Get-DscResource -Name $ResourceTypeName -Module $ModuleName).Properties | where {$_.IsMandatory -eq $false}).Name foreach ($property in $nonGetProperties){ $inputht.remove($property) }
My config yaml file is as follows:
Expected behavior
dsc get should complete discovery of the resource
Actual behavior
Error: "Get-TargetResource: A parameter cannot be found that matches parameter name 'Ensure'"
Error details
"Get-TargetResource: A parameter cannot be found that matches parameter name 'Ensure'"
Environment data
Version
7.3.9
Visuals
No response
The text was updated successfully, but these errors were encountered: