Table of Contents
getvariablemetatags
Table of Contents
Prototype: getvariablemetatags(varname, optional_tag)
Return type: slist
Description: Returns the list of meta
tags for variable varname
.
Make sure you specify the correct scope when supplying the name of the variable.
Arguments:
varname
:string
, in the range:[a-zA-Z0-9_$(){}\[\].:]+
The optional_tag
can be used to look up a specific tag's value. If you format
your tags like meta => { "mykey=myvalue1", "mykey=myvalue2"}
then the
optional_tag
of mykey
will fetch you a list with two entries, { "myvalue1",
"myvalue2" }
.
Example:
body common control
{
bundlesequence => { "example" };
}
bundle agent example
{
vars:
"v" string => "myvalue", meta => { "mytag", "other=once", "other=twice" };
"vtags" slist => getvariablemetatags("example.v");
"othertag_values" slist => getvariablemetatags("example.v", "other");
reports:
"Found tags: $(vtags)";
"Found tags for key 'other': $(othertag_values)";
}
Output:
R: Found tags: source=promise
R: Found tags: mytag
R: Found tags: other=once
R: Found tags: other=twice
R: Found tags for key 'other': once
R: Found tags for key 'other': twice
Notes:
See also: getclassmetatags()
History:
- Introduced in CFEngine 3.6.0
optional_tag
added in 3.10.0