Skip to content

Commit

Permalink
ComputerManagementDsc: Uses commands from DscResource.Common
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed Jan 3, 2023
1 parent e312353 commit 6c157b6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 263 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Removed

- ComputerManagementDsc
- The private function `Test-ResourceDscPropertyIsAssigned` was removed as
from now we should use `Test-DscProperty -Name 'MyProperty' -HasValue`, or
`Get-DscProperty -Name 'MyProperty' -HasValue` depending what kind of
return value is needed - Fixes [Issue #407](https://github.com/dsccommunity/ComputerManagementDsc/issues/407).

### Fixed

- ScheduledTask
Expand All @@ -26,6 +34,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
in the module manifest in the source folder as the built module is
automatically updated with this information by the pipeline - Fixes [Issue #396](https://github.com/dsccommunity/ComputerManagementDsc/issues/396).
- Moved the build step of the pipeline to a Windows build worker when running in Azure DevOps.
- Now uses the commands `Get-DscProperty` and `Test-DscProperty` from
the module DscResource.Common - Fixes [Issue #407](https://github.com/dsccommunity/ComputerManagementDsc/issues/407).
- All uses of `Get-DscProperty` was changed to use the named parameter
`Attribute` instead of the parameter alias `Type`.
- All uses of `Test-ResourceHasDscProperty` was changed to use `Test-DscProperty`

## [8.5.0] - 2021-09-13

Expand Down
16 changes: 8 additions & 8 deletions source/Classes/010.ResourceBase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ResourceBase
$this.Assert()

# Get all key properties.
$keyProperty = $this | Get-DscProperty -Type 'Key'
$keyProperty = $this | Get-DscProperty -Attribute 'Key'

Write-Verbose -Message ($this.localizedData.GetCurrentState -f $this.GetType().Name, ($keyProperty | ConvertTo-Json -Compress))

Expand Down Expand Up @@ -66,7 +66,7 @@ class ResourceBase
}
}

if (($this | Test-ResourceHasDscProperty -Name 'Ensure') -and -not $getCurrentStateResult.ContainsKey('Ensure'))
if (($this | Test-DscProperty -Name 'Ensure') -and -not $getCurrentStateResult.ContainsKey('Ensure'))
{
# Evaluate if we should set Ensure property.
if ($keyPropertyAddedToCurrentState)
Expand Down Expand Up @@ -95,7 +95,7 @@ class ResourceBase
Return the correct values for Reasons property if the derived DSC resource
has such property and it hasn't been already set by GetCurrentState().
#>
if (($this | Test-ResourceHasDscProperty -Name 'Reasons') -and -not $getCurrentStateResult.ContainsKey('Reasons'))
if (($this | Test-DscProperty -Name 'Reasons') -and -not $getCurrentStateResult.ContainsKey('Reasons'))
{
# Always return an empty array if all properties are in desired state.
$dscResourceObject.Reasons = $propertiesNotInDesiredState |
Expand All @@ -109,7 +109,7 @@ class ResourceBase
[void] Set()
{
# Get all key properties.
$keyProperty = $this | Get-DscProperty -Type 'Key'
$keyProperty = $this | Get-DscProperty -Attribute 'Key'

Write-Verbose -Message ($this.localizedData.SetDesiredState -f $this.GetType().Name, ($keyProperty | ConvertTo-Json -Compress))

Expand Down Expand Up @@ -145,7 +145,7 @@ class ResourceBase
[System.Boolean] Test()
{
# Get all key properties.
$keyProperty = $this | Get-DscProperty -Type 'Key'
$keyProperty = $this | Get-DscProperty -Attribute 'Key'

Write-Verbose -Message ($this.localizedData.TestDesiredState -f $this.GetType().Name, ($keyProperty | ConvertTo-Json -Compress))

Expand Down Expand Up @@ -186,7 +186,7 @@ class ResourceBase
hidden [System.Collections.Hashtable[]] Compare()
{
# Get the current state, all properties except Read properties .
$currentState = $this.Get() | Get-DscProperty -Type @('Key', 'Mandatory', 'Optional')
$currentState = $this.Get() | Get-DscProperty -Attribute @('Key', 'Mandatory', 'Optional')

return $this.Compare($currentState, @())
}
Expand All @@ -201,7 +201,7 @@ class ResourceBase
hidden [System.Collections.Hashtable[]] Compare([System.Collections.Hashtable] $currentState, [System.String[]] $excludeProperties)
{
# Get the desired state, all assigned properties that has an non-null value.
$desiredState = $this | Get-DscProperty -Type @('Key', 'Mandatory', 'Optional') -HasValue
$desiredState = $this | Get-DscProperty -Attribute @('Key', 'Mandatory', 'Optional') -HasValue

$CompareDscParameterState = @{
CurrentValues = $currentState
Expand All @@ -224,7 +224,7 @@ class ResourceBase
hidden [void] Assert()
{
# Get the properties that has a non-null value and is not of type Read.
$desiredState = $this | Get-DscProperty -Type @('Key', 'Mandatory', 'Optional') -HasValue
$desiredState = $this | Get-DscProperty -Attribute @('Key', 'Mandatory', 'Optional') -HasValue

$this.AssertProperties($desiredState)
}
Expand Down
153 changes: 0 additions & 153 deletions source/Private/Get-DscProperty.ps1

This file was deleted.

40 changes: 0 additions & 40 deletions source/Private/Test-ResourceDscPropertyIsAssigned.ps1

This file was deleted.

62 changes: 0 additions & 62 deletions source/Private/Test-ResourceHasDscProperty.ps1

This file was deleted.

0 comments on commit 6c157b6

Please sign in to comment.