You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using plugins as a sort of tagging mechanism, where the plugin code needs the path to the file it was called from. There is only one small annoyance with using plugins in this way: as far as I can tell, there is no way to access the calling context from the plugin, so I have to pass that from the call site like this:
{{ tmpl.PathDir | my-plugin }}
This is tolerable, but it got me thinking, wouldn't it be neat if the plugin args were templateable or had some way to pass variables directly in the plugin config? Something like this:
The main issue I have with the current situation is that I want the plugin to define which value goes in the arg. For one plugin I want tmpl.PathDir and for another plugin I want tmpl.Path and for some other plugin I might want the value of a given secret from a datasource. Passing that info from the call site is putting control in the template that I want to retain in the plugin config so that the call site is concise and not so error-prone.
There is another (perhaps simpler) way to do what I want, which would be to some way to export variables into the environment from context variables in the environment when calling the plugins. I noticed that there is already a datasource environment variable, but nothing else to tell the plugin about the context where it's being called.
How hard would this be? I haven't yet dug deep into the code to understand the way it's calling the plugins and I don't want to try introducing something upstream that is totally unwanted (if nobody is interested, I'll just come up with a local hack that does what I need).
Feedback appreciated, especially if there is an obviously better way to do this that I'm just missing somehow. I certainly couldn't find anything appropriate in the documentation and I think I've pored over it pretty thoroughly.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm using plugins as a sort of tagging mechanism, where the plugin code needs the path to the file it was called from. There is only one small annoyance with using plugins in this way: as far as I can tell, there is no way to access the calling context from the plugin, so I have to pass that from the call site like this:
This is tolerable, but it got me thinking, wouldn't it be neat if the plugin args were templateable or had some way to pass variables directly in the plugin config? Something like this:
.gomplate.yaml
The main issue I have with the current situation is that I want the plugin to define which value goes in the arg. For one plugin I want
tmpl.PathDir
and for another plugin I wanttmpl.Path
and for some other plugin I might want the value of a given secret from a datasource. Passing that info from the call site is putting control in the template that I want to retain in the plugin config so that the call site is concise and not so error-prone.There is another (perhaps simpler) way to do what I want, which would be to some way to export variables into the environment from context variables in the environment when calling the plugins. I noticed that there is already a datasource environment variable, but nothing else to tell the plugin about the context where it's being called.
How hard would this be? I haven't yet dug deep into the code to understand the way it's calling the plugins and I don't want to try introducing something upstream that is totally unwanted (if nobody is interested, I'll just come up with a local hack that does what I need).
Feedback appreciated, especially if there is an obviously better way to do this that I'm just missing somehow. I certainly couldn't find anything appropriate in the documentation and I think I've pored over it pretty thoroughly.
Beta Was this translation helpful? Give feedback.
All reactions