config.FileDef: add Content64 for base64-encoded content

This commit is contained in:
Mikaël Cluseau
2026-01-25 20:30:49 +01:00
parent d857af8032
commit 56f78e083a

View File

@ -1,6 +1,7 @@
package config
import (
"encoding/base64"
"fmt"
"io"
"net"
@ -133,11 +134,12 @@ type UserDef struct {
}
type FileDef struct {
Path string
Mode os.FileMode
Content string
Symlink string
Dir bool
Path string
Mode os.FileMode
Content string
Content64 string
Symlink string
Dir bool
}
type NetworkDef struct {
@ -158,6 +160,13 @@ type NetworkDef struct {
func (c *Config) FileContent(filePath string) []byte {
for _, f := range c.Files {
if f.Path == filePath {
if f.Content64 != "" {
decoded, err := base64.StdEncoding.DecodeString(f.Content64)
if err != nil {
panic(fmt.Errorf("invalid base64 content in file %s", f.Path))
}
return decoded
}
return []byte(f.Content)
}
}