Skip to content

Commit

Permalink
Remove IAM import method (#2138)
Browse files Browse the repository at this point in the history
Merged PR #2138.
  • Loading branch information
emilymye authored and modular-magician committed Aug 8, 2019
1 parent 7df4ac4 commit 58eed00
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 104 deletions.
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
6 changes: 3 additions & 3 deletions templates/terraform/provider_gen.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ end
<% iam_policy = object&.iam_policy -%>
<% unless iam_policy.nil? || iam_policy.exclude -%>
<% iam_class_name = product_ns + object.name -%>
"<%= terraform_name -%>_iam_binding": ResourceIamBindingWithImport(<%= iam_class_name -%>IamSchema, <%= iam_class_name -%>IamUpdaterProducer, <%= iam_class_name -%>IdParseFunc),
"<%= terraform_name -%>_iam_member": ResourceIamMemberWithImport(<%= iam_class_name -%>IamSchema, <%= iam_class_name -%>IamUpdaterProducer, <%= iam_class_name -%>IdParseFunc),
"<%= terraform_name -%>_iam_policy": ResourceIamPolicyWithImport(<%= iam_class_name -%>IamSchema, <%= iam_class_name -%>IamUpdaterProducer, <%= iam_class_name -%>IdParseFunc),
"<%= terraform_name -%>_iam_binding": ResourceIamBinding(<%= iam_class_name -%>IamSchema, <%= iam_class_name -%>IamUpdaterProducer, <%= iam_class_name -%>IdParseFunc),
"<%= terraform_name -%>_iam_member": ResourceIamMember(<%= iam_class_name -%>IamSchema, <%= iam_class_name -%>IamUpdaterProducer, <%= iam_class_name -%>IdParseFunc),
"<%= terraform_name -%>_iam_policy": ResourceIamPolicy(<%= iam_class_name -%>IamSchema, <%= iam_class_name -%>IamUpdaterProducer, <%= iam_class_name -%>IdParseFunc),
<% end # unless object.iam_policy -%>
<% end -%>
}
13 changes: 4 additions & 9 deletions third_party/terraform/resources/resource_iam_audit_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,19 @@ var iamAuditConfigSchema = map[string]*schema.Schema{
},
}

func ResourceIamAuditConfig(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc) *schema.Resource {
func ResourceIamAuditConfig(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc, resourceIdParser resourceIdParserFunc) *schema.Resource {
return &schema.Resource{
Create: resourceIamAuditConfigCreate(newUpdaterFunc),
Read: resourceIamAuditConfigRead(newUpdaterFunc),
Update: resourceIamAuditConfigUpdate(newUpdaterFunc),
Delete: resourceIamAuditConfigDelete(newUpdaterFunc),
Schema: mergeSchemas(iamAuditConfigSchema, parentSpecificSchema),
Importer: &schema.ResourceImporter{
State: iamAuditConfigImport(resourceIdParser),
},
}
}

func ResourceIamAuditConfigWithImport(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc, resourceIdParser resourceIdParserFunc) *schema.Resource {
r := ResourceIamAuditConfig(parentSpecificSchema, newUpdaterFunc)
r.Importer = &schema.ResourceImporter{
State: iamAuditConfigImport(resourceIdParser),
}
return r
}

func resourceIamAuditConfigCreate(newUpdaterFunc newResourceIamUpdaterFunc) schema.CreateFunc {
return func(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
Expand Down
13 changes: 4 additions & 9 deletions third_party/terraform/resources/resource_iam_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,19 @@ var iamBindingSchema = map[string]*schema.Schema{
},
}

func ResourceIamBinding(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc) *schema.Resource {
func ResourceIamBinding(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc, resourceIdParser resourceIdParserFunc) *schema.Resource {
return &schema.Resource{
Create: resourceIamBindingCreateUpdate(newUpdaterFunc),
Read: resourceIamBindingRead(newUpdaterFunc),
Update: resourceIamBindingCreateUpdate(newUpdaterFunc),
Delete: resourceIamBindingDelete(newUpdaterFunc),
Schema: mergeSchemas(iamBindingSchema, parentSpecificSchema),
Importer: &schema.ResourceImporter{
State: iamBindingImport(resourceIdParser),
},
}
}

func ResourceIamBindingWithImport(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc, resourceIdParser resourceIdParserFunc) *schema.Resource {
r := ResourceIamBinding(parentSpecificSchema, newUpdaterFunc)
r.Importer = &schema.ResourceImporter{
State: iamBindingImport(resourceIdParser),
}
return r
}

func resourceIamBindingCreateUpdate(newUpdaterFunc newResourceIamUpdaterFunc) func(*schema.ResourceData, interface{}) error {
return func(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
Expand Down
14 changes: 4 additions & 10 deletions third_party/terraform/resources/resource_iam_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,18 @@ func iamMemberImport(resourceIdParser resourceIdParserFunc) schema.StateFunc {
}
}

func ResourceIamMember(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc) *schema.Resource {
func ResourceIamMember(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc, resourceIdParser resourceIdParserFunc) *schema.Resource {
return &schema.Resource{
Create: resourceIamMemberCreate(newUpdaterFunc),
Read: resourceIamMemberRead(newUpdaterFunc),
Delete: resourceIamMemberDelete(newUpdaterFunc),

Schema: mergeSchemas(IamMemberBaseSchema, parentSpecificSchema),
Importer: &schema.ResourceImporter{
State: iamMemberImport(resourceIdParser),
},
}
}

func ResourceIamMemberWithImport(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc, resourceIdParser resourceIdParserFunc) *schema.Resource {
r := ResourceIamMember(parentSpecificSchema, newUpdaterFunc)
r.Importer = &schema.ResourceImporter{
State: iamMemberImport(resourceIdParser),
}
return r
}

func getResourceIamMember(d *schema.ResourceData) *cloudresourcemanager.Binding {
return &cloudresourcemanager.Binding{
Members: []string{d.Get("member").(string)},
Expand Down
13 changes: 4 additions & 9 deletions third_party/terraform/resources/resource_iam_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,20 @@ func iamPolicyImport(resourceIdParser resourceIdParserFunc) schema.StateFunc {
}
}

func ResourceIamPolicy(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc) *schema.Resource {
func ResourceIamPolicy(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc, resourceIdParser resourceIdParserFunc) *schema.Resource {
return &schema.Resource{
Create: ResourceIamPolicyCreate(newUpdaterFunc),
Read: ResourceIamPolicyRead(newUpdaterFunc),
Update: ResourceIamPolicyUpdate(newUpdaterFunc),
Delete: ResourceIamPolicyDelete(newUpdaterFunc),

Schema: mergeSchemas(IamPolicyBaseSchema, parentSpecificSchema),
Importer: &schema.ResourceImporter{
State: iamPolicyImport(resourceIdParser),
},
}
}

func ResourceIamPolicyWithImport(parentSpecificSchema map[string]*schema.Schema, newUpdaterFunc newResourceIamUpdaterFunc, resourceIdParser resourceIdParserFunc) *schema.Resource {
r := ResourceIamPolicy(parentSpecificSchema, newUpdaterFunc)
r.Importer = &schema.ResourceImporter{
State: iamPolicyImport(resourceIdParser),
}
return r
}

func ResourceIamPolicyCreate(newUpdaterFunc newResourceIamUpdaterFunc) schema.CreateFunc {
return func(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
Expand Down
Loading

0 comments on commit 58eed00

Please sign in to comment.