Define variables as blocks with defaults

Signed-off-by: Patrick Van Stee <patrick@vanstee.me>
This commit is contained in:
Patrick Van Stee
2020-04-15 21:00:20 -04:00
parent 5185d534bc
commit f10d8dab5e
3 changed files with 45 additions and 10 deletions

View File

@@ -70,8 +70,9 @@ func ParseFile(fn string) (*Config, error) {
}
type Config struct {
Groups []*Group `hcl:"group,block"`
Targets []*Target `hcl:"target,block"`
Variables []*Variable `json:"-" hcl:"variable,block"`
Groups []*Group `json:"groups" hcl:"group,block"`
Targets []*Target `json:"targets" hcl:"target,block"`
}
func mergeConfig(c1, c2 Config) Config {
@@ -316,6 +317,11 @@ func (c Config) target(name string, visited map[string]struct{}, overrides map[s
return tt, nil
}
type Variable struct {
Name string `json:"-" hcl:"name,label"`
Default string `json:"default,omitempty" hcl:"default,optional"`
}
type Group struct {
Name string `json:"-" hcl:"name,label"`
Targets []string `json:"targets" hcl:"targets"`