microsoft / Requirements

PowerShell framework for declaratively defining and idempotently imposing system configurations
MIT License
159 stars 26 forks source link

DSC resources broken in latest version #58

Closed plaisted closed 4 years ago

plaisted commented 4 years ago

Latest version still uses the deprecated "Name" property when creating DSC based requirement:

  switch ($PSCmdlet.ParameterSetName) {
    "Script" {
      [Requirement]@{
        Namespace = $Namespace
        Describe  = $Describe
        Test      = $Test
        Set       = $Set
        DependsOn = $DependsOn
      }
    }
    "Dsc" {
      $dscParams = @{
        Name       = $ResourceName
        ModuleName = $ModuleName
        Property   = $Property
      }
      [Requirement]@{
        Name      = $Namespace
        Describe  = $Describe
        Test      = { Invoke-DscResource -Method "Test" @dscParams }.GetNewClosure()
        Set       = { Invoke-DscResource -Method "Set" @dscParams }.GetNewClosure()
        DependsOn = $DependsOn
      }
    }
  }

The DSC portion needs to be updated to

      [Requirement]@{
        Namespace      = $Namespace
        Describe  = $Describe
        Test      = { Invoke-DscResource -Method "Test" @dscParams }.GetNewClosure()
        Set       = { Invoke-DscResource -Method "Set" @dscParams }.GetNewClosure()
        DependsOn = $DependsOn
      }

Would submit PR but don't have CLA...

chriskuech commented 4 years ago

I'll fix this when PowerShell 7 ships, adding xplat support for Invoke-DscResource. Right now all our Pester tests fail on PowerShell 5 and are hard to resolve due to how Windows shipped PowerShell 5 and Pester.

chriskuech commented 4 years ago

This has been fixed. Unfortunately due to other issues, we can't add PowerShell 7 DSC support.