Skip to content

Commit

Permalink
Added history and notes for datastate() function
Browse files Browse the repository at this point in the history
(cherry picked from commit 466f642)
  • Loading branch information
nickanderson committed Oct 14, 2020
1 parent 2f51bce commit 33f98c5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions reference/functions/datastate.markdown
Expand Up @@ -34,3 +34,23 @@ Output:
[%CFEngine_include_snippet(datastate.cf, #\+begin_src\s+example_output\s*, .*end_src)%]

**See also:** `getindices()`, `classesmatching()`, `variablesmatching()`, `mergedata()`, `template_method`, `mustache`, `inline_mustache`, `bundlestate()`

**Notes:**

* Beware, when assigning `datastate()` to a variable, multiple passes will result in recursive growth of the data structure. Consider guarding against re-definition of a variable populated by `datastate()`.

Example illustrating how to prevent recursive growth of variable populated by `datastate()`.

```cf3
bundle agent main
{
vars:
"_state"
data => datastate(),
unless => isvariable( $(this.promiser) );
}
```

**History:**

* Introduced in CFEngine 3.6.0

0 comments on commit 33f98c5

Please sign in to comment.