config.FileDef: add Content64 for base64-encoded content
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@ -136,6 +137,7 @@ type FileDef struct {
|
|||||||
Path string
|
Path string
|
||||||
Mode os.FileMode
|
Mode os.FileMode
|
||||||
Content string
|
Content string
|
||||||
|
Content64 string
|
||||||
Symlink string
|
Symlink string
|
||||||
Dir bool
|
Dir bool
|
||||||
}
|
}
|
||||||
@ -158,6 +160,13 @@ type NetworkDef struct {
|
|||||||
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 != "" {
|
||||||
|
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)
|
return []byte(f.Content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user