Skip to content

Commit b0c4a7a

Browse files
Merge pull request #212 from PowershellFrameworkCollective/DscModule
2.2.13.176
2 parents 2aa9efb + 1b57a84 commit b0c4a7a

34 files changed

+1096
-2
lines changed

PSModuleDevelopment/PSModuleDevelopment.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# Version number of this module.
77

8-
ModuleVersion = '2.2.12.172'
8+
ModuleVersion = '2.2.13.176'
99

1010
# ID used to uniquely identify this module
1111
GUID = '37dd5fce-e7b5-4d57-ac37-832055ce49d6'

PSModuleDevelopment/changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Changelog
22

3-
## ???
3+
## 2.2.13.176 (2025-05-04)
44

55
+ New: Template AzureFunctionEventGrid - dedicated endpoint template for an EventGrid function
6+
+ New: Template DscClassFile - a script file with a scaffold for individual DSC Resources. Intended for use with the DscModule template.
7+
+ New: Template DscModule - a module designed to host one or multiple DSC Resources
68
+ Upd: Template AzureFunction - now also builds EventGrid triggers.
79

810
## 2.2.12.172 (2024-10-06)

templates/DscClassFile/PSMDInvoke.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
param (
2+
$Path
3+
)
4+
5+
New-PSMDTemplate -FilePath "$PSScriptRoot\þnameþ.ps1" -TemplateName DscClassFile -OutPath $Path -Description "A DSC Resource Class definition" -Author "Friedrich Weinmann" -Tags 'function','file'

templates/DscClassFile/þnameþ.ps1

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
[DscResource()]
2+
class þnameþ {
3+
#region DSC Properties
4+
<#
5+
The properties you can define in configuration settings.
6+
The [DscProperty(...)] attribute has a few possible values:
7+
- <empty>: Nothing specified makes this an optional property you can leave empty when defining the configuration setting.
8+
- Mandatory: A Property that MUST be set when defining the configuration setting.
9+
- Key: The property is considered as the identifier for the resource modified. It is mandatory AND there cannot be multiple configuration entries with the same value for this property!
10+
- NotConfigurable: ReadOnly property. Mostly used for integration into Azure Guest Configurations
11+
12+
Example Properties:
13+
14+
[DscProperty(Key)]
15+
[string]$Path
16+
17+
[DscProperty(Mandatory)]
18+
[string]$Text
19+
20+
[DscProperty(Mandatory)]
21+
[Ensure]$Ensure
22+
#>
23+
24+
[DscProperty(NotConfigurable)]
25+
[Reason[]] $Reasons # Reserved for Azure Guest Configuration
26+
#endregion DSC Properties
27+
28+
[void]Set() {
29+
# Apply Desired State
30+
}
31+
32+
[þnameþ]Get() {
33+
# Return current actual state
34+
}
35+
36+
[bool]Test() {
37+
# Check whether current state = desired state
38+
}
39+
40+
[Hashtable] GetConfigurableDscProperties()
41+
{
42+
# This method returns a hashtable of properties with two special workarounds
43+
# The hashtable will not include any properties marked as "NotConfigurable"
44+
# Any properties with a ValidateSet of "True","False" will beconverted to Boolean type
45+
# The intent is to simplify splatting to functions
46+
# Source: https://gist.github.com/mgreenegit/e3a9b4e136fc2d510cf87e20390daa44
47+
$dscProperties = @{}
48+
foreach ($property in [þnameþ].GetProperties().Name)
49+
{
50+
# Checks if "NotConfigurable" attribute is set
51+
$notConfigurable = [þnameþ].GetProperty($property).GetCustomAttributes($false).Where({ $_ -is [System.Management.Automation.DscPropertyAttribute] }).NotConfigurable
52+
if (!$notConfigurable)
53+
{
54+
$value = $this.$property
55+
# Gets the list of valid values from the ValidateSet attribute
56+
$validateSet = [þnameþ].GetProperty($property).GetCustomAttributes($false).Where({ $_ -is [System.Management.Automation.ValidateSetAttribute] }).ValidValues
57+
if ($validateSet)
58+
{
59+
# Workaround for boolean types
60+
if ($null -eq (Compare-Object @('True', 'False') $validateSet))
61+
{
62+
$value = [System.Convert]::ToBoolean($this.$property)
63+
}
64+
}
65+
# Add property to new
66+
$dscProperties.add($property, $value)
67+
}
68+
}
69+
return $dscProperties
70+
}
71+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
- main
6+
7+
jobs:
8+
build:
9+
10+
runs-on: windows-latest
11+
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Install Prerequisites
15+
run: .\build\vsts-prerequisites.ps1
16+
shell: powershell
17+
- name: Validate
18+
run: .\build\vsts-validate.ps1
19+
shell: powershell
20+
- name: Build
21+
run: .\build\vsts-build.ps1 -ApiKey $env:APIKEY
22+
shell: powershell
23+
env:
24+
APIKEY: ${{ secrets.ApiKey }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on: [pull_request]
2+
3+
jobs:
4+
validate:
5+
6+
runs-on: windows-latest
7+
8+
steps:
9+
- uses: actions/checkout@v1
10+
- name: Install Prerequisites
11+
run: .\build\vsts-prerequisites.ps1
12+
shell: powershell
13+
- name: Validate
14+
run: .\build\vsts-validate.ps1
15+
shell: powershell

templates/DscModule/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
publish
2+
TestResults

templates/DscModule/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) þ!year!þ þauthorþ
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

templates/DscModule/PSMDInvoke.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
param (
2+
$Path
3+
)
4+
New-PSMDTemplate -ReferencePath "$PSScriptRoot" -OutPath $Path

0 commit comments

Comments
 (0)