Skip to content

Commit

Permalink
add IAM conditions support for generated IAM resources
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
danawillow authored and modular-magician committed Nov 9, 2019
1 parent 1709c10 commit f963370
Show file tree
Hide file tree
Showing 16 changed files with 929 additions and 62 deletions.
7 changes: 3 additions & 4 deletions google-beta/iam_binary_authorization_attestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ func BinaryAuthorizationAttestorIamUpdaterProducer(d *schema.ResourceData, confi
d.Set("project", u.project)
d.Set("attestor", u.GetResourceId())

d.SetId(u.GetResourceId())

return u, nil
}

Expand Down Expand Up @@ -105,7 +103,7 @@ func BinaryAuthorizationAttestorIdParseFunc(d *schema.ResourceData, config *Conf
Config: config,
}
d.Set("attestor", u.GetResourceId())
d.SetId(u.GetResourceId())

return nil
}

Expand All @@ -116,8 +114,9 @@ func (u *BinaryAuthorizationAttestorIamUpdater) GetResourceIamPolicy() (*cloudre
if err != nil {
return nil, err
}
var obj map[string]interface{}

policy, err := sendRequest(u.Config, "GET", project, url, nil)
policy, err := sendRequest(u.Config, "GET", project, url, obj)
if err != nil {
return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err)
}
Expand Down
7 changes: 3 additions & 4 deletions google-beta/iam_cloud_functions_cloud_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ func CloudFunctionsCloudFunctionIamUpdaterProducer(d *schema.ResourceData, confi
d.Set("region", u.region)
d.Set("cloud_function", u.GetResourceId())

d.SetId(u.GetResourceId())

return u, nil
}

Expand Down Expand Up @@ -125,7 +123,7 @@ func CloudFunctionsCloudFunctionIdParseFunc(d *schema.ResourceData, config *Conf
Config: config,
}
d.Set("cloud_function", u.GetResourceId())
d.SetId(u.GetResourceId())

return nil
}

Expand All @@ -136,8 +134,9 @@ func (u *CloudFunctionsCloudFunctionIamUpdater) GetResourceIamPolicy() (*cloudre
if err != nil {
return nil, err
}
var obj map[string]interface{}

policy, err := sendRequest(u.Config, "GET", project, url, nil)
policy, err := sendRequest(u.Config, "GET", project, url, obj)
if err != nil {
return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err)
}
Expand Down
7 changes: 3 additions & 4 deletions google-beta/iam_iap_app_engine_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ func IapAppEngineServiceIamUpdaterProducer(d *schema.ResourceData, config *Confi
d.Set("app_id", u.appId)
d.Set("service", u.GetResourceId())

d.SetId(u.GetResourceId())

return u, nil
}

Expand Down Expand Up @@ -118,7 +116,7 @@ func IapAppEngineServiceIdParseFunc(d *schema.ResourceData, config *Config) erro
Config: config,
}
d.Set("service", u.GetResourceId())
d.SetId(u.GetResourceId())

return nil
}

Expand All @@ -129,8 +127,9 @@ func (u *IapAppEngineServiceIamUpdater) GetResourceIamPolicy() (*cloudresourcema
if err != nil {
return nil, err
}
var obj map[string]interface{}

policy, err := sendRequest(u.Config, "POST", project, url, nil)
policy, err := sendRequest(u.Config, "POST", project, url, obj)
if err != nil {
return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err)
}
Expand Down
12 changes: 8 additions & 4 deletions google-beta/iam_iap_app_engine_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ func IapAppEngineVersionIamUpdaterProducer(d *schema.ResourceData, config *Confi
d.Set("service", u.service)
d.Set("version_id", u.GetResourceId())

d.SetId(u.GetResourceId())

return u, nil
}

Expand Down Expand Up @@ -131,7 +129,7 @@ func IapAppEngineVersionIdParseFunc(d *schema.ResourceData, config *Config) erro
Config: config,
}
d.Set("version_id", u.GetResourceId())
d.SetId(u.GetResourceId())

return nil
}

Expand All @@ -142,8 +140,14 @@ func (u *IapAppEngineVersionIamUpdater) GetResourceIamPolicy() (*cloudresourcema
if err != nil {
return nil, err
}
var obj map[string]interface{}
obj = map[string]interface{}{
"options": map[string]interface{}{
"requestedPolicyVersion": iamPolicyVersion,
},
}

policy, err := sendRequest(u.Config, "POST", project, url, nil)
policy, err := sendRequest(u.Config, "POST", project, url, obj)
if err != nil {
return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err)
}
Expand Down
Loading

0 comments on commit f963370

Please sign in to comment.