Skip to content

Commit 19eb255

Browse files
committed
Merge branch 'fix-metadata-version' of https://github.com/Gijsreyn/operation-methods into fix-metadata-version
2 parents 29b9632 + cdb0ba7 commit 19eb255

Some content is hidden

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

44 files changed

+553
-168
lines changed

.vscode/docs.code-snippets

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
// Place your DSCv3 workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
3-
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
4-
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
5-
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
6-
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
2+
// Place your DSCv3 workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
3+
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
4+
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
5+
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
6+
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
77
// Placeholders with the same ids are connected.
88
"Configuration function template": {
99
"scope": "markdown",
@@ -140,7 +140,7 @@
140140
" </details>",
141141
""
142142
]
143-
}
143+
},
144144
"Changelog Entry Multi Item": {
145145
"scope": "markdown",
146146
"prefix": "docs-changelog-entry-multi-issue-pr",
@@ -158,7 +158,7 @@
158158
" </details>",
159159
""
160160
]
161-
}
161+
},
162162
"Changelog release heading": {
163163
"scope": "markdown",
164164
"prefix": "docs-changelog-release-heading",
@@ -173,14 +173,22 @@
173173
"[release-${1:v3.0.0-${2:alpha.5}}]: https://github.com/PowerShell/DSC/releases/tag/${1:v3.0.0-${2:alpha.5}} \"Link to the DSC ${1:v3.0.0-${2:alpha.5}} release on GitHub\"",
174174
"[compare-${1:v3.0.0-${2:alpha.5}}]: https://github.com/PowerShell/DSC/compare/v3.0.0-alpha.4...${1:v3.0.0-${2:alpha.5}}"
175175
]
176-
177-
}
176+
},
178177
"Github Work Item Link": {
179178
"scope": "markdown",
180179
"prefix": "docs-gh-link",
181180
"description": "Template for a DSC Github work item link",
182181
"body": [
183182
"[#${1:work item id}]: https://github.com/PowerShell/DSC/issues/${1:work item id}"
184183
]
185-
}
184+
},
185+
"RFC table entry": {
186+
"scope": "markdown",
187+
"prefix": "rfc-table-entry",
188+
"description": "Template for an entry in the RFC History table",
189+
"body": [
190+
"| RFC${1:NNNN} | ${2:Title} | ${3|Accepted,Rejected,Final|} | ${4:#123} |"
191+
]
192+
},
193+
186194
}

build.ps1

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,26 @@ param(
1515
[switch]$GetPackageVersion,
1616
[switch]$SkipLinkCheck,
1717
[switch]$UseX64MakeAppx,
18-
[switch]$UseCratesIO,
18+
[switch]$UseCFS,
1919
[switch]$UpdateLockFile,
2020
[switch]$Audit,
2121
[switch]$UseCFSAuth,
2222
[switch]$Clean,
2323
[switch]$Verbose
2424
)
2525

26-
$env:RUSTC_LOG=$null
27-
$env:RUSTFLAGS='-Dwarnings'
28-
$usingADO = ($null -ne $env:TF_BUILD)
29-
3026
trap {
3127
Write-Error "An error occurred: $($_ | Out-String)"
3228
exit 1
3329
}
3430

