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

Add DSC class-based resource BootstrapPSResourceGet #14

Merged
merged 21 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/analyzersettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

TypeNotFound - Because classes in the project cannot be found unless built.
RequiresModuleInvalid - Because 'using module' in prefix.ps1 cannot be resolved as source file.
DscResourceInvalidKeyProperty - Because the enum type are not defined in the source file, only built module.
#>
ExcludeRules = @()

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- DSC class-based resource `BootstrapPSResourceGet'.

### Fixed

- Reverted resolve dependency logic so that GitHub actions works.
Expand Down
2 changes: 2 additions & 0 deletions RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
#xDscResourceDesigner = 'latest'

# Build dependencies needed for using the module
'DscResource.Base' = 'latest'
#'DscResource.Common' = 'latest'
'DscResource.Common' = @{
Version = 'latest'
Parameters = @{
AllowPrerelease = $true
}
}

# Analyzer rules
'DscResource.AnalyzerRules' = 'latest'
'Indented.ScriptAnalyzerRules' = 'latest'
Expand Down
51 changes: 43 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,54 @@ stages:
buildType: 'current'
artifactName: $(buildArtifactName)
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'
# - task: PowerShell@2
# name: configureWinRM
# displayName: 'Configure WinRM'
# inputs:
# targetType: 'inline'
# script: 'winrm quickconfig -quiet'
# pwsh: false
- task: PowerShell@2
name: test
displayName: 'Run Integration Test'
inputs:
filePath: './build.ps1'
arguments: "-Tasks test -CodeCoverageThreshold 0 -PesterPath 'tests/Integration' -PesterExcludeTag 'BootstrapScript'"
arguments: "-Tasks test -CodeCoverageThreshold 0 -PesterPath 'tests/Integration' -PesterExcludeTag @('BootstrapScript','DSC')"
pwsh: $(PWSH)
- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
testRunTitle: 'Integration ($(Agent.JobName))'

- job: Test_Integration_DSC
displayName: 'Integration DSC'
strategy:
matrix:
WIN2019:
JOB_VMIMAGE: 'windows-2019'
PWSH: false
WIN2022:
JOB_VMIMAGE: 'windows-2022'
PWSH: false
pool:
vmImage: $(JOB_VMIMAGE)
timeoutInMinutes: 0
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download Build Artifact'
inputs:
buildType: 'current'
artifactName: $(buildArtifactName)
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'
- task: PowerShell@2
name: configureWinRM
displayName: 'Configure WinRM'
inputs:
targetType: 'inline'
script: 'winrm quickconfig -quiet'
pwsh: false
- task: PowerShell@2
name: test
displayName: 'Run Integration Test'
inputs:
filePath: './build.ps1'
arguments: "-Tasks test -CodeCoverageThreshold 0 -PesterPath 'tests/Integration' -PesterTag 'DSC'"
pwsh: $(PWSH)
- task: PublishTestResults@2
displayName: 'Publish Test Results'
Expand Down
8 changes: 8 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,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 @@ -143,6 +149,7 @@ Pester:
OutputEncoding: ascii
ExcludeFromCodeCoverage:
- Modules/DscResource.Common
- Modules/DscResource.Base

####################################################
# Pester Configuration (DscResource.Test) #
Expand All @@ -166,6 +173,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
- PSResourceGet.Bootstrap.psm1
MainGitBranch: main
Expand Down
22 changes: 22 additions & 0 deletions source/Classes/001.PSResourceGetBootstrapReason.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<#
.SYNOPSIS
The reason a property of a DSC resource is not in desired state.

.DESCRIPTION
A DSC resource can have a read-only property `Reasons` that the compliance
part (audit via Azure Policy) of Azure AutoManage Machine Configuration
uses. The property Reasons holds an array of PSResourceGetBootstrapReason.
Each PSResourceGetBootstrapReason explains why a property of a DSC resource
is not in desired state.
#>

class PSResourceGetBootstrapReason
{
[DscProperty()]
[System.String]
$Code

[DscProperty()]
[System.String]
$Phrase
}
Loading
Loading