A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.cfengine.com/latest/reference-functions-getvalues.html below:

getvalues - CFEngine 3.26 Docs

Prototype: getvalues(varref)

Return type: slist

Description: Returns the list of values in varref which can be the name of an array or container.

This function can accept many types of data parameters.

If the array contains list values, then all of the list elements are flattened into a single list to make the return value a list.

If the data container contains non-scalar values (e.g. nested containers) they are skipped. The special values true, false, and null are serialized to their string representations. Numerical values are serialized to their string representations.

You can specify a path inside the container. For example, below you'll look at the values of d[k], not at the top level of d.

Make sure you specify the correct scope when supplying the name of the variable.

Arguments:

Example:

code

body common control
{
      bundlesequence => { "example" };
}

bundle agent example
{
  vars:

      "v[index_1]" string => "value_1";
      "v[index_2]" string => "value_2";

      "values"        slist => getvalues("v");
      "values_sorted" slist => sort(values, lex);

      # works with data containers too
      "d" data => parsejson('{ "k": [ 1, 2, 3, "a", "b", "c" ] }');

      "cvalues"        slist => getvalues("d[k]");
      "cvalues_sorted" slist => sort(cvalues, lex);

  reports:
      "Found values: $(values_sorted)";
      "Found container values: $(cvalues_sorted)";

}

Output:

code

R: Found values: value_1
R: Found values: value_2
R: Found container values: 1
R: Found container values: 2
R: Found container values: 3
R: Found container values: a
R: Found container values: b
R: Found container values: c

History: The collecting function behavior was added in 3.9.

See also: getindices(), about collecting functions, and data documentation.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4