1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 22:32:14 +00:00

ros config get shows default values

This commit is contained in:
Josh Curl
2016-03-31 21:31:46 -07:00
parent ecae451ad1
commit c0c8179813
12 changed files with 103 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
package util
import (
"bytes"
"errors"
"fmt"
"io"
@@ -68,6 +69,25 @@ func Convert(from, to interface{}) error {
return yaml.Unmarshal(bytes, to)
}
func ConvertIgnoreOmitEmpty(from, to interface{}) error {
var buffer bytes.Buffer
encoder := yaml.NewEncoder(&buffer)
encoder.IgnoreOmitEmpty = true
if err := encoder.Encode(from); err != nil {
return err
}
decoder := yaml.NewDecoder(&buffer)
if err := decoder.Decode(to); err != nil {
return err
}
return nil
}
func Copy(d interface{}) interface{} {
switch d := d.(type) {
case map[interface{}]interface{}: