Skip to content

Commit 0725486

Browse files
author
Sander van Harmelen
committed
Refactored the last two resources
1 parent eccd5ad commit 0725486

8 files changed

Lines changed: 251 additions & 159 deletions

builtin/bins/provider-aws/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ package main
33
import (
44
"github.com/hashicorp/terraform/builtin/providers/aws"
55
"github.com/hashicorp/terraform/plugin"
6-
"github.com/hashicorp/terraform/terraform"
76
)
87

98
func main() {
109
plugin.Serve(&plugin.ServeOpts{
11-
ProviderFunc: func() terraform.ResourceProvider {
12-
return new(aws.ResourceProvider)
13-
},
10+
ProviderFunc: aws.Provider,
1411
})
1512
}

builtin/providers/aws/provider.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ import (
44
"os"
55

66
"github.com/hashicorp/terraform/helper/schema"
7+
"github.com/hashicorp/terraform/terraform"
78
)
89

9-
// Provider returns a schema.Provider for AWS.
10-
//
11-
// NOTE: schema.Provider became available long after the AWS provider
12-
// was started, so resources may not be converted to this new structure
13-
// yet. This is a WIP. To assist with the migration, make sure any resources
14-
// you migrate are acceptance tested, then perform the migration.
15-
func Provider() *schema.Provider {
10+
// Provider returns a terraform.ResourceProvider.
11+
func Provider() terraform.ResourceProvider {
1612
// TODO: Move the validation to this, requires conditional schemas
1713
// TODO: Move the configuration to this, requires validation
1814

@@ -42,10 +38,10 @@ func Provider() *schema.Provider {
4238
},
4339

4440
ResourcesMap: map[string]*schema.Resource{
45-
"aws_autoscaling_group": resourceAwsAutoscalingGroup(),
46-
//"aws_db_instance": resourceAwsDbInstance(),
47-
"aws_db_parameter_group": resourceAwsDbParameterGroup(),
48-
//"aws_db_security_group": resourceAwsDbSecurityGroup(),
41+
"aws_autoscaling_group": resourceAwsAutoscalingGroup(),
42+
"aws_db_instance": resourceAwsDbInstance(),
43+
"aws_db_parameter_group": resourceAwsDbParameterGroup(),
44+
"aws_db_security_group": resourceAwsDbSecurityGroup(),
4945
"aws_db_subnet_group": resourceAwsDbSubnetGroup(),
5046
"aws_eip": resourceAwsEip(),
5147
"aws_elb": resourceAwsElb(),

builtin/providers/aws/provider_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ var testAccProviders map[string]terraform.ResourceProvider
1313
var testAccProvider *schema.Provider
1414

1515
func init() {
16-
testAccProvider = Provider()
16+
testAccProvider = Provider().(*schema.Provider)
1717
testAccProviders = map[string]terraform.ResourceProvider{
1818
"aws": testAccProvider,
1919
}
2020
}
2121

2222
func TestProvider(t *testing.T) {
23-
if err := Provider().InternalValidate(); err != nil {
23+
if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
2424
t.Fatalf("err: %s", err)
2525
}
2626
}

0 commit comments

Comments
 (0)