Hello, I would like to know if it's possible to list all the env that are declared on a subflow! I would like to simplify my code from mapping the env to specific variables, and I would like them to be dynamic! Something like:
for(var e in env)
msg[e] = env.get(e);
return msg;
it is not possible to list the env vars set on a subflow. We only provide env.get() as a way to get the value of a known env var.
Env vars cannot be dynamic. Their main use is to allow per-subflow customisation of nodes within the subflow. Nodes cannot dynamically change their settings.
Thank you @knolleary put that in your "To Think one day if I have the time. Probably not! Not!" list . That would be a got thing, a way to retrieve all the env (and if possible, global, flow) variables.
You can already use flow.keys() and global.keys(). We don't have the equivalent for env - there are good reasons for not allowing a flow to get all the env vars - as they will typically be used to provide passwords or other secure details. Allowing a flow to iterate over them and report their value would be a potential security issue. Same reason we don't expose process.env in the Function node by default.
I understand @knolleary , in the env the keys() should be more restrict. It should only return in nodered subflow the env that are declared in that subflow. The subflow is under my control, so if I put a password in the subflow interface it would not be exposing any sensitive data, because I put it there, and I know it. Basically I'm getting data that I put there! Not data that someone put there, the subflow is written by me (or loaded by me) and unique to my nodered instance. From that point of view, the global.keys() and flow.keys() are also very sensitive, they also can store passwords (to reuse in multiple flows for example, we can't add a costume configure node to that).