Skip to content

Commit 1bb0fb0

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
Remove unncessary context property
1 parent 95c1f1e commit 1bb0fb0

File tree

4 files changed

+14
-48
lines changed

4 files changed

+14
-48
lines changed

dsc_lib/src/configure/config_doc.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ use std::collections::HashMap;
99

1010
use crate::{dscerror::DscError, schemas::DscRepoSchema};
1111

12-
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)]
13-
#[serde(rename_all = "camelCase")]
14-
pub enum ContextKind {
15-
Configuration,
16-
Resource,
17-
}
18-
1912
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)]
2013
#[serde(rename_all = "camelCase")]
2114
pub enum SecurityContextKind {
@@ -63,9 +56,6 @@ pub struct MicrosoftDscMetadata {
6356
/// The security context of the configuration operation, can be specified to be required
6457
#[serde(rename = "securityContext", skip_serializing_if = "Option::is_none")]
6558
pub security_context: Option<SecurityContextKind>,
66-
/// Identifies if the operation is part of a configuration
67-
#[serde(skip_serializing_if = "Option::is_none")]
68-
pub context: Option<ContextKind>,
6959
}
7060

7161
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)]

dsc_lib/src/configure/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,6 @@ impl Configurator {
709709
Metadata {
710710
microsoft: Some(
711711
MicrosoftDscMetadata {
712-
context: None,
713712
version: Some(env!("CARGO_PKG_VERSION").to_string()),
714713
operation: Some(operation),
715714
execution_type: Some(self.context.execution_type.clone()),

powershell-adapter/psDscAdapter/psDscAdapter.psm1

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -362,27 +362,14 @@ function Get-DscResourceObject {
362362
$inputObj = $jsonInput | ConvertFrom-Json
363363
$desiredState = [System.Collections.Generic.List[Object]]::new()
364364

365-
# catch potential for improperly formatted configuration input
366-
if ($inputObj.resources -and -not $inputObj.metadata.'Microsoft.DSC'.context -eq 'configuration') {
367-
'The input has a top level property named "resources" but is not a configuration. If the input should be a configuration, include the property: "metadata": {"Microsoft.DSC": {"context": "Configuration"}}' | Write-DscTrace -Operation Warn
368-
}
369-
370-
$adapterName = 'Microsoft.DSC/PowerShell'
371-
372-
if ($null -ne $inputObj.metadata -and $null -ne $inputObj.metadata.'Microsoft.DSC' -and $inputObj.metadata.'Microsoft.DSC'.context -eq 'configuration') {
373-
# change the type from pscustomobject to dscResourceObject
374-
$inputObj.resources | ForEach-Object -Process {
375-
$desiredState += [dscResourceObject]@{
376-
name = $_.name
377-
type = $_.type
378-
properties = $_.properties
379-
}
365+
$inputObj.resources | ForEach-Object -Process {
366+
$desiredState += [dscResourceObject]@{
367+
name = $_.name
368+
type = $_.type
369+
properties = $_.properties
380370
}
381371
}
382-
else {
383-
Write-DscTrace -Operation Error -Message 'Unexpected input format. The input must be a configuration object.'
384-
exit 1
385-
}
372+
386373
return $desiredState
387374
}
388375

@@ -535,7 +522,7 @@ class dscResourceCache {
535522
[dscResourceCacheEntry[]] $ResourceCache
536523
}
537524

538-
# format expected for configuration and resource output
525+
# format expected for configuration output
539526
class dscResourceObject {
540527
[string] $name
541528
[string] $type

powershell-adapter/psDscAdapter/win_psDscAdapter.psm1

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,6 @@ function Get-DscResourceObject {
268268
$inputObj = $jsonInput | ConvertFrom-Json
269269
$desiredState = [System.Collections.Generic.List[Object]]::new()
270270

271-
# catch potential for improperly formatted configuration input
272-
if ($inputObj.resources -and -not $inputObj.metadata.'Microsoft.DSC'.context -eq 'configuration') {
273-
'The input has a top level property named "resources" but is not a configuration. If the input should be a configuration, include the property: "metadata": {"Microsoft.DSC": {"context": "Configuration"}}' | Write-DscTrace -Operation Warn
274-
}
275-
276271
# match adapter to version of powershell
277272
if ($PSVersionTable.PSVersion.Major -le 5) {
278273
$adapterName = 'Microsoft.Windows/WindowsPowerShell'
@@ -281,20 +276,15 @@ function Get-DscResourceObject {
281276
$adapterName = 'Microsoft.DSC/PowerShell'
282277
}
283278

284-
if ($null -ne $inputObj.metadata -and $null -ne $inputObj.metadata.'Microsoft.DSC' -and $inputObj.metadata.'Microsoft.DSC'.context -eq 'configuration') {
285-
# change the type from pscustomobject to dscResourceObject
286-
$inputObj.resources | ForEach-Object -Process {
287-
$desiredState += [dscResourceObject]@{
288-
name = $_.name
289-
type = $_.type
290-
properties = $_.properties
291-
}
279+
# change the type from pscustomobject to dscResourceObject
280+
$inputObj.resources | ForEach-Object -Process {
281+
$desiredState += [dscResourceObject]@{
282+
name = $_.name
283+
type = $_.type
284+
properties = $_.properties
292285
}
293286
}
294-
else {
295-
Write-DscTrace -Operation Error -Message 'Unexpected input format. Please ensure the input is a valid DSC configuration.'
296-
exit 1
297-
}
287+
298288
return $desiredState
299289
}
300290

0 commit comments

Comments
 (0)