From 4d5661fa8ecd1ffbfa55f090fe3c382060f28ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Tue, 10 Feb 2026 15:14:01 +0100 Subject: [PATCH] FileContent: tolerant base64 reader --- base64/base64.go | 10 ++++++++++ config/config.go | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 base64/base64.go diff --git a/base64/base64.go b/base64/base64.go new file mode 100644 index 0000000..0354ac9 --- /dev/null +++ b/base64/base64.go @@ -0,0 +1,10 @@ +package base64 + +import ( + "encoding/base64" + "strings" +) + +func Decode(s string) ([]byte, error) { + return base64.RawStdEncoding.DecodeString(strings.TrimRight(s, "=")) +} diff --git a/config/config.go b/config/config.go index 8f6b79e..5dac1f9 100644 --- a/config/config.go +++ b/config/config.go @@ -1,7 +1,6 @@ package config import ( - "encoding/base64" "fmt" "io" "net" @@ -9,6 +8,8 @@ import ( "time" yaml "gopkg.in/yaml.v2" + + "novit.tech/direktil/pkg/base64" ) // Load a config from a file. @@ -161,7 +162,7 @@ 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 := base64.Decode(f.Content64) if err != nil { panic(fmt.Errorf("invalid base64 content in file %s", f.Path)) }