Comments (7)
If you think this is a good idea, I can work on a PR.
from gomplate.
Thanks a lot for this neat tool
You're very welcome!
PR #114 just went in, which allows for multiple files to be read at a time (and multiple outputs specified), so that's part of the equation.
But iterating dirs natively is a really good idea. I'd love to see a PR for this. I like --input-dir
and --output-dir
as option names.
As far as the collection of datasources goes, how about instead having a new URL scheme, something like dir:///foo/bar/baz
? It could be treated similarly to how the Vault datasource works, in terms of specifying sub-keys:
Let's say you had a directory like:
/tmp/data
/foo.json
/bar.yaml
So, you could have a template like this:
(in.tmpl)
{{ (datasource "mydir" "foo").whatever }}
{{ (datasource "mydir" "bar").something }}
$ gomplate -d mydir=dir:///tmp/data -i in.tmpl
Does that make sense?
Either way - can you work on the input/output-dir and datasource dirs as two separate PRs?
from gomplate.
@hairyhenderson yeah, have seen the new options also in the README and was confused a bit that this was not yet release (but already documented). Took me a bit ;-) Having options for specfiying in and out files is a very good thing because then in an Docker environment you don't need any shell for piping things into gomplate and redirect it to files. As much as I love this as part of the Unix philosophy, this makes it impossible to use a blank base image (scratch).
If gomplate could do all the file handling, then it would be even a better fit for configuration pre processing in an orchestration environment (like in Kubernetes / OpenShift init-containers).
{{ (datasource "mydir" "foo").whatever }}
{{ (datasource "mydir" "bar").something }}
A new URL scheme would make it, too. tbh I think this will bloat the usage patterns quite a bit more. In templates with a lot of parameters to fill in, having to always write (datasource <name> <arg>)
is quite a mouthful and redundant imo. I would even try to shorten this (e.g 'ds' as an alias to 'datasource' or even to allow to work directly on the datasource like with {{ foo.whatEver }}
(don't know hard this would be to implement, though. Not really a gopher ;-) just an idea.
Let me try to start with the input/output-dir which I think is of reasonable scope for a golang starter like me ;-)
from gomplate.
and was confused a bit that this was not yet release (but already documented)
sorry about that - I've been meaning to release 1.6.0 but I want to get some more robust testing in place, and do a little refactoring first. I'm at DockerCon this week and haven't had time to really focus on much
from gomplate.
e.g 'ds' as an alias to 'datasource'
That's a great idea
or even to allow to work directly on the datasource like with {{ foo.whatEver }} (don't know hard this would be to implement, though
Unfortunately that'd be quite difficult due to how Go templating works ds
would be enough to make the templates a bit more manageable.
Looking forward to the PR!
from gomplate.
Hi,
I started working with gomplate recently and am struck at the below point, so can you please help me out.
I have a datasource file live.yaml and created the below template file but in line 3 I am unable to replace datasource name live with a variable that I will have a data driven template
{{$instance:=(getenv "INSTANCE_TYPE")}}
{{$ds := datasource $instance }}
{{range $item := $ds.live}}
{{ if eq $item.type "none" }}
scp $WORKSPACE/myDoctor.ear.tar.bz2 {{$item.user}}@{{$item.name}}:{{$item.path}}
ssh {{$item.user}}@{{$item.name}} {{$item.stop}}
ssh {{$item.user}}@{{$item.name}} tar -xjf {{$item.path}}/myDoctor.ear.tar.bz2 -C {{$item.path}}/deployments/
ssh {{$item.user}}@{{$item.name}} {{$item.start}}
{{end}}
{{end}}
from gomplate.
@vegapatel can you please open a new issue instead of commenting on a closed issue? And when you do, please also let me know what the full command is that you're running as well. Thanks!
from gomplate.
Related Issues (20)
- etcd support as datasource HOT 2
- PPC64 build missing from the latest release HOT 4
- Validation of the generated template
- The function `coll.Index` can not be evaluated HOT 2
- allow templating in `.gomplateignore`, so folder can be dynamically excluded by configs HOT 9
- output-map not working with external template HOT 3
- net.ParsePrefix error HOT 1
- doc site should show docs from latest major release rather than main HOT 2
- Function to generate MAC addresses HOT 7
- Feature request: straightforward way to include templates HOT 3
- Feature request: add crypto.MD5 HOT 6
- Feature request: function to embed the output of shell commands/scripts HOT 5
- Documentation: header and delimiter in data.CSVBy* functions HOT 3
- Request for new release 13.11.x? HOT 2
- Consider making slim-sprig functions first-class HOT 5
- docs: Listing the `crypto.SHA*` functions together makes the ToC hide the docs HOT 1
- update usage docs to explain "multiple outputs from one template" HOT 6
- access runtime configs from within templates HOT 2
- Unable to pass a Slice of string keys to coll.Pick() HOT 1
- Question: How can I do a different action if it is the last iteration of a loop
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gomplate.