Giter Club home page Giter Club logo

Comments (7)

rhuss avatar rhuss commented on May 18, 2024

If you think this is a good idea, I can work on a PR.

from gomplate.

hairyhenderson avatar hairyhenderson commented on May 18, 2024

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.

rhuss avatar rhuss commented on May 18, 2024

@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.

hairyhenderson avatar hairyhenderson commented on May 18, 2024

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.

hairyhenderson avatar hairyhenderson commented on May 18, 2024

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.

vegapatel avatar vegapatel commented on May 18, 2024

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.

hairyhenderson avatar hairyhenderson commented on May 18, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.