knative/func

Placeholders to pass values to template rendering

aliok opened this issue · 5 comments

aliok commented

When I create a NodeJS HTTP func using the template, I see it is always created with the same package name: http-handler: https://github.com/knative/func/blob/main/templates/node/http/package.json#L2

kn func create -l node -t http

It would be useful to make some1 of these hardcoded values placeholders.

Something like this:

kn func create -l node -t http -p name:"my-handler"

which can generate something like:

{
  "name": "my-handler",
  "version": "0.1.0",

Current hardcoded values can be the defaults.

While name is just very simple and doesn't provide much value, having ports, builders, baseImages, etc. can be very useful.

Context:

  • I am working on creating some Backstage templates for Knative Function templates.
  • If there was a way to pass some arguments to the function during the creation, I wouldn't need to duplicate these templates and add some placeholders in them

Footnotes

  1. Definition of what to keep hardcoded and what to parametrize needs some work.

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

yes this would be super helpful

If we do this improvement, we can use these templates as-is in Backstage.

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.