gomplate
gomplate copied to clipboard
Add ability to disable or rename the special `type` query parameter
Hey :wave:,
I'm trying to set a query parameter for an http datasource:
What works:
gomplate -d repos=https://<redacted>/api/repositories
What does not work:
gomplate -d repos=https://<redacted>/api/repositories?type=local
How to set ?type=local
for the http datasource?
Thanks!
I think this is an edge case: https://docs.gomplate.ca/datasources/#overriding-mime-types
@dbluxo can you clarify what "does not work" means here?
The type
parameter is interpreted by gomplate to act as a media type hint for processing the result, so setting it to a non-MIME-type will probably break parsing.
This definitely feels like an unexpected edge-case, but it was bound to hit someone eventually 😓
I guess one workaround would be to use include
instead of datasource
/ds
in your template to avoid parsing the data, and then parse it later specifically as the expected format with the appropriate data
function.
For example:
{{ $parsed := include "repos" | data.JSON }}
can you clarify what "does not work" means here?
When I run it with ?type=local
, I get the following error message:
17:01:35 ERR error="failed to render template gomplate/template.yaml: template: gomplate/template.yaml:5:30: executing \"gomplate/template.yaml\" at <ds \"repos\">: error calling ds: Datasources of type local not yet supported"
I have now implemented it without ?type=local
and perform the local repositories filtering in the template.
ok yeah - my assumption in https://github.com/hairyhenderson/gomplate/issues/1606#issuecomment-1404282464 stands then...
perhaps the type
query parameter is something that could be disabled optionally...
This issue is stale because it has been open for 60 days with no activity. Remove stale
label or comment or this will be automatically closed in a few days.
This issue is stale because it has been open for 60 days with no activity. Remove stale
label or comment or this will be automatically closed in a few days.