config: validate output only has "value" field
This commit is contained in:
parent
a4f38a3933
commit
ed1860de61
|
@ -146,6 +146,19 @@ func (c *Config) Validate() error {
|
|||
}
|
||||
|
||||
// Check that all outputs are valid
|
||||
for _, o := range c.Outputs {
|
||||
invalid := false
|
||||
for k, _ := range o.RawConfig.Raw {
|
||||
if k != "value" {
|
||||
invalid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if invalid {
|
||||
errs = append(errs, fmt.Errorf(
|
||||
"%s: output should only have 'value' field", o.Name))
|
||||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return &multierror.Error{Errors: errs}
|
||||
|
|
|
@ -15,6 +15,13 @@ func TestConfigValidate(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate_outputBadField(t *testing.T) {
|
||||
c := testConfig(t, "validate-output-bad-field")
|
||||
if err := c.Validate(); err == nil {
|
||||
t.Fatal("should not be valid")
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate_unknownResourceVar(t *testing.T) {
|
||||
c := testConfig(t, "validate-unknown-resource-var")
|
||||
if err := c.Validate(); err == nil {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
resource "aws_instance" "web" {
|
||||
}
|
||||
|
||||
output "ip" {
|
||||
value = "foo"
|
||||
another = "nope"
|
||||
}
|
Loading…
Reference in New Issue