support for file's content64

This commit is contained in:
Mikaël Cluseau
2026-01-25 20:55:15 +01:00
parent 183099f7da
commit 0dbab431a0
3 changed files with 8 additions and 3 deletions

View File

@ -32,6 +32,8 @@ import (
var cmdlineParam = restful.QueryParameter("cmdline", "Linux kernel cmdline addition")
var b64 = base64.StdEncoding.WithPadding(base64.NoPadding)
type renderContext struct {
Host *localconfig.Host
SSLConfig *cfsslconfig.Config
@ -102,6 +104,8 @@ func (ctx *renderContext) Config() (ba []byte, cfg *config.Config, err error) {
return
}
// log.Print("rendered config:\n", string(ba))
cfg = &config.Config{}
if err = yaml.Unmarshal(ba, cfg); err != nil {
return
@ -189,6 +193,7 @@ func (ctx *renderContext) TemplateFuncs() map[string]any {
enc := base64.StdEncoding.WithPadding(base64.NoPadding)
return enc.EncodeToString([]byte(input))
},
"host_ip": func() (s string) {
return ctx.Host.IPs[0]
},

2
go.mod
View File

@ -25,7 +25,7 @@ require (
gopkg.in/yaml.v2 v2.4.0
k8s.io/apimachinery v0.33.2
m.cluseau.fr/go v0.0.0-20230809064045-12c5a121c766
novit.tech/direktil/pkg v0.0.0-20250706092353-d857af8032a1
novit.tech/direktil/pkg v0.0.0-20260125193049-56f78e083a84
)
replace github.com/zmap/zlint/v3 => github.com/zmap/zlint/v3 v3.3.1

4
go.sum
View File

@ -346,5 +346,5 @@ k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
m.cluseau.fr/go v0.0.0-20230809064045-12c5a121c766 h1:JRzMBDbUwrTTGDJaJSH0ap4vRL0Q9CN1bG8a6n49eaQ=
m.cluseau.fr/go v0.0.0-20230809064045-12c5a121c766/go.mod h1:BMv3aOSYpupuiiG3Ch3ND88aB5CfAks3YZuRLE8j1ls=
novit.tech/direktil/pkg v0.0.0-20250706092353-d857af8032a1 h1:hKj9qhbTAoTxYIj6KaMLJp9I+bvZfkSM/QwK8Bd496o=
novit.tech/direktil/pkg v0.0.0-20250706092353-d857af8032a1/go.mod h1:zjezU6tELE880oYHs/WAauGBupKIEQQ7KqWTB69RW10=
novit.tech/direktil/pkg v0.0.0-20260125193049-56f78e083a84 h1:eqLPaRpVth1WgdvprKKtc4CVF13dkxuKbo7bLzlYG6s=
novit.tech/direktil/pkg v0.0.0-20260125193049-56f78e083a84/go.mod h1:zjezU6tELE880oYHs/WAauGBupKIEQQ7KqWTB69RW10=