-
Notifications
You must be signed in to change notification settings - Fork 52
/
module_config.go
47 lines (41 loc) · 1.07 KB
/
module_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package moduleconfig
import (
"io/ioutil"
yaml "gopkg.in/yaml.v2"
)
type ModuleConfig struct {
Name string
Description string
Author string
DependsOn []string `yaml:"dependsOn,omitempty"`
TemplateConfig `yaml:"template"`
RequiredCredentials []string `yaml:"requiredCredentials"`
Parameters []Parameter
}
type Parameter struct {
Field string
Label string `yaml:"label,omitempty"`
Options []string `yaml:"options,omitempty"`
Execute string `yaml:"execute,omitempty"`
Value string `yaml:"value,omitempty"`
Default string `yaml:"default,omitempty"`
Info string `yaml:"info,omitempty"`
}
type TemplateConfig struct {
StrictMode bool
Delimiters []string
InputDir string `yaml:"inputDir"`
OutputDir string `yaml:"outputDir"`
}
func LoadModuleConfig(filePath string) (ModuleConfig, error) {
config := ModuleConfig{}
data, err := ioutil.ReadFile(filePath)
if err != nil {
return config, err
}
err = yaml.Unmarshal(data, &config)
if err != nil {
return config, err
}
return config, nil
}