Open krimdomu opened 8 years ago
I love the idea! :+1:
Would it allow the templates to modify the value of those variables too?
I think we should prevent this to disallow potentially dangerous operations (e.g. changing a $command
variable's value to rm -rf /
, which is later executed by mytask
with run
). At the same time, it can be very a powerful feature too (while making debugging harder ^^).
Are there any alternatives to PadWalker
to evaluate?
It's author says in the docs:
I wouldn't recommend using PadWalker directly in production code
It's probably related to the above point.
It's author says in the docs:
I wouldn't recommend using PadWalker directly in production code
Yes, but it also says ;-)
Some of the modules that use PadWalker internally are certainly safe for and useful in production.
No the variables wouldn't be possible to modify in the template.
Interesting.
Some questions
$x
in the template and its not initialized will it get a value from the task and then the user who is expecting to see an uninitialized value will be surprised? I think ferki has a point about it might make debugging harder? Not sure.Also it kind of violates the idea of low coupling. If you change the task, you gotta go into the template and make sure something wasn't affected there. Whereas before you could just look at was was passed in.
But I guess thats true of automatically passing the task parameters to the template as well which I thought was a great idea a couple weeks ago....
I haven't done tests yet. So i don't know if it is fast or not. I just wanted to know how the people thinks about such a feature before working on it.
Yes, the debugging might be harder, indeed. But this feature should not replace the current behavor. So if user provide their template variables as they are doing today, it should work. And also the manually passed parameters must have precedence over the ones getting with PadWalker.
I use PadWalker in production code. Not very often, but sometimes it's really handy...
IMHO this is a feature that should be enabled explicitly and needs lots of tests...
@jfried:
No the variables wouldn't be possible to modify in the template.
:+1:
@kablamo: I think low coupling is already not there anymore, as CMDB variables are also exposed towards the templates :)
@reneeb: thanks for the feedback on PadWalker! I also think this behaviour can come in handy, and it should be explicitly requested (i.e. being explicit about "I know I want this").
Hi,
it would be possible with the PadWalker Module (https://metacpan.org/pod/PadWalker) to get the variables that the user declared inside a task. With this it would be possible to the something like this:
So it would be possible to access the variables from inside a task in the template that gets parsed in the task. With this the user doesn't need to pass the variables to the template function.
What do you think about this?