-
Notifications
You must be signed in to change notification settings - Fork 280
/
xds_lua.go
54 lines (42 loc) · 996 Bytes
/
xds_lua.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package controlplane
import (
"os"
"github.com/rakyll/statik/fs"
// include luascripts source code
_ "github.com/pomerium/pomerium/internal/controlplane/luascripts"
)
//go:generate go run github.com/rakyll/statik -src=./luascripts -include=*.lua -p luascripts -ns luascripts
//go:generate go fmt ./luascripts/statik.go
var luascripts struct {
ExtAuthzSetCookie string
CleanUpstream string
}
func init() {
hfs, err := fs.NewWithNamespace("luascripts")
if err != nil {
panic(err)
}
fileToField := map[string]*string{
"/clean-upstream.lua": &luascripts.CleanUpstream,
"/ext-authz-set-cookie.lua": &luascripts.ExtAuthzSetCookie,
}
err = fs.Walk(hfs, "/", func(p string, fi os.FileInfo, err error) error {
if err != nil {
return err
}
if fi.IsDir() {
return nil
}
bs, err := fs.ReadFile(hfs, p)
if err != nil {
return err
}
if ptr, ok := fileToField[p]; ok {
*ptr = string(bs)
}
return nil
})
if err != nil {
panic(err)
}
}