config: outputs must be unique
This commit is contained in:
parent
8494cad8c4
commit
099293b690
|
@ -586,7 +586,18 @@ func (c *Config) Validate() error {
|
|||
}
|
||||
|
||||
// Check that all outputs are valid
|
||||
{
|
||||
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
|
||||
}
|
||||
found[o.Name] = struct{}{}
|
||||
|
||||
var invalidKeys []string
|
||||
valueKeyFound := false
|
||||
for k := range o.RawConfig.Raw {
|
||||
|
@ -626,6 +637,7 @@ func (c *Config) Validate() error {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check that all variables are in the proper context
|
||||
for source, rc := range c.rawConfigs() {
|
||||
|
|
|
@ -300,6 +300,13 @@ func TestConfigValidate_outputBadField(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate_outputDuplicate(t *testing.T) {
|
||||
c := testConfig(t, "validate-output-dup")
|
||||
if err := c.Validate(); err == nil {
|
||||
t.Fatal("should not be valid")
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigValidate_pathVar(t *testing.T) {
|
||||
c := testConfig(t, "validate-path-var")
|
||||
if err := c.Validate(); err != nil {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
resource "aws_instance" "web" {
|
||||
}
|
||||
|
||||
output "ip" {
|
||||
value = "foo"
|
||||
}
|
||||
|
||||
output "ip" {
|
||||
value = "bar"
|
||||
}
|
Loading…
Reference in New Issue