diff --git a/docs/dev/reference/changelog.md b/docs/dev/reference/changelog.md index cf24f9d817..861819164d 100644 --- a/docs/dev/reference/changelog.md +++ b/docs/dev/reference/changelog.md @@ -65,6 +65,12 @@ Use [`resource.FromProvider`](https://pkg.go.dev/go.viam.com/rdk/resource#FromPr {{% /changelog %}} +{{% changelog color="changed" title="Fragment Variables" date="2025-10-06" %}} + +[Fragments](/manage/fleet/reuse-configuration/) now support variables, allowing you to define variable values per-machine. + +{{% /changelog %}} + {{% changelog color="added" title="Machine job scheduling" date="2025-08-19" %}} Added support for scheduling automated jobs on machines that run at specified intervals. diff --git a/docs/manage/fleet/reuse-configuration.md b/docs/manage/fleet/reuse-configuration.md index 8b6138a82d..0cc2aa02cb 100644 --- a/docs/manage/fleet/reuse-configuration.md +++ b/docs/manage/fleet/reuse-configuration.md @@ -48,6 +48,52 @@ If you already created a machine to test your configuration, you can **Switch to {{% /tablestep %}} {{% tablestep %}} +**Add variable templates.** + +Fragments support variable substitution, allowing you to use the same fragment for multiple use cases even if there are small differences in configuration. + +When configuring resources, click the **{} JSON** button to switch to advanced view. +Instead of a key value, add a variable in the form `"$variable": { "name": "placeholder" } }}`. +For example: + +{{< tabs >}} +{{% tab name="With Variable" %}} + +```json {class="line-numbers linkable-line-numbers" data-line="4-8"} +{ + "api": "rdk:component:camera", + "attributes": { + "preloaded_image": { + "$variable": { + "name": "placeholder" + } + } + }, + "model": "rdk:builtin:image_file", + "name": "camera-placeholder" +} +``` + +{{% /tab %}} +{{% tab name="Without Variable" %}} + +```json {class="line-numbers linkable-line-numbers" data-line="4"} +{ + "api": "rdk:component:camera", + "attributes": { + "preloaded_image": "dog" + }, + "model": "rdk:builtin:image_file", + "name": "camera-placeholder" +} +``` + +{{% /tab %}} +{{< /tabs >}} + +{{% /tablestep %}} +{{% tablestep %}} + **Set your privacy settings in the menu bar.** There are three options for this: @@ -86,6 +132,21 @@ Search for your fragment and add it. Click **Save** in the upper right corner of the screen. +{{% /tablestep %}} +{{% tablestep %}} +**Add variables** if the fragment uses variable templates. + +In the fragment's panel, find the **Variables** section and add them to the JSON object. +For example: + +```json {class="line-numbers linkable-line-numbers" data-line="5"} +{ + "placeholder": "dog" +} +``` + +Click **Save** in the upper right corner of the screen. + {{% /tablestep %}} {{% tablestep %}} **Repeat step 1 for each of the machines** that you want to configure in the same way.