Skip to content

Commit

Permalink
get rid of extra_schema entry
Browse files Browse the repository at this point in the history
  • Loading branch information
drebes committed Mar 10, 2020
1 parent aab1f14 commit 770f40d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 28 deletions.
5 changes: 3 additions & 2 deletions products/iap/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@ objects:
- !ruby/object:Api::Resource
name: 'Client'
base_url: '{{brand}}/identityAwareProxyClients'
self_link: '{{name}}'
self_link: '{{client_id}}'
input: true
description: |
Contains the data that describes an Identity Aware Proxy owned client.
parameters:
- !ruby/object:Api::Type::String
name: 'name'
name: 'clientId'
api_name: name
description: |
Output only. Unique identifier of the OAuth client.
output: true
Expand Down
5 changes: 2 additions & 3 deletions products/iap/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,13 @@ overrides: !ruby/object:Overrides::ResourceOverrides
attributes: |
* `client_id`: The OAuth2 ID of the client.
properties:
name: !ruby/object:Overrides::Terraform::PropertyOverride
exclude: true
clientId: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb
secret: !ruby/object:Overrides::Terraform::PropertyOverride
sensitive: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
post_create: templates/terraform/post_create/iap_client.go.erb
custom_import: templates/terraform/custom_import/iap_client.go.erb
extra_schema_entry: templates/terraform/extra_schema_entry/iap_client.erb
# This is for copying files over
files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
Expand Down
4 changes: 2 additions & 2 deletions templates/terraform/custom_import/iap_client.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ nameParts := strings.Split(d.Get("brand").(string), "/")
if len(nameParts) != 6 {
return nil, fmt.Errorf(
"Saw %s when the name is expected to have shape %s",
d.Get("name"),
"{{brand}}/identityAwareProxyClients/{{client_id}}",
d.Get("brand").(string),
"projects/{{project_number}}/brands/{{brand_id}}/identityAwareProxyClients/{{client_id}}",
)
}

Expand Down
4 changes: 0 additions & 4 deletions templates/terraform/extra_schema_entry/iap_client.erb

This file was deleted.

21 changes: 4 additions & 17 deletions templates/terraform/post_create/iap_client.go.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
// `name` is autogenerated from the api so needs to be set post-create
name, ok := res["name"]
if !ok {
return fmt.Errorf("Create response didn't contain critical fields. Create may not have succeeded.")
}
brand := d.Get("brand")
clientId := flattenIapClientClientId(res["name"], d, config)

nameParts := strings.Split(name.(string), "/")
if len(nameParts) != 6 {
return fmt.Errorf(
"Saw %s when the name is expected to have shape %s",
d.Get("name"),
"{{brand}}/identityAwareProxyClients/{{client_id}}",
)
}

log.Printf("[DEBUG] Setting client_id to %s", nameParts[5])
d.Set("client_id", nameParts[5])
d.SetId(name.(string))
d.Set("client_id", clientId)
d.SetId(fmt.Sprintf("%s/identityAwareProxyClients/%s", brand, clientId))

0 comments on commit 770f40d

Please sign in to comment.