1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
11 "github.com/ghodss/yaml"
14 // LoadFile loads configuration from the file given by configPath and
15 // decodes it into cfg.
17 // YAML and JSON formats are supported.
18 func LoadFile(cfg interface{}, configPath string) error {
19 buf, err := ioutil.ReadFile(configPath)
23 err = yaml.Unmarshal(buf, cfg)
25 return fmt.Errorf("Error decoding config %q: %v", configPath, err)
30 // Dump returns a YAML representation of cfg.
31 func Dump(cfg interface{}) ([]byte, error) {
32 return yaml.Marshal(cfg)