'with' attribute #5875
Replies: 3 comments 3 replies
-
I don't know the relevance of the JSON, and the CFEngine snippet wasn't quite syntactically right either. But I think I was able to distill it into a runnable example:
What is it that doesn't work? |
Beta Was this translation helpful? Give feedback.
-
My trouble is something like this,first set up the json:
It is almost as if 'with' doesn't iterate over json[a] This is cfengine nova 3.21.5. |
Beta Was this translation helpful? Give feedback.
-
I spent a little bit of time trying to get this into a runnable state but It's still not clear to me:
It would be helpful if you could provide whatever is necessary to run the policy directly. Also, I think you could simplify your policy here, it's not clear to me the value your use of with is bringing in most cases. Usually, with is useful for transforming a string at promise actuation time. Say, for example if you want to generate an associatiave array using the canonified version of a string as the key instead of the raw value. But at least from what I see here, I think you could probably remove them.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm a bit unsure about expectation of when 'with' should work.
I have a json file which looks like this:
{
"array": [
"235235"
],
"string": "236253"
}
And '.cf' which looks like this:
vars:
"a_var[$(with)]" -> { "works" }
with => "$(array)",
string => "$(with)";
classes:
"a_exists" -> { "fail" }
with => "$(array)",
fileexists( "..../a_fil_$(with)";
"b_exists" -> { "ok" }
with => "$(string)",
fileexists( "..../b_fil_$(with)");
with in 'vars' and 'classes' behaves differently.
The differenct affects also if /unless in commands
Beta Was this translation helpful? Give feedback.
All reactions