Skip to content

Commit

Permalink
config/configupgrade: Test to show that list unwrapping works for sets
Browse files Browse the repository at this point in the history
This was already working but we had no tests to prove it.
  • Loading branch information
apparentlymart committed Feb 23, 2019
1 parent 929231a commit b217624
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
14 changes: 9 additions & 5 deletions configs/configschema/decoder_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ func (b *Block) DecoderSpec() hcldec.Spec {
}

for name, attrS := range b.Attributes {
ret[name] = &hcldec.AttrSpec{
Name: name,
Type: attrS.Type,
Required: attrS.Required,
}
ret[name] = attrS.decoderSpec(name)
}

for name, blockS := range b.BlockTypes {
Expand Down Expand Up @@ -103,3 +99,11 @@ func (b *Block) DecoderSpec() hcldec.Spec {

return ret
}

func (a *Attribute) decoderSpec(name string) hcldec.Spec {
return &hcldec.AttrSpec{
Name: name,
Type: a.Type,
Required: a.Required,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ resource "test_instance" "bad4" {
security_groups = ["${list("a", "b", "c")}"]
}

resource "test_instance" "bad5" {
security_groups = ["${test_instance.bad1.subnet_ids}"] # this one references a set
}

resource "test_instance" "bad6" {
subnet_ids = ["${test_instance.bad1.security_groups}"] # this one defines a set
}

resource "test_instance" "bad7" {
subnet_ids = ["${test_instance.bad1.*.id}"] # this one defines a set
}

# The rest of these should keep the same amount of list-ness

resource "test_instance" "ok1" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ resource "test_instance" "bad4" {
security_groups = ["a", "b", "c"]
}

resource "test_instance" "bad5" {
security_groups = test_instance.bad1.subnet_ids # this one references a set
}

resource "test_instance" "bad6" {
subnet_ids = test_instance.bad1.security_groups # this one defines a set
}

resource "test_instance" "bad7" {
subnet_ids = test_instance.bad1.*.id # this one defines a set
}

# The rest of these should keep the same amount of list-ness

resource "test_instance" "ok1" {
Expand Down

0 comments on commit b217624

Please sign in to comment.