Skip to content
Julien Loudet edited this page Jan 17, 2025 · 2 revisions

Vars

Vars are a convenient way to do string replacement in your descriptor files.

For instance, if you need to specify the path of a directory at several places in the same descriptor file. Associating a var to this full path would allow you to only repeat the var.

How to use

Each var must be declared in a vars section of your descriptor. The underlying structure is a hash map so each entry should not be prefixed by a dash ("-", as that would turn it into a list).

vars:
    FOO: foo/bar/baz
    BAR: bar foo baz

This declaration is supported in all descriptors.

To use a var two conditions must be met:

  • surround the entire value with double quotes,
  • surround the var with two consecutive pairs of curly braces.
vars:
  FOO: foo/bar/baz
  
configuration:
  base_path: "{{ FOO }}/root-directory"

Vars propagation within descriptors

Zenoh-Flow supports separating the declaration of nodes in dedicated files. To avoid having to repeat this vars section in every descriptor file, it is propagated in a top-down fashion: the vars sections will be merged and if a value is repeated in several sections, the value of the containing descriptor will override all others.

To illustrate, if we have:

  • In the descriptor of the data flow:
name: data flow

vars:
  FOO: data-flow
  • In the descriptor of a composite operator:
description: composite operator

vars:
  FOO: composite
  BAR: composite
  • In the descriptor of an operator, included in the composite operator:
description: operator

vars:
  FOO: operator
  BAR: operator
  BAZ: operator

Then, once Zenoh-Flow has merged all vars sections, its values will be:

vars:
  FOO: data-flow
  BAR: composite
  BAZ: operator

The rationale is to allow providing default values in the vars section that can be easily overwritten in the data flow descriptor — without requiring to modify each descriptor file manually.

Clone this wiki locally