Bas van der Vlies <bas.van...@surfsara.nl> writes:
I just want to use a function in format(), eg:
* "$(this.bundle):
(template )/$(json )", "auto")); >
I get all kind of errors:
{{{
error: format() didn't have enough parameters
}}}
>
The question is this an error or is it not allowed?
{ "Hello": "World" }
Hi Bas,
It seems like the format()
function doesn't accept functions as input yet. Can
you open an issue for this. I believe that the format()
function needs
"collecting" behavior.
bundle agent main { reports: "CFEngine $(sys.cf_version)"; "$(this.bundle): $(with)" with => format("BAS %S", readdata( "/tmp/example.json", "auto" )); }
error: format() didn't have enough parameters error: format() didn't have enough parameters R: CFEngine 3.11.0 error: format() didn't have enough parameters error: format() didn't have enough parameters R: main: $(with) error: format() didn't have enough parameters error: format() didn't have enough parameters error: format() didn't have enough parameters error: format() didn't have enough parameters
Here are some alternate patterns that work as expected with nested functions.
bundle agent main { vars: "d" data => readdata( "/tmp/example.json", "auto" ); reports: "CFEngine $(sys.cf_version)"; "$(this.bundle): $(with)" with => format("BAS %S", d ); }
R: CFEngine 3.11.0 R: main: BAS {"Hello":"World"}
bundle agent main { vars: "d" data => readdata( "/tmp/example.json", "auto" ); reports: "CFEngine $(sys.cf_version)"; "$(this.bundle): $(with)" with => string_mustache("BAS {{$-top-}}", d ); }
R: CFEngine 3.11.0 R: main: BAS {"Hello":"World"}
bundle agent main { reports: "CFEngine $(sys.cf_version)"; "$(this.bundle): $(with)" with => string_mustache("BAS {{$-top-}}", readdata( "/tmp/example.json", "auto" ) ); }
R: CFEngine 3.11.0 R: main: BAS {"Hello":"World"}
–
Nick Anderson
Doer of things, CFEngine
--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengin...@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/help-cfengine.
For more options, visit https://groups.google.com/d/optout.
<latex267401RO_6f10a91c2c7637b29ba0bca2d50ee29eb5722324.png>
bundle agent main { reports: "CFEngine $(sys.cf_version)"; "$(this.bundle): $(with)" with => string_mustache("BAS {{$-top-}}", readdata( "/tmp/example.json", "auto" ) );
bundle agent main { reports: "CFEngine $(sys.cf_version)"; "$(this.bundle): $(with)" with => string_mustache("BAS {{$-top-}}", readdata( "/tmp/example.json", "auto" ) );Thanks a lot Nick for this suggestion. Very useful the ‘string_mustache’ and easy ;-)