func/templates
github-actions[bot] 70fd17642e
chore: update Springboot platform version to 3.1.0 (#1763)
Co-authored-by: Knative Automation <automation@knative.team>
2023-05-27 00:42:26 +00:00
..
go feat: write instanced and static scaffolding (#1732) 2023-05-18 20:03:14 +00:00
node feat: custom health checks for node and typescript (#1682) 2023-04-25 06:31:44 +00:00
python Add Python templates for gunicorn and uwsgi + Flask (#1655) 2023-04-10 19:03:48 +00:00
quarkus chore: update Quarkus platform version to 3.0.4.Final (#1758) 2023-05-25 13:41:25 +00:00
rust chore: remove Procfile from Rust templates (#1736) 2023-05-10 18:07:01 +00:00
springboot chore: update Springboot platform version to 3.1.0 (#1763) 2023-05-27 00:42:26 +00:00
typescript feat: custom health checks for node and typescript (#1682) 2023-04-25 06:31:44 +00:00
README.md chore: refactor repository layout (#1554) 2023-02-15 08:46:52 +00:00
manifest.yaml feat(templates): remove liveness and readiness from defaults (#1555) 2023-02-16 08:23:51 +00:00

README.md

Templates

Packaging

When updates are made to these templates, they must be packaged (serialized as a Go byte array) by running make generate/zz_filesystem_generated.go, and checking in the resultant ./generate/zz_filesystem_generated.go file.

How it works

The ./generate/templates directory contains Go program that generates ./generate/zz_filesystem_generated.go. The file defines byte array variable named TemplatesZip. The variable contains ZIP representation of the templates directory. The byte array variable is then used to instantiate exported global variable function.EmbeddedTemplatesFS, which implements standard Go interfaces fs.ReadDirFS and fs.StatFS.

Rationale

Until such time as embedding static assets in binaries is included in the base go build functionality (see https://github.com/golang/go/issues/35950) we need to use our custom serialization script (./generate/templates/main.go).

Native Go embedding introduced in Go 1.16 could be used for executable binary, however it cannot be used for library. For a library we need to generate a Go source code containing the templates.