From b3a4513d3d17f10dee499e42db184fc89917bcd5 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 18 Mar 2020 22:19:23 +0100 Subject: WIP LoadFromBytes --- pkg/tcpip/config/config.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'pkg/tcpip/config/config.go') 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) -- cgit v1.2.3