FileContent: tolerant base64 reader

This commit is contained in:
Mikaël Cluseau
2026-02-10 15:14:01 +01:00
parent 56f78e083a
commit 7eff78e870

View File

@ -6,6 +6,7 @@ import (
"io"
"net"
"os"
"strings"
"time"
yaml "gopkg.in/yaml.v2"
@ -157,11 +158,13 @@ type NetworkDef struct {
Script string
}
var b64 = base64.RawStdEncoding
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)
decoded, err := b64.DecodeString(strings.TrimRight(f.Content64, "="))
if err != nil {
panic(fmt.Errorf("invalid base64 content in file %s", f.Path))
}