1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package main
import (
"fmt"
"io"
"github.com/google/go-jsonnet"
)
func Transpile(in io.Reader, repoURL string) (string, error) {
data, err := io.ReadAll(in)
if err != nil {
return "", err
}
vm := jsonnet.MakeVM()
output, err := vm.EvaluateAnonymousSnippet("policy.jsonnet", string(data))
if err != nil {
return "", err
}
stanza := fmt.Sprintf("// This tailnet's ACLs are maintained in %s", repoURL)
return fmt.Sprintf("%s\n%s", stanza, output), nil
}
|