Skip to content

Commit d1293b4

Browse files
committed
Merge branch 'main' of https://github.com/Gijsreyn/operation-methods into add-join-function
2 parents 45eae9e + c54b956 commit d1293b4

Some content is hidden

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

57 files changed

+1515
-375
lines changed

.github/workflows/winget.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish to Winget
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
9+
env:
10+
WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_CREATE_GITHUB_TOKEN }}
11+
12+
jobs:
13+
publish:
14+
runs-on: windows-latest # Action can only run on Windows
15+
16+
# Only submit stable releases
17+
if: ${{ !github.event.release.prerelease }}
18+
steps:
19+
- name: Publish DSC package
20+
run: |
21+
$assets = '${{ toJSON(github.event.release.assets) }}' | ConvertFrom-Json
22+
$x64ZIPInstallerUrl = $assets | Where-Object -Property name -like '*x86_64-pc-windows-msvc.zip' | Select-Object -ExpandProperty browser_download_url
23+
$arm64InstallerUrl = $assets | Where-Object -Property name -like '*aarch64-pc-windows-msvc.zip' | Select-Object -ExpandProperty browser_download_url
24+
$msixInstallerURL = $assets | Where-Object -Property name -like '*Win.msixbundle' | Select-Object -ExpandProperty browser_download_url
25+
$version = (${{ toJSON(github.event.release.tag_name) }}).Trim('v')
26+
27+
$wingetPackage = "Microsoft.DSC"
28+
29+
& curl.exe -JLO https://aka.ms/wingetcreate/latest
30+
& .\wingetcreate.exe update $wingetPackage --version $version --urls $x64ZIPInstallerUrl $arm64InstallerUrl $msixInstallerURL --submit
31+
32+
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
description: Reference for the 'lastIndexOf' DSC configuration document function
3+
ms.date: 08/29/2025
4+
ms.topic: reference
5+
title: lastIndexOf
6+
---
7+
8+
## Synopsis
9+
10+
Returns an integer for the index of the last occurrence of an item in an array.
11+
If the item isn't present, returns -1.
12+
13+
## Syntax
14+
15+
```Syntax
16+
lastIndexOf(arrayToSearch, itemToFind)
17+
```
18+
19+
## Description
20+
21+
The `lastIndexOf()` function searches an array from the end to the beginning
22+
and returns the zero-based index of the last matching element. String
23+
comparisons are case-sensitive. If no match is found, `-1` is returned.
24+
25+
Supported `itemToFind` types:
26+
27+
- string (case-sensitive)
28+
- number (integer)
29+
- array (deep equality)
30+
- object (deep equality)
31+
32+
## Examples
33+
34+
### Example 1 - Find the last rollout slot for a server role (strings)
35+
36+
Use `lastIndexOf()` to locate where a particular role (like a web node)
37+
appears last in a planned rollout sequence. This is handy when you need to
38+
schedule a final step (for example, draining traffic) after the last matching
39+
node has been processed. This example uses [`createArray()`][02] to build the
40+
list of nodes.
41+
42+
```yaml
43+
# lastindexof.example.1.dsc.config.yaml
44+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
45+
resources:
46+
- name: Rollout Plan
47+
type: Microsoft.DSC.Debug/Echo
48+
properties:
49+
output:
50+
lastWebIndex: "[lastIndexOf(createArray('web01','db01','web02','cache01','web03'), 'web03')]"
51+
lastWebFamilyIndex: "[lastIndexOf(createArray('web01','db01','web02','cache01','web02'), 'web02')]"
52+
```
53+
54+
```bash
55+
dsc config get --file lastindexof.example.1.dsc.config.yaml
56+
```
57+
58+
```yaml
59+
results:
60+
- name: Rollout Plan
61+
type: Microsoft.DSC.Debug/Echo
62+
result:
63+
actualState:
64+
output:
65+
lastWebIndex: 4
66+
lastWebFamilyIndex: 4
67+
messages: []
68+
hadErrors: false
69+
```
70+
71+
Note that string comparison is case-sensitive. Searching for `WEB02` would
72+
return `-1` in this example.
73+
74+
### Example 2 - Locate the last matching configuration object (objects)
75+
76+
Deep equality lets you search arrays of objects. Here we find the last
77+
occurrence of a feature flag object with a specific name. This example uses
78+
[`createObject()`][03] to build objects and [`createArray()`][10] to build the
79+
collection.
80+
81+
```yaml
82+
# lastindexof.example.2.dsc.config.yaml
83+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
84+
resources:
85+
- name: Feature Flags
86+
type: Microsoft.DSC.Debug/Echo
87+
properties:
88+
output:
89+
lastBetaIndex: "[lastIndexOf(createArray(createObject('name','Beta'), createObject('name','Gamma'), createObject('name','Beta')), createObject('name','Beta'))]"
90+
```
91+
92+
```bash
93+
dsc config get --file lastindexof.example.2.dsc.config.yaml
94+
```
95+
96+
```yaml
97+
results:
98+
- name: Feature Flags
99+
type: Microsoft.DSC.Debug/Echo
100+
result:
101+
actualState:
102+
output:
103+
lastBetaIndex: 2
104+
messages: []
105+
hadErrors: false
106+
```
107+
108+
Property order in objects doesn't matter. The following also returns `1` due to
109+
deep equality: `lastIndexOf(array(createObject('a',1,'b',2), createObject('b',2,'a',1)), createObject('a',1,'b',2))`.
110+
111+
## Parameters
112+
113+
### arrayToSearch
114+
115+
The array to search. Required.
116+
117+
```yaml
118+
Type: array
119+
Required: true
120+
Position: 1
121+
```
122+
123+
### itemToFind
124+
125+
The item to search for. Required.
126+
127+
```yaml
128+
Type: string | number | array | object
129+
Required: true
130+
Position: 2
131+
```
132+
133+
## Output
134+
135+
Returns a number representing the last index or -1 if not found.
136+
137+
```yaml
138+
Type: number
139+
```
140+
141+
## Related functions
142+
143+
- [`indexOf()`][00] - First occurrence index in an array
144+
- [`contains()`][01] - Checks for presence in arrays/objects/strings
145+
146+
<!-- Link reference definitions -->
147+
[00]: ./indexOf.md
148+
[01]: ./contains.md
149+
[02]: ./createArray.md
150+
[03]: ./createObject.md
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
---
2+
description: Reference for the 'skip' DSC configuration document function
3+
ms.date: 08/29/2025
4+
ms.topic: reference
5+
title: skip
6+
---
7+
8+
## Synopsis
9+
10+
Returns an array with all the elements after the specified number in the array,
11+
or returns a string with all the characters after the specified number in the
12+
string.
13+
14+
## Syntax
15+
16+
```Syntax
17+
skip(<originalValue>, <numberToSkip>)
18+
```
19+
20+
## Description
21+
22+
The `skip()` function returns the tail of an array or string by skipping a
23+
specified number of items from the start.
24+
25+
- For arrays: returns a new array containing elements after the specified index
26+
- For strings: returns a new string containing characters after the specified index
27+
28+
Both parameters are required. `originalValue` must be an array or a string.
29+
`numberToSkip` must be an integer; negative values are treated as zero. If the
30+
number is greater than the length of the array or string, the function returns
31+
an empty array or an empty string respectively.
32+
33+
## Examples
34+
35+
### Example 1 - Skip elements in an array
36+
37+
The following example returns the tail of an array by skipping the first two
38+
elements.
39+
40+
```yaml
41+
# skip.example.1.dsc.config.yaml
42+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
43+
resources:
44+
- name: Tail of array
45+
type: Microsoft.DSC.Debug/Echo
46+
properties:
47+
output:
48+
tail: "[skip(createArray('a','b','c','d'), 2)]"
49+
```
50+
51+
```bash
52+
dsc config get --file skip.example.1.dsc.config.yaml
53+
```
54+
55+
```yaml
56+
results:
57+
- name: Tail of array
58+
type: Microsoft.DSC.Debug/Echo
59+
result:
60+
actualState:
61+
output:
62+
tail:
63+
- c
64+
- d
65+
messages: []
66+
hadErrors: false
67+
```
68+
69+
### Example 2 - Skip characters in a string
70+
71+
The following example returns the substring of a string by skipping the first
72+
two characters.
73+
74+
```yaml
75+
# skip.example.2.dsc.config.yaml
76+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
77+
resources:
78+
- name: Tail of string
79+
type: Microsoft.DSC.Debug/Echo
80+
properties:
81+
output:
82+
tail: "[skip('hello', 2)]"
83+
```
84+
85+
```bash
86+
dsc config get --file skip.example.2.dsc.config.yaml
87+
```
88+
89+
```yaml
90+
results:
91+
- name: Tail of string
92+
type: Microsoft.DSC.Debug/Echo
93+
result:
94+
actualState:
95+
output:
96+
tail: llo
97+
messages: []
98+
hadErrors: false
99+
```
100+
101+
## Parameters
102+
103+
### originalValue
104+
105+
The value to skip items from. Can be an array or a string.
106+
107+
```yaml
108+
Type: array | string
109+
Required: true
110+
Position: 1
111+
```
112+
113+
### numberToSkip
114+
115+
The number of items to skip from the start. Must be an integer. Negative values
116+
are treated as zero.
117+
118+
```yaml
119+
Type: int
120+
Required: true
121+
Position: 2
122+
```
123+
124+
## Output
125+
126+
Returns the same type as `originalValue`:
127+
128+
- If `originalValue` is an array, returns an array
129+
- If `originalValue` is a string, returns a string
130+
131+
```yaml
132+
Type: array | string
133+
```
134+
135+
## Error conditions
136+
137+
- `originalValue` is not an array or string
138+
- `numberToSkip` is not an integer
139+
140+
## Related functions
141+
142+
- [`first()`][00] - Returns the first element or character
143+
- [`length()`][01] - Returns the number of elements or characters
144+
145+
<!-- Link reference definitions -->
146+
[00]: ./first.md
147+
[01]: ./length.md

dsc/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dsc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ path-absolutize = { version = "3.1" }
2424
regex = "1.11"
2525
rust-i18n = { version = "3.1" }
2626
schemars = { version = "1.0" }
27+
semver = "1.0"
2728
serde = { version = "1.0", features = ["derive"] }
2829
serde_json = { version = "1.0", features = ["preserve_order"] }
2930
serde_yaml = { version = "0.9" }

dsc/examples/hello_world.dsc.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
targetScope = 'desiredStateConfiguration'
44

55
// use workaround where Bicep currently requires version in date format
6-
resource echo 'Microsoft.DSC.Debug/Echo@2025-01-01' = {
6+
resource echo 'Microsoft.DSC.Debug/Echo@2025-08-27' = {
77
name: 'exampleEcho'
88
properties: {
99
output: 'Hello, world!'

dsc/locales/en-us.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ getAll = "Get all instances of the resource"
3434
resource = "The name of the resource to invoke"
3535
functionAbout = "Operations on DSC functions"
3636
listFunctionAbout = "List or find functions"
37+
version = "The version of the resource to invoke in semver format"
3738

3839
[main]
3940
ctrlCReceived = "Ctrl-C received"

0 commit comments

Comments
 (0)