bundle agent main
{
vars:
"yaml" data => parseyaml ('
books:
scifi_schema:
isbn: "isbn_scifi"
book_name: "book_name_scifi"
travel_schema:
isbn: "isbn_travel"
book_name: "book_name_travel"
');
"schemas" slist => getindices( "@(yaml[books])" );
# Munge the data structure into a unified list of strings
"arr_munged[$(schemas)]"
string => "$(with)::isbn: '$(yaml[books][$(schemas)][isbn])' with book_name: '$(yaml[books][$(schemas)][book_name])'",
with => regex_replace( "$(schemas)", "_schema", "", "g" );
"l_munged" slist => getvalues( arr_munged );
reports:
"CFEngine '$(sys.cf_version)'";
"$(l_munged)";
}
Created
November 8, 2022 14:30
-
-
Save nickanderson/286eb0a04c45df231e20f9a2ce4fc957 to your computer and use it in GitHub Desktop.
Example illustrating munging YAML data structure into a list of strings
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment