Skip to content
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

BREAKING CHANGE: New Scope property breaks DSC Resource #14

Closed
jpogran opened this issue Feb 6, 2018 · 9 comments
Closed

BREAKING CHANGE: New Scope property breaks DSC Resource #14

jpogran opened this issue Feb 6, 2018 · 9 comments
Labels
breaking change When used on an issue, the issue has been determined to be a breaking change. bug The issue is a bug.

Comments

@jpogran
Copy link

jpogran commented Feb 6, 2018

Commit cacd235 added the Scope property to the xPowerShellExecutionPolicy DSC Resource, however according to the DMTF specification (page 37) Scope is a reserved keyword, and results in this DSC Resource being unusable. This change also prevents us from including this release in the Puppet dsc module. I replicated this on PowerShell 5.1 on a fresh machine, with a Install-Module -Name xPowerShellExecutionPolicy using the PowerShellGallery feed, which pulls down version 2.0.0.0.

Attempting to use the DSC Resource results in a failure to find it:

PS C:\> Invoke-DscResource -Name xPowerShellExecutionPolicy -Property @{ ExecutionPolicy = 'RemoteSigned' } -Verbose -Method Test -ModuleName xPowerShellExecutionPolicy
Invoke-DscResource : Resource xPowerShellExecutionPolicy was not found as one of the builtin resources. Please add -ModuleName
parameter to include external resources.
At line:1 char:1
+ Invoke-DscResource -Name xPowerShellExecutionPolicy -Property @{ Exec ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-DscResource], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.DesiredStateConfiguration.Commands.InvokeDscResourceMethod
   Command

This is because it fails parsing with the syntax error from usage of the word scope:

PS C:\> Get-DscResource
ImportCimAndScriptKeywordsFromModule : Cim deserializer threw an error when deserializing file C:\Program Files\Windows
PowerShell\Modules\xPowerShellExecutionPolicy\2.0.0.0\DSCResources\MSFT_xPowerShellExecutionPolicy\MSFT_xPowerShellExec
utionPolicy.Schema.mof.
At
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:4143
char:29
+ ...     $null = ImportCimAndScriptKeywordsFromModule -Module $mod -Resour ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], PSInvalidOperationException
    + FullyQualifiedErrorId : System.Management.Automation.PSInvalidOperationException,ImportCimAndScriptKeywordsFromM
   odule

ImportCimAndScriptKeywordsFromModule : Syntax error:
 At line:6, char:276
 Buffer:
erPolicy"}] String Scope^;
};
At
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:4143
char:29
+ ...     $null = ImportCimAndScriptKeywordsFromModule -Module $mod -Resour ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], CimException
    + FullyQualifiedErrorId : Microsoft.Management.Infrastructure.CimException,ImportCimAndScriptKeywordsFromModule

The fix would be to choose a different name for the Scope property, something like ScopeLevel or ExecutionPolicyScope. I can put up a PR to fix that, but wanted to ask first what name to use.

@michaeltlombardi
Copy link

#9 is also impacted by this.

jpogran added a commit to jpogran/puppetlabs-dsc that referenced this issue Feb 7, 2018
@TraGicCode
Copy link
Contributor

TraGicCode commented Feb 19, 2018

I was able to verify this was broken as well. ScopeLevel seems reasonable to me.

/cc @kwirkykat

@zjalexander
Copy link

@mgreenegit

@johlju johlju added bug The issue is a bug. in progress The issue is being actively worked on by someone. breaking change When used on an issue, the issue has been determined to be a breaking change. labels Apr 22, 2018
@MattAllison
Copy link

I know I'm late to the party but I just hit this bug. Recommend "PolicyScope" or "ExecutionPolicyScope" as the parameter name. May be more intuitive than ScopeLevel.

@johlju
Copy link
Member

johlju commented Apr 24, 2018

@MattAllison Never to late to come with suggestions! @TraGicCode is working on this in PR #15. @TraGicCode what is you opinion about @MattAllison's proposal?

@TraGicCode
Copy link
Contributor

I'm okay with the recommendation. No problem on my end with changing this. I'm in favor of long names so i shall pick ExecutionPolicyScope :). Sound good @MattAllison ?

@johlju
Copy link
Member

johlju commented Apr 25, 2018

@TraGicCode we are three in favor of 'ExecutionPolicyScope' so I propose we go with that. 😃

@MattAllison
Copy link

I'm good with the verbose parameter name. Thank you!

@TraGicCode
Copy link
Contributor

I will work on this now.

@johlju johlju changed the title New Scope property breaks DSC Resource BREAKING CHANGE: New Scope property breaks DSC Resource Apr 26, 2018
@johlju johlju closed this as completed in #15 May 4, 2018
johlju pushed a commit that referenced this issue May 4, 2018
- BREAKING CHANGE: Renamed the 'Scope' Parameter to 'ExecutionPolicyScope' since
  errors are thrown when the MOF file is parsed because 'Scope' is a reserved
  keyword in the DMTF Specification (issue #14).
@johlju johlju removed the in progress The issue is being actively worked on by someone. label May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change When used on an issue, the issue has been determined to be a breaking change. bug The issue is a bug.
Projects
None yet
Development

No branches or pull requests

6 participants