From 447a290a8c920f719f82e863277a645df65e1a43 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 16 Nov 2017 10:06:03 +0100 Subject: pkg/config: provide SaveData function Parallel to LoadFile/LoadData. --- pkg/config/config.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pkg/config') diff --git a/pkg/config/config.go b/pkg/config/config.go index c1a761e18..b80e03b3f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -35,13 +35,17 @@ func LoadData(data []byte, cfg interface{}) error { } func SaveFile(filename string, cfg interface{}) error { - data, err := json.MarshalIndent(cfg, "", "\t") + data, err := SaveData(cfg) if err != nil { return err } return osutil.WriteFile(filename, data) } +func SaveData(cfg interface{}) ([]byte, error) { + return json.MarshalIndent(cfg, "", "\t") +} + func checkUnknownFields(data []byte, typ reflect.Type) error { if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Struct { return fmt.Errorf("config type is not pointer to struct") -- cgit mrf-deployment