Skip to content

Commit 56b21d7

Browse files
committed
Rewrite examples for real-world examples
1 parent dc0635f commit 56b21d7

File tree

1 file changed

+43
-6
lines changed
  • docs/reference/schemas/config/functions

1 file changed

+43
-6
lines changed

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

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ The `delimiter` can be any value; it is converted to a string.
2828

2929
## Examples
3030

31-
### Example 1 - Join array of strings
31+
### Example 1 - Produce a list of servers
32+
33+
Create a comma-separated string from a list of host names to pass to tools or
34+
APIs that accept CSV input. This example uses [`createArray()`][02] to build
35+
the server list and joins with ", ".
3236

3337
```yaml
3438
# join.example.1.dsc.config.yaml
@@ -37,7 +41,7 @@ resources:
3741
- name: Echo
3842
type: Microsoft.DSC.Debug/Echo
3943
properties:
40-
output: "[join(createArray('a','b','c'), '-')]"
44+
output: "[join(createArray('web01','web02','web03'), ', ')]"
4145
```
4246
4347
```bash
@@ -50,12 +54,15 @@ results:
5054
type: Microsoft.DSC.Debug/Echo
5155
result:
5256
actualState:
53-
output: a-b-c
57+
output: web01, web02, web03
5458
messages: []
5559
hadErrors: false
5660
```
5761
58-
### Example 2 - Join characters of a string
62+
### Example 2 - Build a file system path from segments
63+
64+
Join path segments into a single path string. This is useful when composing
65+
paths dynamically from parts.
5966
6067
```yaml
6168
# join.example.2.dsc.config.yaml
@@ -64,7 +71,7 @@ resources:
6471
- name: Echo
6572
type: Microsoft.DSC.Debug/Echo
6673
properties:
67-
output: "[join('abc', '-')]"
74+
output: "[join(createArray('/etc','nginx','sites-enabled'), '/')]"
6875
```
6976
7077
```bash
@@ -77,7 +84,37 @@ results:
7784
type: Microsoft.DSC.Debug/Echo
7885
result:
7986
actualState:
80-
output: a-b-c
87+
output: /etc/nginx/sites-enabled
88+
messages: []
89+
hadErrors: false
90+
```
91+
92+
### Example 3 - Format a version string from numeric parts
93+
94+
Convert version components (numbers) into a dotted version string. Non-string
95+
elements are converted to strings automatically.
96+
97+
```yaml
98+
# join.example.3.dsc.config.yaml
99+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
100+
resources:
101+
- name: Echo
102+
type: Microsoft.DSC.Debug/Echo
103+
properties:
104+
output: "[join(createArray(1,2,3), '.')]"
105+
```
106+
107+
```bash
108+
dsc config get --file join.example.3.dsc.config.yaml
109+
```
110+
111+
```yaml
112+
results:
113+
- name: Echo
114+
type: Microsoft.DSC.Debug/Echo
115+
result:
116+
actualState:
117+
output: 1.2.3
81118
messages: []
82119
hadErrors: false
83120
```

0 commit comments

Comments
 (0)