Skip to content

Commit 32f79b7

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
fix construction of runtime config
1 parent 776a45d commit 32f79b7

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

dsc_lib/src/dscresources/dscresource.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,15 @@ impl Invoke for DscResource {
201201
for property in &self.properties {
202202
resource_properties.insert(property.clone(), Value::Null);
203203
}
204+
let mut resources_map = Map::new();
204205
property_map.insert("properties".to_string(), Value::Object(resource_properties));
206+
resources_map.insert("resources".to_string(), Value::Object(property_map));
205207
let adapter_resource = Resource {
206208
name: self.type_name.clone(),
207209
resource_type: adapter.clone(),
208210
depends_on: None,
209211
metadata: None,
210-
properties: Some(property_map),
212+
properties: Some(resources_map),
211213
};
212214
configuration.resources.push(adapter_resource);
213215
let config_json = serde_json::to_string(&configuration)?;

powershell-adapter/psDscAdapter/powershell.resource.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ switch ($Operation) {
189189
@{ valid = $true } | ConvertTo-Json
190190
}
191191
Default {
192-
Write-Error 'Unsupported operation. Please use one of the following: List, Get, Set, Test, Export, Validate'
192+
Write-DscTrace -Operation Error -Message 'Unsupported operation. Please use one of the following: List, Get, Set, Test, Export, Validate'
193193
}
194194
}
195195

powershell-adapter/psDscAdapter/win_psDscAdapter.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ function Invoke-DscOperation {
377377
# using the cmdlet the appropriate dsc module, and handle errors
378378
try {
379379
Write-DscTrace -Operation Debug -Message "Module: $($cachedDscResourceInfo.ModuleName), Name: $($cachedDscResourceInfo.Name), Property: $($property)"
380-
$invokeResult = Invoke-DscResource -Method $Operation -ModuleName $cachedDscResourceInfo.ModuleName -Name $cachedDscResourceInfo.Name -Property $property
380+
$invokeResult = Invoke-DscResource -Method $Operation -ModuleName $cachedDscResourceInfo.ModuleName -Name $cachedDscResourceInfo.Name -Property $property -ErrorAction Stop
381381

382382
if ($invokeResult.GetType().Name -eq 'Hashtable') {
383383
$invokeResult.keys | ForEach-Object -Begin { $ResultProperties = @{} } -Process { $ResultProperties[$_] = $invokeResult.$_ }

0 commit comments

Comments
 (0)