Skip to content

Commit 2046ea7

Browse files
michaeltlombardiSteveL-MSFT
authored andcommitted
(GH-642) Ensure camelCase for items in dsc_lib
Prior to this change, the structs and enums in `dsc_lib` didn't consistently use camelCase - most property names and enum values use camelCase, but not all - and this inconsistency isn't predictable for end users, who need to consult the JSON Schemas to be sure. This change updates the definitions to rename the fields and values when serializing and deserializing, which also updates their JSON Schema. A future change is required to update the canonical schemas in the repository to match these updates.
1 parent e8e7cdc commit 2046ea7

30 files changed

+66
-48
lines changed

configurations/windows/windows_baseline.dsc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
33
metadata:
44
Microsoft.DSC:
5-
securityContext: Elevated
5+
securityContext: elevated
66
resources:
77
- name: Validate the OS is Windows
88
type: Microsoft.DSC/Assertion

dsc/assertion.dsc.resource.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "Microsoft.DSC/Assertion",
44
"version": "0.1.0",
55
"description": "`test` will be invoked for all resources in the supplied configuration.",
6-
"kind": "Group",
6+
"kind": "group",
77
"get": {
88
"executable": "dsc",
99
"args": [

dsc/examples/groups.dsc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
33
metadata:
44
Microsoft.DSC:
5-
requiredSecurityContext: Current # this is the default and just used as an example indicating this config works for admins and non-admins
5+
requiredSecurityContext: current # this is the default and just used as an example indicating this config works for admins and non-admins
66
resources:
77
- name: Last Group
88
type: Microsoft.DSC/Group

dsc/examples/require_admin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
55
metadata:
66
Microsoft.DSC:
7-
securityContext: Elevated
7+
securityContext: elevated
88
resources:
99
- name: os
1010
type: Microsoft/OSInfo

dsc/examples/require_nonadmin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
44
metadata:
55
Microsoft.DSC:
6-
securityContext: Restricted
6+
securityContext: restricted
77
resources:
88
- name: os
99
type: Microsoft/OSInfo

dsc/examples/winps_script.dsc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
22
metadata:
33
Microsoft.DSC:
4-
securityContext: Elevated
4+
securityContext: elevated
55
resources:
66
- type: Microsoft.Windows/WindowsPowerShell
77
name: Run WinPS script

dsc/group.dsc.resource.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "Microsoft.DSC/Group",
44
"version": "0.1.0",
55
"description": "All resources in the supplied configuration is treated as a group.",
6-
"kind": "Group",
6+
"kind": "group",
77
"get": {
88
"executable": "dsc",
99
"args": [

dsc/include.dsc.resource.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "Microsoft.DSC/Include",
44
"version": "0.1.0",
55
"description": "Allows including a configuration file with optional parameter file.",
6-
"kind": "Importer",
6+
"kind": "importer",
77
"get": {
88
"executable": "dsc",
99
"args": [

dsc/tests/dsc_args.tests.ps1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ actualState:
9191
$out.Trim() | Should -BeExactly $expected
9292
}
9393

94+
It 'YAML output includes object separator' {
95+
$out = dsc resource list -o yaml | Out-String
96+
foreach ($obj in $out.Split('---')) {
97+
$resource = $obj | y2j | ConvertFrom-Json
98+
$resource | Should -Not -BeNullOrEmpty
99+
$resource.Type | Should -BeLike '*/*'
100+
$resource.Kind | Should -BeIn ('resource', 'group', 'importer', 'adapter')
101+
}
102+
}
103+
94104
It 'can generate PowerShell completer' {
95105
$out = dsc completer powershell | Out-String
96106
Invoke-Expression $out
@@ -232,7 +242,7 @@ resources:
232242
$a = dsc resource list '*' -a Test* -o json | ConvertFrom-Json
233243
foreach ($r in $a) {
234244
$r.requireAdapter.StartsWith("Test") | Should -Be $true
235-
$r.kind | Should -Be "Resource"
245+
$r.kind | Should -Be "resource"
236246
}
237247
}
238248

@@ -243,7 +253,7 @@ resources:
243253
$r = $a[0]
244254
$r.requireAdapter | Should -Not -BeNullOrEmpty
245255
$r.requireAdapter.StartsWith("Test") | Should -Be $true
246-
$r.kind | Should -Be "Resource"
256+
$r.kind | Should -Be "resource"
247257
}
248258

249259
It 'passing filepath to document arg should error' {

dsc/tests/dsc_config_get.tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Describe 'dsc config get tests' {
4747
$result.results[0].type | Should -BeExactly 'Microsoft.DSC.Debug/Echo'
4848
$result.results[0].result.actualState.output | Should -Be 'hello'
4949
$result.metadata.'Microsoft.DSC'.version | Should -BeLike '3.*'
50-
$result.metadata.'Microsoft.DSC'.operation | Should -BeExactly 'Get'
51-
$result.metadata.'Microsoft.DSC'.executionType | Should -BeExactly 'Actual'
50+
$result.metadata.'Microsoft.DSC'.operation | Should -BeExactly 'get'
51+
$result.metadata.'Microsoft.DSC'.executionType | Should -BeExactly 'actual'
5252
$result.metadata.'Microsoft.DSC'.startDatetime | Should -Not -BeNullOrEmpty
5353
$result.metadata.'Microsoft.DSC'.endDatetime | Should -Not -BeNullOrEmpty
5454
$result.metadata.'Microsoft.DSC'.duration | Should -Not -BeNullOrEmpty

0 commit comments

Comments
 (0)