summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2020-03-18 22:19:23 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2020-03-18 22:19:23 +0100
commitb3a4513d3d17f10dee499e42db184fc89917bcd5 (patch)
tree4779c5befdb0771e3353987c79ea59d5f30f77d6 /pkg/tcpip
parent190f2587d5620e86cc9d0868314d08f922217b9e (diff)
WIP LoadFromBytes
Diffstat (limited to 'pkg/tcpip')
-rw-r--r--pkg/tcpip/config/config.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/pkg/tcpip/config/config.go b/pkg/tcpip/config/config.go
index c3518ef35..d021bf6a3 100644
--- a/pkg/tcpip/config/config.go
+++ b/pkg/tcpip/config/config.go
@@ -118,14 +118,9 @@ type Config struct {
routes []tcpip.Route
}
-func Load(yamlname string) (*Config, error) {
- data, err := ioutil.ReadFile(yamlname)
- if err != nil {
- log.Fatalf("File reading error", err)
- }
-
+func LoadFromBytes(data []byte) (*Config, error) {
var np Netplan
- err = yaml.Unmarshal(data, &np)
+ err := yaml.Unmarshal(data, &np)
fmt.Println("err", err)
fmt.Println("res", np)
@@ -139,6 +134,15 @@ func Load(yamlname string) (*Config, error) {
}, nil
}
+func Load(yamlname string) (*Config, error) {
+ data, err := ioutil.ReadFile(yamlname)
+ if err != nil {
+ log.Fatalf("File reading error", err)
+ }
+
+ return LoadFromBytes(data)
+}
+
func CheckError(err error) {
if err != nil {
log.Fatal("Error: " , err)