add terraform config merge logic to config.Merge

This commit is contained in:
James Bardin 2017-03-22 09:01:54 -04:00
parent b38e620b2f
commit bcbcc65f7d
3 changed files with 33 additions and 3 deletions

View File

@ -119,6 +119,7 @@ func TestAppend(t *testing.T) {
false,
},
// appending configs merges terraform blocks
{
&Config{
Terraform: &Terraform{

View File

@ -32,9 +32,13 @@ func Merge(c1, c2 *Config) (*Config, error) {
c.Atlas = c2.Atlas
}
// Merge the Terraform configuration, which is a complete overwrite.
// Merge the Terraform configuration
if c1.Terraform != nil {
c.Terraform = c1.Terraform
if c2.Terraform != nil {
c.Terraform.Merge(c2.Terraform)
}
} else {
c.Terraform = c2.Terraform
}

View File

@ -434,6 +434,31 @@ func TestMerge(t *testing.T) {
},
false,
},
// terraform blocks are merged, not overwritten
{
&Config{
Terraform: &Terraform{
RequiredVersion: "A",
},
},
&Config{
Terraform: &Terraform{
Backend: &Backend{
Type: "test",
},
},
},
&Config{
Terraform: &Terraform{
RequiredVersion: "A",
Backend: &Backend{
Type: "test",
},
},
},
false,
},
}
for i, tc := range cases {