Skip to content

Commit b5890dd

Browse files
authored
Merge branch 'main' into gh-57/main/add-shallowmerge-function
2 parents 5c36b4a + 36c0650 commit b5890dd

File tree

135 files changed

+11103
-1295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+11103
-1295
lines changed

Cargo.lock

Lines changed: 54 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ members = [
66
"dsc",
77
"lib/dsc-lib",
88
"lib/dsc-lib-jsonschema",
9+
"lib/dsc-lib-jsonschema-macros",
910
"resources/dscecho",
1011
"lib/dsc-lib-osinfo",
1112
"resources/osinfo",
@@ -29,6 +30,7 @@ default-members = [
2930
"dsc",
3031
"lib/dsc-lib",
3132
"lib/dsc-lib-jsonschema",
33+
"lib/dsc-lib-jsonschema-macros",
3234
"resources/dscecho",
3335
"lib/dsc-lib-osinfo",
3436
"resources/osinfo",
@@ -54,6 +56,7 @@ Windows = [
5456
"dsc",
5557
"lib/dsc-lib",
5658
"lib/dsc-lib-jsonschema",
59+
"lib/dsc-lib-jsonschema-macros",
5760
"resources/dscecho",
5861
"lib/dsc-lib-osinfo",
5962
"resources/osinfo",
@@ -74,6 +77,7 @@ macOS = [
7477
"dsc",
7578
"lib/dsc-lib",
7679
"lib/dsc-lib-jsonschema",
80+
"lib/dsc-lib-jsonschema-macros",
7781
"resources/dscecho",
7882
"lib/dsc-lib-osinfo",
7983
"resources/osinfo",
@@ -91,6 +95,7 @@ Linux = [
9195
"dsc",
9296
"lib/dsc-lib",
9397
"lib/dsc-lib-jsonschema",
98+
"lib/dsc-lib-jsonschema-macros",
9499
"resources/dscecho",
95100
"lib/dsc-lib-osinfo",
96101
"resources/osinfo",
@@ -130,6 +135,8 @@ clap_complete = { version = "4.5" }
130135
crossterm = { version = "0.29" }
131136
# dsc
132137
ctrlc = { version = "3.5" }
138+
# dsc-lib-jsonschema-macros
139+
darling = { version = "0.23" }
133140
# dsc-lib
134141
derive_builder = { version = "0.20" }
135142
# dsc, dsc-lib
@@ -150,6 +157,10 @@ num-traits = { version = "0.2" }
150157
os_info = { version = "3.13" }
151158
# dsc, dsc-lib
152159
path-absolutize = { version = "3.1" }
160+
# dsc-lib-jsonschema-macros
161+
proc-macro2 = { version = "1.0" }
162+
# dsc-lib-jsonschema-macros
163+
quote = { version = "1.0" }
153164
# dsc, dsc-lib
154165
regex = { version = "1.12" }
155166
# registry, dsc-lib-registry
@@ -170,6 +181,8 @@ serde = { version = "1.0", features = ["derive"] }
170181
serde_json = { version = "1.0", features = ["preserve_order"] }
171182
# dsc, dsc-lib, y2j
172183
serde_yaml = { version = "0.9" }
184+
# dsc-lib-jsonschema-macros
185+
syn = { version = "2.0" }
173186
# dsc, y2j
174187
syntect = { version = "5.3", features = ["default-fancy"], default-features = false }
175188
# dsc, process
@@ -200,7 +213,7 @@ utfx = { version = "0.1" }
200213
uuid = { version = "1.18", features = ["v4"] }
201214
# dsc-lib, dsc-lib-jsonschema
202215
url = { version = "2.5" }
203-
# dsc-lib
216+
# dsc-lib, dsc-lib-jsonschema
204217
urlencoding = { version = "2.1" }
205218
# dsc-lib
206219
which = { version = "8.0" }
@@ -218,6 +231,7 @@ pretty_assertions = { version = "1.4.1" }
218231
# Workspace crates as dependencies
219232
dsc-lib = { path = "lib/dsc-lib" }
220233
dsc-lib-jsonschema = { path = "lib/dsc-lib-jsonschema" }
234+
dsc-lib-jsonschema-macros = { path = "lib/dsc-lib-jsonschema-macros" }
221235
dsc-lib-osinfo = { path = "lib/dsc-lib-osinfo" }
222236
dsc-lib-security_context = { path = "lib/dsc-lib-security_context" }
223237
tree-sitter-dscexpression = { path = "grammars/tree-sitter-dscexpression" }

adapters/powershell/Tests/TestClassResource/0.0.1/TestClassResource.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ VariablesToExport = @()
3434
AliasesToExport = @()
3535

3636
# DSC resources to export from this module
37-
DscResourcesToExport = @('TestClassResource', 'NoExport')
37+
DscResourcesToExport = @('TestClassResource', 'NoExport', 'FilteredExport')
3838

3939
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
4040
PrivateData = @{

adapters/powershell/Tests/TestClassResource/0.0.1/TestClassResource.psm1

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,52 @@ class NoExport: BaseTestClass
155155
}
156156
}
157157

158+
[DscResource()]
159+
class FilteredExport : BaseTestClass
160+
{
161+
[DscProperty(Key)]
162+
[string] $Name
163+
164+
[DscProperty()]
165+
[string] $Prop1
166+
167+
[void] Set()
168+
{
169+
}
170+
171+
[bool] Test()
172+
{
173+
return $true
174+
}
175+
176+
[FilteredExport] Get()
177+
{
178+
return $this
179+
}
180+
181+
static [FilteredExport[]] Export()
182+
{
183+
$resultList = [List[FilteredExport]]::new()
184+
$obj = New-Object FilteredExport
185+
$obj.Name = "DefaultObject"
186+
$obj.Prop1 = "Default Property"
187+
$resultList.Add($obj)
188+
189+
return $resultList.ToArray()
190+
}
191+
192+
static [FilteredExport[]] Export([FilteredExport]$Name)
193+
{
194+
$resultList = [List[FilteredExport]]::new()
195+
$obj = New-Object FilteredExport
196+
$obj.Name = $Name
197+
$obj.Prop1 = "Filtered Property for $Name"
198+
$resultList.Add($obj)
199+
200+
return $resultList.ToArray()
201+
}
202+
}
203+
158204
function Test-World()
159205
{
160206
"Hello world from PSTestModule!"

adapters/powershell/Tests/powershellgroup.config.tests.ps1

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,49 @@ Describe 'PowerShell adapter resource tests' {
105105
$out | Should -BeLike "*ERROR*Export method not implemented by resource 'TestClassResource/NoExport'*"
106106
}
107107

108+
It 'Export works with filtered export property' {
109+
$yaml = @'
110+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
111+
resources:
112+
- name: Working with class-based resources
113+
type: Microsoft.DSC/PowerShell
114+
properties:
115+
resources:
116+
- name: Class-resource Info
117+
type: TestClassResource/FilteredExport
118+
properties:
119+
Name: 'FilteredExport'
120+
'@
121+
$out = $yaml | dsc -l trace config export -f - 2> "$TestDrive/export_trace.txt"
122+
$LASTEXITCODE | Should -Be 0
123+
$res = $out | ConvertFrom-Json
124+
$res.'$schema' | Should -BeExactly 'https://aka.ms/dsc/schemas/v3/bundled/config/document.json'
125+
$res.'resources' | Should -Not -BeNullOrEmpty
126+
$res.resources[0].properties.result.count | Should -Be 1
127+
$res.resources[0].properties.result[0].Name | Should -Be "FilteredExport"
128+
$res.resources[0].properties.result[0].Prop1 | Should -Be "Filtered Property for FilteredExport"
129+
"$TestDrive/export_trace.txt" | Should -FileContentMatch "Properties provided for filtered export"
130+
}
131+
132+
It 'Export fails when filtered export is requested but not implemented' {
133+
$yaml = @'
134+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
135+
resources:
136+
- name: Working with class-based resources
137+
type: Microsoft.DSC/PowerShell
138+
properties:
139+
resources:
140+
- name: Class-resource Info
141+
type: TestClassResource/NoExport
142+
properties:
143+
Name: 'SomeFilter'
144+
'@
145+
$out = $yaml | dsc config export -f - 2>&1 | Out-String
146+
$LASTEXITCODE | Should -Be 2
147+
$out | Should -Not -BeNullOrEmpty
148+
$out | Should -BeLike "*ERROR*Export method with parameters not implemented by resource 'TestClassResource/NoExport'*"
149+
}
150+
108151
It 'Custom psmodulepath in config works' {
109152

110153
$OldPSModulePath = $env:PSModulePath

adapters/powershell/psDscAdapter/powershell.resource.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ switch ($Operation) {
181181
# process the INPUT (desiredState) for each resource as dscresourceInfo and return the OUTPUT as actualState
182182
$actualState = $psDscAdapter.invoke( { param($op, $ds, $dscResourceCache) Invoke-DscOperation -Operation $op -DesiredState $ds -dscResourceCache $dscResourceCache }, $Operation, $ds, $dscResourceCache)
183183
if ($null -eq $actualState) {
184-
Write-DscTrace -Operation Error -Message 'Incomplete GET for resource ' + $ds.Name
184+
"Failed to invoke operation '{0}' for resource name '{1}'." -f $Operation, $ds.Name | Write-DscTrace -Operation Error
185185
exit 1
186186
}
187187
if ($null -ne $actualState.Properties -and $actualState.Properties.InDesiredState -eq $false) {

0 commit comments

Comments
 (0)