|
|
|
|
@ -239,6 +239,12 @@ func (c *Config) Validate() error {
|
|
|
|
|
vars := c.InterpolatedVariables()
|
|
|
|
|
varMap := make(map[string]*Variable)
|
|
|
|
|
for _, v := range c.Variables {
|
|
|
|
|
if _, ok := varMap[v.Name]; ok {
|
|
|
|
|
errs = append(errs, fmt.Errorf(
|
|
|
|
|
"Variable '%s': duplicate found. Variable names must be unique.",
|
|
|
|
|
v.Name))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
varMap[v.Name] = v
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -586,43 +592,55 @@ func (c *Config) Validate() error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check that all outputs are valid
|
|
|
|
|
for _, o := range c.Outputs {
|
|
|
|
|
var invalidKeys []string
|
|
|
|
|
valueKeyFound := false
|
|
|
|
|
for k := range o.RawConfig.Raw {
|
|
|
|
|
if k == "value" {
|
|
|
|
|
valueKeyFound = true
|
|
|
|
|
{
|
|
|
|
|
found := make(map[string]struct{})
|
|
|
|
|
for _, o := range c.Outputs {
|
|
|
|
|
// Verify the output is new
|
|
|
|
|
if _, ok := found[o.Name]; ok {
|
|
|
|
|
errs = append(errs, fmt.Errorf(
|
|
|
|
|
"%s: duplicate output. output names must be unique.",
|
|
|
|
|
o.Name))
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if k == "sensitive" {
|
|
|
|
|
if sensitive, ok := o.RawConfig.config[k].(bool); ok {
|
|
|
|
|
if sensitive {
|
|
|
|
|
o.Sensitive = true
|
|
|
|
|
}
|
|
|
|
|
found[o.Name] = struct{}{}
|
|
|
|
|
|
|
|
|
|
var invalidKeys []string
|
|
|
|
|
valueKeyFound := false
|
|
|
|
|
for k := range o.RawConfig.Raw {
|
|
|
|
|
if k == "value" {
|
|
|
|
|
valueKeyFound = true
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if k == "sensitive" {
|
|
|
|
|
if sensitive, ok := o.RawConfig.config[k].(bool); ok {
|
|
|
|
|
if sensitive {
|
|
|
|
|
o.Sensitive = true
|
|
|
|
|
}
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
errs = append(errs, fmt.Errorf(
|
|
|
|
|
"%s: value for 'sensitive' must be boolean",
|
|
|
|
|
o.Name))
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
invalidKeys = append(invalidKeys, k)
|
|
|
|
|
}
|
|
|
|
|
if len(invalidKeys) > 0 {
|
|
|
|
|
errs = append(errs, fmt.Errorf(
|
|
|
|
|
"%s: value for 'sensitive' must be boolean",
|
|
|
|
|
o.Name))
|
|
|
|
|
continue
|
|
|
|
|
"%s: output has invalid keys: %s",
|
|
|
|
|
o.Name, strings.Join(invalidKeys, ", ")))
|
|
|
|
|
}
|
|
|
|
|
invalidKeys = append(invalidKeys, k)
|
|
|
|
|
}
|
|
|
|
|
if len(invalidKeys) > 0 {
|
|
|
|
|
errs = append(errs, fmt.Errorf(
|
|
|
|
|
"%s: output has invalid keys: %s",
|
|
|
|
|
o.Name, strings.Join(invalidKeys, ", ")))
|
|
|
|
|
}
|
|
|
|
|
if !valueKeyFound {
|
|
|
|
|
errs = append(errs, fmt.Errorf(
|
|
|
|
|
"%s: output is missing required 'value' key", o.Name))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, v := range o.RawConfig.Variables {
|
|
|
|
|
if _, ok := v.(*CountVariable); ok {
|
|
|
|
|
if !valueKeyFound {
|
|
|
|
|
errs = append(errs, fmt.Errorf(
|
|
|
|
|
"%s: count variables are only valid within resources", o.Name))
|
|
|
|
|
"%s: output is missing required 'value' key", o.Name))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, v := range o.RawConfig.Variables {
|
|
|
|
|
if _, ok := v.(*CountVariable); ok {
|
|
|
|
|
errs = append(errs, fmt.Errorf(
|
|
|
|
|
"%s: count variables are only valid within resources", o.Name))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|