Skip to content

Commit

Permalink
SqlServerDsc: Use ResourceBase from DscResource.Base (#1826)
Browse files Browse the repository at this point in the history
- SqlServerDsc
  - Class-based resources now uses the parent class `ResourceBase` from the
    module _DscResource.Base_ (issue #1790).
  - Removed private function `Test-ResourceDscPropertyIsAssigned` and
    `Test-ResourceHasDscProperty`. Both are replaced by `Test-DscProperty`
    which is now part of the module _DscResource.Common_.
  - Removed private function `Get-DscProperty`. It is replaced by `Get-DscProperty`
    which is now part of the module _DscResource.Common_.
  - The class `ResourceBase` and `Reason` has been removed, they are now
    part of the module _DscResource.Base_.
  - The enum `Ensure` has been removed, is is now part of the module
    _DscResource.Base_.
  - The private functions that the class `ResourceBase` depended on has been
    moved to the module _DscResource.Base_.
    - `ConvertFrom-CompareResult`
    - `ConvertTo-Reason`
    - `Get-ClassName`
    - `Get-LocalizedDataRecursive`
  • Loading branch information
johlju authored Jan 3, 2023
1 parent 4814bee commit 914c53c
Show file tree
Hide file tree
Showing 30 changed files with 48 additions and 4,021 deletions.
1 change: 1 addition & 0 deletions .vscode/analyzersettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
# TODO: This is not excluded correctly, see test QA/ScriptAnalyzer.Tests.ps1 for more information.
ExcludeRules = @(
'TypeNotFound'
'RequiresModuleInvalid' # Becuase 'using module' in prefix.ps1 cannot be resolved as source file.
)

Rules = @{
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

- SqlServerDsc
- Removed `Assert-ElevatedUser` from private functions - [Issue #1797](https://github.com/dsccommunity/SqlServerDsc/issues/1797)
- Removed `Assert-ElevatedUser` from private functions ([issue #1797](https://github.com/dsccommunity/SqlServerDsc/issues/1797)).
- `Assert-ElevatedUser` added to _DscResource.Common_ public functions
([issue #82](https://github.com/dsccommunity/DscResource.Common/issues/82)).
- Removed `Test-IsNumericType` from private functions ([issue #1795](https://github.com/dsccommunity/SqlServerDsc/issues/1795)).
Expand All @@ -20,6 +20,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed `Assert-RequiredCommandParameter` from private functions ([issue #1796](https://github.com/dsccommunity/SqlServerDsc/issues/1796)).
- Replaced by `Assert-BoundParameter` (part of _DscResource.Common_)
that had a new parameter set added ([issue #92](https://github.com/dsccommunity/DscResource.Common/issues/92)).
- Removed private function `Test-ResourceDscPropertyIsAssigned` and
`Test-ResourceHasDscProperty`. Both are replaced by `Test-DscProperty`
which is now part of the module _DscResource.Common_.
- Removed private function `Get-DscProperty`. It is replaced by `Get-DscProperty`
which is now part of the module _DscResource.Common_.
- The class `ResourceBase` and `Reason` has been removed, they are now
part of the module _DscResource.Base_.
- The enum `Ensure` has been removed, is is now part of the module
_DscResource.Base_.
- The private functions that the class `ResourceBase` depended on has been
moved to the module _DscResource.Base_.
- `ConvertFrom-CompareResult`
- `ConvertTo-Reason`
- `Get-ClassName`
- `Get-LocalizedDataRecursive`

### Added

Expand Down Expand Up @@ -68,6 +83,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update to build module in separate folder under `output`.
- Moved the build step of the pipeline to a Windows build worker when
running in Azure DevOps.
- Class-based resources now uses the parent class `ResourceBase` from the
module _DscResource.Base_ ([issue #1790](https://github.com/dsccommunity/SqlServerDsc/issues/1790)).
- Settings for the _Visual Studio Code_ extension _Pester Tests_ was changed
to be able to run all unit tests, and all tests run by the extension
are now run in a separate process to be able to handle changes in
Expand Down
5 changes: 4 additions & 1 deletion RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
Sampler = 'latest'
'Sampler.GitHubTasks' = 'latest'
MarkdownLinkCheck = 'latest'
'DscResource.Common' = 'latest'
'DscResource.Test' = 'latest'
xDscResourceDesigner = 'latest'
'DscResource.DocGenerator' = 'latest'

# Build dependencies needed for using the module
'DscResource.Base' = 'latest'
'DscResource.Common' = 'latest'

# Analyzer rules
'DscResource.AnalyzerRules' = 'latest'
'Indented.ScriptAnalyzerRules' = 'latest'
Expand Down
8 changes: 8 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ NestedModule:
AddToManifest: false
Exclude: PSGetModuleInfo.xml

DscResource.Base:
CopyOnly: true
Path: ./output/RequiredModules/DscResource.Base
AddToManifest: false
Exclude: PSGetModuleInfo.xml

####################################################
# Pester Configuration (Sampler) #
####################################################
Expand All @@ -99,6 +105,7 @@ Pester:
OutputEncoding: ascii
ExcludeFromCodeCoverage:
- Modules/DscResource.Common
- Modules/DscResource.Base

####################################################
# Pester Configuration (DscResource.Test) #
Expand All @@ -121,6 +128,7 @@ DscTest:
- output
ExcludeModuleFile:
- Modules/DscResource.Common
- Modules/DscResource.Base
# Must exclude built module file because it should not be tested like MOF-based resources
- SqlServerDsc.psm1
MainGitBranch: main
Expand Down
10 changes: 0 additions & 10 deletions source/Classes/002.Reason.ps1

This file was deleted.

260 changes: 0 additions & 260 deletions source/Classes/010.ResourceBase.ps1

This file was deleted.

3 changes: 2 additions & 1 deletion source/Classes/011.SqlResourceBase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class SqlResourceBase : ResourceBase
[Reason[]]
$Reasons

SqlResourceBase () : base ()
# Passing the module's base directory to the base constructor.
SqlResourceBase () : base ($PSScriptRoot)
{
$this.SqlServerObject = $null
}
Expand Down
4 changes: 2 additions & 2 deletions source/Classes/020.SqlAudit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ class SqlAudit : SqlResourceBase
}

# Get all optional properties that has an assigned value.
$assignedOptionalDscProperties = $this | Get-DscProperty -HasValue -Type 'Optional' -ExcludeName @(
$assignedOptionalDscProperties = $this | Get-DscProperty -HasValue -Attribute 'Optional' -ExcludeName @(
# Remove optional properties that is not an audit property.
'ServerName'
'Ensure'
Expand Down Expand Up @@ -565,7 +565,7 @@ class SqlAudit : SqlResourceBase
hidden [System.Object] CreateAudit()
{
# Get all properties that has an assigned value.
$assignedDscProperties = $this | Get-DscProperty -HasValue -Type @(
$assignedDscProperties = $this | Get-DscProperty -HasValue -Attribute @(
'Key'
'Optional'
) -ExcludeName @(
Expand Down
Loading

0 comments on commit 914c53c

Please sign in to comment.