Skip to content

Commit 5f0fef9

Browse files
authored
DOCS-4460: Support variable substitution (#4731)
1 parent 5e6f781 commit 5f0fef9

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

docs/dev/reference/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ Use [`resource.FromProvider`](https://pkg.go.dev/go.viam.com/rdk/resource#FromPr
6565

6666
{{% /changelog %}}
6767

68+
{{% changelog color="changed" title="Fragment Variables" date="2025-10-06" %}}
69+
70+
[Fragments](/manage/fleet/reuse-configuration/) now support variables, allowing you to define variable values per-machine.
71+
72+
{{% /changelog %}}
73+
6874
{{% changelog color="added" title="Machine job scheduling" date="2025-08-19" %}}
6975

7076
Added support for scheduling automated jobs on machines that run at specified intervals.

docs/manage/fleet/reuse-configuration.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,52 @@ If you already created a machine to test your configuration, you can **Switch to
4848

4949
{{% /tablestep %}}
5050
{{% tablestep %}}
51+
**Add variable templates.**
52+
53+
Fragments support variable substitution, allowing you to use the same fragment for multiple use cases even if there are small differences in configuration.
54+
55+
When configuring resources, click the **{} JSON** button to switch to advanced view.
56+
Instead of a key value, add a variable in the form `"$variable": { "name": "placeholder" } }}`.
57+
For example:
58+
59+
{{< tabs >}}
60+
{{% tab name="With Variable" %}}
61+
62+
```json {class="line-numbers linkable-line-numbers" data-line="4-8"}
63+
{
64+
"api": "rdk:component:camera",
65+
"attributes": {
66+
"preloaded_image": {
67+
"$variable": {
68+
"name": "placeholder"
69+
}
70+
}
71+
},
72+
"model": "rdk:builtin:image_file",
73+
"name": "camera-placeholder"
74+
}
75+
```
76+
77+
{{% /tab %}}
78+
{{% tab name="Without Variable" %}}
79+
80+
```json {class="line-numbers linkable-line-numbers" data-line="4"}
81+
{
82+
"api": "rdk:component:camera",
83+
"attributes": {
84+
"preloaded_image": "dog"
85+
},
86+
"model": "rdk:builtin:image_file",
87+
"name": "camera-placeholder"
88+
}
89+
```
90+
91+
{{% /tab %}}
92+
{{< /tabs >}}
93+
94+
{{% /tablestep %}}
95+
{{% tablestep %}}
96+
5197
**Set your privacy settings in the menu bar.**
5298
There are three options for this:
5399

@@ -86,6 +132,21 @@ Search for your fragment and add it.
86132

87133
Click **Save** in the upper right corner of the screen.
88134

135+
{{% /tablestep %}}
136+
{{% tablestep %}}
137+
**Add variables** if the fragment uses variable templates.
138+
139+
In the fragment's panel, find the **Variables** section and add them to the JSON object.
140+
For example:
141+
142+
```json {class="line-numbers linkable-line-numbers" data-line="5"}
143+
{
144+
"placeholder": "dog"
145+
}
146+
```
147+
148+
Click **Save** in the upper right corner of the screen.
149+
89150
{{% /tablestep %}}
90151
{{% tablestep %}}
91152
**Repeat step 1 for each of the machines** that you want to configure in the same way.

0 commit comments

Comments
 (0)