Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/reference/functions/classfiltercsv.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ minus `1`.
*.sh text eol=lf
```

**See also:** [`data_expand()`][data_expand], [`readcsv()`][readcsv], [`classmatch()`][classmatch]
**See also:** [`classfilterdata()`][classfilterdata], [`data_expand()`][data_expand], [`readcsv()`][readcsv], [`classmatch()`][classmatch]

**History:**

Expand Down
55 changes: 55 additions & 0 deletions content/reference/functions/classfilterdata.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
layout: default
title: classfilterdata
---

[%CFEngine_function_prototype(data_container, data_structure, key_or_index)%]

**Description:**
This function filters a data container (`data_container`) based on defined
classes. Records within the data container containing a class expression located
at a given key or index (`key_or_index`) are filtered out when they evaluate to
false in the current context. The interpretation of the data container depends
on the specified data structure (`data_structure`).

If the `data_structure` argument is specified to be:
- `"array_of_arrays"`, the `data_container` argument is interpreted as an array
of arrays, and the `key_or_index` argument is interpreted as an index within
the children arrays.
- `"array_of_objects"`, the `data_container` argument is interpreted as an array
of objects, and the `key_or_index` argument is interpreted as a key within the
children objects.
- `"auto"`, the interpretation is automatically detected based on the data
structure.

[%CFEngine_function_attributes(data_container, data_structure, key_or_index)%]

**Example (with array of arrays):**

**Policy:**

[%CFEngine_include_snippet(classfilterdata_array_of_arrays.cf, #\+begin_src cfengine3, .*end_src)%]

**Output:**

[%CFEngine_include_snippet(classfilterdata_array_of_arrays.cf, #\+begin_src\s+example_output\s*, .*end_src)%]

**Example (with array of objects):**

**Policy:**

[%CFEngine_include_snippet(classfilterdata_array_of_objects.cf, #\+begin_src cfengine3, .*end_src)%]

**Output:**

[%CFEngine_include_snippet(classfilterdata_array_of_objects.cf, #\+begin_src\s+example_output\s*, .*end_src)%]

**Notes:**

This function can accept many types of data parameters _(See [collecting function][Functions#collecting functions])_.

**See also:** [`classfiltercsv()`][classfiltercsv], [`data_expand()`][data_expand], [`classmatch()`][classmatch]

**History:**

- Introduced in CFEngine 3.27.0