Closed alexellis closed 2 years ago
Signed-off-by: Alex Ellis (OpenFaaS Ltd) alexellis2@gmail.com
Allow static files to be published into final image for Go template
Allows code to be published into final image, without leaking additional source code into container.
package function import ( "fmt" "io/ioutil" "os" "log" ) // Handle a serverless request func Handle(req []byte) string { data, err := ioutil.ReadFile("./static/hostname") if err != nil { log.Println(err) os.Exit(-1) } return fmt.Sprintf("File contents: %s", string(data)) }
This is a breaking change for existing users who rely on folder names such as templates or dataset.json within their published image.
templates
dataset.json
Now, put these files into the static folder and read them from ./static/templates/index.html and so forth.
static
./static/templates/index.html
A note will be published in the openfaas docs repo for this new change.
Signed-off-by: Alex Ellis (OpenFaaS Ltd) alexellis2@gmail.com
Description
Allow static files to be published into final image for Go template
Motivation and Context
Allows code to be published into final image, without leaking additional source code into container.
How Has This Been Tested?
Types of changes
How are existing users impacted? What migration steps/scripts do we need?
This is a breaking change for existing users who rely on folder names such as
templates
ordataset.json
within their published image.Now, put these files into the
static
folder and read them from./static/templates/index.html
and so forth.Checklist:
A note will be published in the openfaas docs repo for this new change.