FileContent: tolerant base64 reader
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
@ -157,11 +158,13 @@ type NetworkDef struct {
|
|||||||
Script string
|
Script string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var b64 = base64.RawStdEncoding
|
||||||
|
|
||||||
func (c *Config) FileContent(filePath string) []byte {
|
func (c *Config) FileContent(filePath string) []byte {
|
||||||
for _, f := range c.Files {
|
for _, f := range c.Files {
|
||||||
if f.Path == filePath {
|
if f.Path == filePath {
|
||||||
if f.Content64 != "" {
|
if f.Content64 != "" {
|
||||||
decoded, err := base64.StdEncoding.DecodeString(f.Content64)
|
decoded, err := b64.DecodeString(strings.TrimRight(f.Content64, "="))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("invalid base64 content in file %s", f.Path))
|
panic(fmt.Errorf("invalid base64 content in file %s", f.Path))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user