From 261cdc2564653b62f966466332e5d145364b4073 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 19 Jun 2017 16:34:59 +0200 Subject: pkg/config: add SaveFile function --- pkg/config/config.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pkg/config') diff --git a/pkg/config/config.go b/pkg/config/config.go index b31399713..fc77d2496 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -32,6 +32,14 @@ func LoadData(data []byte, cfg interface{}) error { return nil } +func SaveFile(filename string, cfg interface{}) error { + data, err := json.MarshalIndent(cfg, "", "\t") + if err != nil { + return err + } + return ioutil.WriteFile(filename, data, 0600) +} + 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