blob: 88d2551571d9e7c58baf7a55e4b51544ca3ec3d9 [file] [log] [blame]
giolekvab1f19ee2020-05-16 11:31:20 +04001package appmanager
2
3import (
4 "io/ioutil"
5 "os"
6
7 "gopkg.in/yaml.v2"
8)
9
10type Action struct {
11 Name string `yaml:"name"`
12 Template string `yaml:"template"`
13}
14
15type Actions struct {
16 Actions []Action `yaml:"actions"`
17}
18
19func FromYaml(str string, out interface{}) error {
20 return yaml.Unmarshal([]byte(str), out)
21}
22
23func FromYamlFile(actionsFile string, out interface{}) error {
24 f, err := os.Open(actionsFile)
25 if err != nil {
26 return err
27 }
28 defer f.Close()
29 b, err := ioutil.ReadAll(f)
30 if err != nil {
31 return err
32 }
33 return FromYaml(string(b), out)
34}