blob: 65fb0612c800181e1abbf6bda8add50ee012b80e [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
giolekva1c0372c2020-05-16 21:18:59 +040019type CallAction struct {
20 App string `yaml:"app"`
21 Action string `yaml:"action"`
22 Args map[string]interface{} `yaml:"args"`
23}
24
25type PostInstall struct {
26 CallAction []CallAction `yaml:"callAction"`
27}
28
29type Init struct {
30 PostInstall PostInstall `yaml:"postInstall"`
31}
32
giolekvab1f19ee2020-05-16 11:31:20 +040033func FromYaml(str string, out interface{}) error {
34 return yaml.Unmarshal([]byte(str), out)
35}
36
37func FromYamlFile(actionsFile string, out interface{}) error {
38 f, err := os.Open(actionsFile)
39 if err != nil {
40 return err
41 }
42 defer f.Close()
43 b, err := ioutil.ReadAll(f)
44 if err != nil {
45 return err
46 }
47 return FromYaml(string(b), out)
48}