31+
$env:RUSTC_LOG=$null
32+
$env:RUSTFLAGS='-Dwarnings'
33+
$usingADO = ($null -ne $env:TF_BUILD)
34+
if ($usingADO -or $UseCFSAuth) {
35+
$UseCFS = $true
36+
}
37+
3538
if ($Verbose) {
3639
$env:RUSTC_LOG='rustc_codegen_ssa::back::link=info'
3740
}
@@ -171,6 +174,39 @@ if ($null -ne (Get-Command msrustup -CommandType Application -ErrorAction Ignore
171174
if ($null -ne $packageType) {
172175
$SkipBuild = $true
173176
} else {
177+
if ($UseCFS) {
178+
Write-Host "Using CFS for cargo source replacement"
179+
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
180+
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null
181+
182+
if ($UseCFSAuth) {
183+
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
184+
throw "Azure CLI not found"
185+
}
186+
187+
if ($null -ne (Get-Command az -ErrorAction Ignore)) {
188+
Write-Host "Getting token"
189+
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
190+
if ($LASTEXITCODE -ne 0) {
191+
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
192+
} else {
193+
$header = "Bearer $accessToken"
194+
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
195+
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
196+
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
197+
}
198+
}
199+
else {
200+
Write-Warning "Azure CLI not found, proceeding with anonymous access."
201+
}
202+
}
203+
} else {
204+
# this will override the config.toml
205+
Write-Host "Setting CARGO_SOURCE_crates-io_REPLACE_WITH to 'crates-io'"
206+
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = 'CRATESIO'
207+
$env:CARGO_REGISTRIES_CRATESIO_INDEX = 'sparse+https://index.crates.io/'
208+
}
209+
174210
## Test if Rust is installed
175211
if (!$usingADO -and !(Get-Command 'cargo' -ErrorAction Ignore)) {
176212
Write-Verbose -Verbose "Rust not found, installing..."
@@ -229,7 +265,11 @@ if ($null -ne $packageType) {
229265
## Test if tree-sitter is installed
230266
if ($null -eq (Get-Command tree-sitter -ErrorAction Ignore)) {
231267
Write-Verbose -Verbose "tree-sitter not found, installing..."
232-
cargo install tree-sitter-cli --config .cargo/config.toml
268+
if ($UseCFS) {
269+
cargo install tree-sitter-cli --config .cargo/config.toml
270+
} else {
271+
cargo install tree-sitter-cli
272+
}
233273
if ($LASTEXITCODE -ne 0) {
234274
throw "Failed to install tree-sitter-cli"
235275
}
@@ -290,39 +330,6 @@ if (!$SkipBuild) {
290330
}
291331
New-Item -ItemType Directory $target -ErrorAction Ignore > $null
292332

293-
if ($UseCratesIO) {
294-
# this will override the config.toml
295-
Write-Host "Setting CARGO_SOURCE_crates-io_REPLACE_WITH to 'crates-io'"
296-
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = 'CRATESIO'
297-
$env:CARGO_REGISTRIES_CRATESIO_INDEX = 'sparse+https://index.crates.io/'
298-
} else {
299-
Write-Host "Using CFS for cargo source replacement"
300-
${env:CARGO_SOURCE_crates-io_REPLACE_WITH} = $null
301-
$env:CARGO_REGISTRIES_CRATESIO_INDEX = $null
302-
303-
if ($UseCFSAuth) {
304-
if ($null -eq (Get-Command 'az' -ErrorAction Ignore)) {
305-
throw "Azure CLI not found"
306-
}
307-
308-
if ($null -ne (Get-Command az -ErrorAction Ignore)) {
309-
Write-Host "Getting token"
310-
$accessToken = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
311-
if ($LASTEXITCODE -ne 0) {
312-
Write-Warning "Failed to get access token, use 'az login' first, or use '-useCratesIO' to use crates.io. Proceeding with anonymous access."
313-
} else {
314-
$header = "Bearer $accessToken"
315-
$env:CARGO_REGISTRIES_POWERSHELL_TOKEN = $header
316-
$env:CARGO_REGISTRIES_POWERSHELL_CREDENTIAL_PROVIDER = 'cargo:token'
317-
$env:CARGO_REGISTRIES_POWERSHELL_INDEX = "sparse+https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell~force-auth/Cargo/index/"
318-
}
319-
}
320-
else {
321-
Write-Warning "Azure CLI not found, proceeding with anonymous access."
322-
}
323-
}
324-
}
325-
326333
# make sure dependencies are built first so clippy runs correctly
327334
$windows_projects = @("pal", "registry_lib", "registry", "reboot_pending", "wmi-adapter", "configurations/windows", 'extensions/appx')
328335
$macOS_projects = @("resources/brew")
@@ -380,7 +387,11 @@ if (!$SkipBuild) {
380387
else {
381388
if ($Audit) {
382389
if ($null -eq (Get-Command cargo-audit -ErrorAction Ignore)) {
383-
cargo install cargo-audit --features=fix --config .cargo/config.toml
390+
if ($UseCFS) {
391+
cargo install cargo-audit --features=fix --config .cargo/config.toml
392+
} else {
393+
cargo install cargo-audit --features=fix
394+
}
384395
}
385396

386397
cargo audit fix
@@ -413,7 +424,11 @@ if (!$SkipBuild) {
413424
else {
414425
if ($Audit) {
415426
if ($null -eq (Get-Command cargo-audit -ErrorAction Ignore)) {
416-
cargo install cargo-audit --features=fix --config .cargo/config.toml
427+
if ($UseCFS) {
428+
cargo install cargo-audit --features=fix --config .cargo/config.toml
429+
} else {
430+
cargo install cargo-audit --features=fix
431+
}
417432
}
418433

419434
cargo audit fix

docs/reference/schemas/config/functions/array.md

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,31 @@ title: array
99

1010
## Synopsis
1111

12-
Creates an array from the given elements (strings, numbers, arrays, or objects).
12+
Wraps a single value (string, number, array, or object) in an array.
1313

1414
## Syntax
1515

1616
```Syntax
17-
array(<element1>, <element2>, ...)
17+
array(<value>)
1818
```
1919

2020
## Description
2121

22-
The `array()` function creates an array from the provided arguments, allowing
23-
mixed data types within the same array. Unlike `createArray()` which requires
24-
all elements to be the same type, `array()` accepts any combination of strings,
25-
numbers, arrays, and objects as arguments.
22+
The `array()` function returns a new array containing the single input value.
23+
The value can be a string, number, array, or object. Use
24+
`createArray()` to construct arrays with multiple elements of the same type.
2625

27-
This function is useful when you need to combine different types of data into a
28-
single collection, such as mixing configuration values, computed results, and
29-
structured metadata in deployment scenarios.
26+
This function is useful when a schema expects an array, but you only have a
27+
single value, or when you need to nest an existing array or object inside an
28+
outer array.
3029

3130
## Examples
3231

33-
### Example 1 - Build a deployment plan
32+
### Example 1 - Wrap an existing array as a single element
3433

35-
This example demonstrates combining different data types to create a comprehensive
36-
deployment configuration. The array contains an existing server list, a numeric
37-
batch size, and a configuration object with deployment strategy details.
34+
This example demonstrates wrapping an existing server list into a single array
35+
element, producing a nested array. This can be useful when a downstream schema
36+
expects an array of arrays.
3837

3938
```yaml
4039
# array.example.1.dsc.config.yaml
@@ -52,7 +51,7 @@ resources:
5251
- name: Deployment Plan
5352
type: Microsoft.DSC.Debug/Echo
5453
properties:
55-
output: "[array(parameters('webServers'), parameters('batchSize'), createObject('strategy', 'blue-green'))]"
54+
output: "[array(parameters('webServers'))]"
5655
```
5756
5857
```bash
@@ -68,17 +67,14 @@ results:
6867
output:
6968
- - web01
7069
- web02
71-
- 2
72-
- strategy: blue-green
7370
messages: []
7471
hadErrors: false
7572
```
7673
77-
### Example 2 - Compose mixed telemetry payload parts
74+
### Example 2 - Wrap a single object for payloads
7875
79-
This example shows how to construct a telemetry payload by combining a string
80-
identifier, structured metadata object, and numeric status code into a single
81-
array for logging or monitoring systems.
76+
This example shows how to wrap a structured metadata object into an array for
77+
logging or monitoring systems that expect arrays.
8278
8379
```yaml
8480
# array.example.2.dsc.config.yaml
@@ -92,7 +88,7 @@ resources:
9288
type: Microsoft.DSC.Debug/Echo
9389
properties:
9490
output:
95-
payload: "[array(parameters('correlationId'), createObject('severity', 'info'), 200)]"
91+
payload: "[array(createObject('severity', 'info'))]"
9692
```
9793
9894
```bash
@@ -107,18 +103,15 @@ results:
107103
actualState:
108104
output:
109105
payload:
110-
- ABC123
111106
- severity: info
112-
- 200
113107
messages: []
114108
hadErrors: false
115109
```
116110
117-
### Example 3 - Combine generated and literal collections
111+
### Example 3 - Wrap generated collections
118112
119-
This example demonstrates nesting arrays and objects within a parent array,
120-
showing how `array()` can combine results from other DSC functions like
121-
`createArray()` and `createObject()` with literal values.
113+
This example demonstrates wrapping a generated collection (like one from
114+
`createArray()` or `createObject()`) into an outer array.
122115

123116
```yaml
124117
# array.example.3.dsc.config.yaml
@@ -128,7 +121,8 @@ resources:
128121
type: Microsoft.DSC.Debug/Echo
129122
properties:
130123
output:
131-
combined: "[array(createArray('a','b'), array(1,2), createObject('k','v'))]"
124+
combinedArray: "[array(createArray('a','b'))]"
125+
combinedObject: "[array(createObject('k','v'))]"
132126
```
133127

134128
```bash
@@ -142,31 +136,31 @@ results:
142136
result:
143137
actualState:
144138
output:
145-
combined:
139+
combinedArray:
146140
- - a
147141
- b
148-
- - 1
149-
- 2
142+
combinedObject:
150143
- k: v
151144
messages: []
152145
hadErrors: false
153146
```
154147

155148
## Parameters
156149

157-
### element1, element2, ...
150+
### value
158151

159-
The elements to include in the array.
152+
The single value to wrap in the array.
160153

161154
```yaml
162155
Type: string, number, array, or object
163156
Required: false
164-
Multiplicity: 0 or more
157+
MinimumCount: 1
158+
MaximumCount: 1
165159
```
166160

167-
Each element provided as an argument will be added to the resulting array in the
168-
order specified. All elements must be one of the four accepted types: string,
169-
number (integer), array, or object. Boolean and null values are not supported.
161+
The provided value will be wrapped into the resulting array. The value must be
162+
one of the four accepted types: string, number (integer), array, or object.
163+
Boolean and null values are not supported.
170164

171165
## Output
172166

docs/reference/schemas/config/functions/first.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ hadErrors: false
109109
### Example 3 - Chain with array construction
110110
111111
This example shows how `first()` can be combined with `array()` to get the
112-
first element from a dynamically constructed array containing mixed data types.
112+
first element from a dynamically constructed array, by wrapping a single
113+
generated collection.
113114

114115
```yaml
115116
# first.example.3.dsc.config.yaml
@@ -119,7 +120,7 @@ resources:
119120
type: Microsoft.DSC.Debug/Echo
120121
properties:
121122
output:
122-
firstMixed: "[first(array(createArray('a','b'), createObject('k','v')))]"
123+
firstMixed: "[first(array(createArray('a','b')))]"
123124
```
124125

125126
```bash
@@ -133,9 +134,7 @@ results:
133134
result:
134135
actualState:
135136
output:
136-
firstMixed:
137-
- a
138-
- b
137+
firstMixed: a
139138
messages: []
140139
hadErrors: false
141140
```

0 commit comments

Comments
 (0)