Skip to content

Commit 2574f7d

Browse files
authored
Merge pull request hashicorp#22270 from hashicorp/appilon/prune-terraform.NewResourceConfig
[CLEANUP] Prune terraform.NewResourceConfig
2 parents 869ac33 + 2a01704 commit 2574f7d

26 files changed

Lines changed: 380 additions & 2231 deletions

‎builtin/provisioners/chef/resource_provisioner_test.go‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"testing"
77

88
"github.com/hashicorp/terraform/communicator"
9-
"github.com/hashicorp/terraform/config"
109
"github.com/hashicorp/terraform/config/hcl2shim"
1110
"github.com/hashicorp/terraform/helper/schema"
1211
"github.com/hashicorp/terraform/terraform"
@@ -432,10 +431,5 @@ func TestResourceProvider_configureVaults(t *testing.T) {
432431
}
433432

434433
func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig {
435-
r, err := config.NewRawConfig(c)
436-
if err != nil {
437-
t.Fatalf("bad: %s", err)
438-
}
439-
440-
return terraform.NewResourceConfig(r)
434+
return terraform.NewResourceConfigRaw(c)
441435
}

‎builtin/provisioners/file/resource_provisioner_test.go‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package file
33
import (
44
"testing"
55

6-
"github.com/hashicorp/terraform/config"
76
"github.com/hashicorp/terraform/config/hcl2shim"
87
"github.com/hashicorp/terraform/helper/schema"
98
"github.com/hashicorp/terraform/terraform"
@@ -109,10 +108,5 @@ func TestResourceProvider_Validate_bad_to_many_src(t *testing.T) {
109108
}
110109

111110
func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig {
112-
r, err := config.NewRawConfig(c)
113-
if err != nil {
114-
t.Fatalf("bad: %s", err)
115-
}
116-
117-
return terraform.NewResourceConfig(r)
111+
return terraform.NewResourceConfigRaw(c)
118112
}

‎builtin/provisioners/habitat/resource_provisioner.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ func validateFn(c *terraform.ResourceConfig) (ws []string, es []error) {
293293
// Validate service level configs
294294
services, ok := c.Get("service")
295295
if ok {
296-
for _, service := range services.([]map[string]interface{}) {
296+
for _, svc := range services.([]interface{}) {
297+
service := svc.(map[string]interface{})
297298
strategy, ok := service["strategy"].(string)
298299
if ok && !updateStrategies[strategy] {
299300
es = append(es, errors.New(strategy+" is not a valid update strategy."))

‎builtin/provisioners/habitat/resource_provisioner_test.go‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package habitat
33
import (
44
"testing"
55

6-
"github.com/hashicorp/terraform/config"
76
"github.com/hashicorp/terraform/helper/schema"
87
"github.com/hashicorp/terraform/terraform"
98
)
@@ -50,8 +49,13 @@ func TestResourceProvisioner_Validate_bad(t *testing.T) {
5049

5150
func TestResourceProvisioner_Validate_bad_service_config(t *testing.T) {
5251
c := testConfig(t, map[string]interface{}{
53-
"service": []map[string]interface{}{
54-
map[string]interface{}{"name": "core/foo", "strategy": "bar", "topology": "baz", "url": "badurl"},
52+
"service": []interface{}{
53+
map[string]interface{}{
54+
"name": "core/foo",
55+
"strategy": "bar",
56+
"topology": "baz",
57+
"url": "badurl",
58+
},
5559
},
5660
})
5761

@@ -65,10 +69,5 @@ func TestResourceProvisioner_Validate_bad_service_config(t *testing.T) {
6569
}
6670

6771
func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig {
68-
r, err := config.NewRawConfig(c)
69-
if err != nil {
70-
t.Fatalf("config error: %s", err)
71-
}
72-
73-
return terraform.NewResourceConfig(r)
72+
return terraform.NewResourceConfigRaw(c)
7473
}

‎builtin/provisioners/local-exec/resource_provisioner_test.go‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/hashicorp/terraform/config"
1110
"github.com/hashicorp/terraform/helper/schema"
1211
"github.com/hashicorp/terraform/terraform"
1312
)
@@ -118,12 +117,7 @@ func TestResourceProvider_Validate_missing(t *testing.T) {
118117
}
119118

120119
func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig {
121-
r, err := config.NewRawConfig(c)
122-
if err != nil {
123-
t.Fatalf("bad: %s", err)
124-
}
125-
126-
return terraform.NewResourceConfig(r)
120+
return terraform.NewResourceConfigRaw(c)
127121
}
128122

129123
func TestResourceProvider_ApplyCustomInterpreter(t *testing.T) {

‎builtin/provisioners/puppet/resource_provisioner_test.go‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package puppet
33
import (
44
"testing"
55

6-
"github.com/hashicorp/terraform/config"
76
"github.com/hashicorp/terraform/helper/schema"
87
"github.com/hashicorp/terraform/terraform"
98
)
@@ -120,10 +119,5 @@ func TestProvisioner_Validate_good_bolt_timeout(t *testing.T) {
120119
}
121120

122121
func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig {
123-
r, err := config.NewRawConfig(c)
124-
if err != nil {
125-
t.Fatalf("bad: %s", err)
126-
}
127-
128-
return terraform.NewResourceConfig(r)
122+
return terraform.NewResourceConfigRaw(c)
129123
}

‎builtin/provisioners/remote-exec/resource_provisioner_test.go‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
"github.com/hashicorp/terraform/communicator"
1313
"github.com/hashicorp/terraform/communicator/remote"
14-
"github.com/hashicorp/terraform/config"
1514
"github.com/hashicorp/terraform/helper/schema"
1615
"github.com/hashicorp/terraform/terraform"
1716
)
@@ -264,10 +263,5 @@ func TestProvisionerTimeout(t *testing.T) {
264263
}
265264

266265
func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig {
267-
r, err := config.NewRawConfig(c)
268-
if err != nil {
269-
t.Fatalf("bad: %s", err)
270-
}
271-
272-
return terraform.NewResourceConfig(r)
266+
return terraform.NewResourceConfigRaw(c)
273267
}

‎builtin/provisioners/salt-masterless/resource_provisioner_test.go‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@ import (
66
"strings"
77
"testing"
88

9-
"github.com/hashicorp/terraform/config"
109
"github.com/hashicorp/terraform/helper/schema"
1110
"github.com/hashicorp/terraform/terraform"
1211
)
1312

1413
func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig {
15-
r, err := config.NewRawConfig(c)
16-
if err != nil {
17-
t.Fatalf("bad: %s", err)
18-
}
19-
20-
return terraform.NewResourceConfig(r)
14+
return terraform.NewResourceConfigRaw(c)
2115
}
2216

2317
func TestResourceProvisioner_impl(t *testing.T) {

‎helper/config/validator_test.go‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/hashicorp/terraform/config"
87
"github.com/hashicorp/terraform/terraform"
98
)
109

@@ -81,7 +80,7 @@ func TestValidator_complex(t *testing.T) {
8180
// Valid
8281
c = testConfig(t, map[string]interface{}{
8382
"foo": "bar",
84-
"nested": []map[string]interface{}{
83+
"nested": []interface{}{
8584
map[string]interface{}{"foo": "bar"},
8685
},
8786
})
@@ -111,7 +110,7 @@ func TestValidator_complexNested(t *testing.T) {
111110

112111
// Valid
113112
c = testConfig(t, map[string]interface{}{
114-
"ingress": []map[string]interface{}{
113+
"ingress": []interface{}{
115114
map[string]interface{}{
116115
"from_port": "80",
117116
},
@@ -121,7 +120,7 @@ func TestValidator_complexNested(t *testing.T) {
121120

122121
// Valid
123122
c = testConfig(t, map[string]interface{}{
124-
"ingress": []map[string]interface{}{
123+
"ingress": []interface{}{
125124
map[string]interface{}{
126125
"from_port": "80",
127126
"cidr_blocks": []interface{}{"foo"},
@@ -144,7 +143,7 @@ func TestValidator_complexDeepRequired(t *testing.T) {
144143
// Valid
145144
c = testConfig(t, map[string]interface{}{
146145
"foo": "bar",
147-
"nested": []map[string]interface{}{
146+
"nested": []interface{}{
148147
map[string]interface{}{"foo": "bar"},
149148
},
150149
})
@@ -164,15 +163,8 @@ func TestValidator_complexDeepRequired(t *testing.T) {
164163
testInvalid(v, c)
165164
}
166165

167-
func testConfig(
168-
t *testing.T,
169-
c map[string]interface{}) *terraform.ResourceConfig {
170-
r, err := config.NewRawConfig(c)
171-
if err != nil {
172-
t.Fatalf("bad: %s", err)
173-
}
174-
175-
return terraform.NewResourceConfig(r)
166+
func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig {
167+
return terraform.NewResourceConfigRaw(c)
176168
}
177169

178170
func testInvalid(v *Validator, c *terraform.ResourceConfig) {

‎helper/diff/diff_test.go‎

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)