Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New --context flag for pre-loading datasources into context #424

Merged
merged 1 commit into from
Nov 16, 2018

Conversation

hairyhenderson
Copy link
Owner

@hairyhenderson hairyhenderson commented Nov 13, 2018

Fixes #404

Adds a new --context/-c commandline flag to allow pre-loading a datasource into the template's context.

This allows this sort of usage:

$ gomplate -c foo=https://example.com/foo.json -c bar.yml -i '{{ .foo.value }}, {{ .bar.value }}'
foo's value, bar's value
$ gomplate -c .=baz.yml -i '{{ .value }}'
baz's value

Caveats:

  • all context datasources are loaded first - this can introduce latency
  • setting the root (with alias of .) makes .Env unavailable
  • sub-paths can't be given to context datasources in the template (i.e. {{ datasource "foo" "subpath" }})
  • inline datasources can't be added to the context at runtime

Other:

  • context datasources are still available by name as regular datasources:
    $ gomplate -c .=baz.yml -i '{{ .value }} - {{ (ds ".").value }}'
    baz's value - baz's value

Signed-off-by: Dave Henderson [email protected]

@hairyhenderson hairyhenderson self-assigned this Nov 13, 2018
@hairyhenderson hairyhenderson force-pushed the add-datasources-to-context-404 branch 2 times, most recently from 8a5906f to 0566b87 Compare November 13, 2018 04:48
@hairyhenderson hairyhenderson force-pushed the add-datasources-to-context-404 branch from 0566b87 to 8a470c5 Compare November 15, 2018 03:25
@vitalka200
Copy link

vitalka200 commented Nov 15, 2018

Hi @hairyhenderson,
when this PR can be merged?
I wanted to use gomplate to pre-render Helm Charts, and loading datasources is one that is missing.

Thank you!

@hairyhenderson hairyhenderson force-pushed the add-datasources-to-context-404 branch 4 times, most recently from 37cc840 to ae400e0 Compare November 15, 2018 18:38
@hairyhenderson hairyhenderson force-pushed the add-datasources-to-context-404 branch from ae400e0 to 6056ca9 Compare November 15, 2018 18:40
@hairyhenderson hairyhenderson changed the title [WIP] New --context flag for pre-loading datasources into context New --context flag for pre-loading datasources into context Nov 15, 2018
@hairyhenderson
Copy link
Owner Author

@vitalka200 Soon! 😉

Keep in mind that gomplate is not a drop-in replacement for Helm. Helm and gomplate have different sets of functions that are supported, and I don't intend for gomplate to ever be fully Helm-compatible.

If you want true pre-rendering for Helm, I suggest using helm's --dry-run and --debug options.

@hairyhenderson hairyhenderson merged commit 3dad8fe into master Nov 16, 2018
@hairyhenderson hairyhenderson deleted the add-datasources-to-context-404 branch November 16, 2018 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants