-
Notifications
You must be signed in to change notification settings - Fork 205
Hash table returned from Get-TargetResource must contain all properties in the schema.mof #318
Comments
@kwirkykat @mbreakey3 (or anyone else) can you answer this question? |
There is a semantic in powershell where the first object emitted to
pipeline defines the structure for all other objects. It is best practice
to create a new psobject and populate all fields, even if the value is
$null. To demonstrate, take an array of $a and $b where $a = new-object
PSObject -Property @{ A = 'a' } and $b has B = 'b'. Take turns emitting $a
or $b first. So if you have calls to a bunch of remote machines, they all
need to return the same shape or you lose data on the pipeline.
Sorry, I'm on phone or I would give better examples.
Scottley
…On Sep 10, 2017 3:14 AM, "Johan Ljunggren" ***@***.***> wrote:
@kwirkykat <https://github.com/kwirkykat> @mbreakey3
<https://github.com/mbreakey3> (or anyone else) can you answer this
question?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#318 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHhqNx6jsafM1qX_0iEmymE26G0ocWwXks5sg7ZtgaJpZM4PSRQE>
.
|
@johlju It's in the official DSC docs
|
Yes, thats the same paragraph I quoted in the initial issue comment. |
@johlju, thanks for raising the question/issue. I was looking at this today and realized there currently isn't a common test for this. |
@kwirkykat Is it okay that I add this to the best practices guideline and also write a common test for this (that will write warnings for the time being)? |
While I agree that in most situations the Get-TargetResource should return actual values I think its important that the guidance is clarified for resources which include Add and Remove Properties (Such as the Group Resource) and resources with specific Credential objects as these don't lend themselves to returning useful values. A simple way to handle with would be to allow test opt-outs for specific parameters against a known set of criteria in a similar way that |
I suggest we move this issue to DscResource.Tests so that we can add a test for this. |
I have created an issue in DscResource.Tests which referencing this issue. Closing this issue here, and suggest moving any further discussion to the issue PowerShell/DscResource.Tests#220. |
For reference, this error is output when trying to return a property that does not exist in the schema. Unfortunately there is apparently not the similiar check when the hash table is not returning all properties in the schema.
|
I trying to figure out this question; Must the Get-TargetResource always return a hash table containing all the properties in the scheme.mof?
I think @kwirkykat might have mention this somewhere - but finding that is like a needle in a hay stack.
I can't find this in any guideline or common test. I can only find this text.
So if this is true, then we should have a common test for it. Because then I have this problem in many resources!
The text was updated successfully, but these errors were encountered: