Skip to content

Commit

Permalink
Add SetKey
Browse files Browse the repository at this point in the history
  • Loading branch information
MissingRoberto committed Jul 22, 2017
1 parent b285bfe commit 9d30b58
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions set.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ import (
)

func SetKeyInFile(file string, path string, key string) error {
bytes, err := ioutil.ReadFile(key)
yaml, err := ReadYamlFromFile(file)
if err != nil {
return err
}
value := string(bytes)

return SetInFile(file, path, value)
err = SetKey(yaml, path, key)
if err != nil {
return err
}

return WriteYaml(yaml, file)
}

func SetKey(yaml *simpleyaml.Yaml, path string, key string) error {
bytes, err := ioutil.ReadFile(key)
if err != nil {
return err
}
return Set(yaml, path, string(bytes))
}

func SetInFile(file string, path string, val interface{}) error {
Expand Down

0 comments on commit 9d30b58

Please sign in to comment.