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 😞... But I think 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)
- Cannot install in GitHub Actions using go install HOT 8
- `file.Write` doesn't respect outputDir HOT 7
- gomplate produces no result and no error HOT 1
- Need to finalize gomplate.Renderer and related types before v4.0.0 HOT 2
- Tests failing on 32-bit builds due to unaligned struct in dependency HOT 5
- Provide TrimLeft and TrimRight Support HOT 8
- Process datasources as templates before the final template
- SQL datasource HOT 3
- bug: can't retrieve from Vault KVv2 mounts with slashes in the name HOT 6
- Release `aarch64` artifact HOT 1
- vault aws iam auth support/documentation
- aws sm and smp datasources fail on EC2 instance HOT 3
- plugin function is executed within an if block that evaluates to false HOT 5
- Is the second example for `coll.Merge` incorrect?
- OS information... HOT 1
- Secrets Manager Datasource Doesn't Appear to Work HOT 3
- Turn off following symlinks HOT 3
- Handling generic path type with versioning in Vault
- Update Go version to 1.22.5 due to CVE-2024-24791
- `excludeProcessing` does not obey negative patterns
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.