gomplate icon indicating copy to clipboard operation
gomplate copied to clipboard

Add ability to disable or rename the special `type` query parameter

Open dbluxo opened this issue 1 year ago • 7 comments

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!

dbluxo avatar Jan 25 '23 12:01 dbluxo

I think this is an edge case: https://docs.gomplate.ca/datasources/#overriding-mime-types

kekscode avatar Jan 25 '23 13:01 kekscode

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

hairyhenderson avatar Jan 25 '23 22:01 hairyhenderson

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 }}

hairyhenderson avatar Jan 25 '23 22:01 hairyhenderson

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.

dbluxo avatar Jan 26 '23 16:01 dbluxo

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

hairyhenderson avatar Jan 26 '23 19:01 hairyhenderson

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.

github-actions[bot] avatar Apr 03 '23 04:04 github-actions[bot]

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.

github-actions[bot] avatar Jun 05 '23 04:06 github-actions[bot]