From df760d5f0a5f2345dead7104ec10d799b34d443f Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 5 Dec 2019 11:13:58 -0800 Subject: [PATCH 01/11] fingerprint_name --- templates/ansible/resource.erb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index ec4e12aafb53..572d22ba3b11 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -266,15 +266,30 @@ def update_fields(module, request, response): <% update_props.each do |key, props| -%> <% func_name = "#{props.first.name.underscore}_update" -%> +<% fingerprint_name = props.map { |x| x.fingerprint_name }.first -%> <% unless object.hidden.include?(func_name) -%> def <%= func_name -%>(module, request, response): auth = GcpSession(module, <%= quote_string(prod_name) -%>) +<% if fingerprint_name -%> + new_resource = <%= method_call('fetch_resource', ['module', 'self_link(module)', + ('kind' if object.kind?), + ]) + -%> + fingerprint = new_resource[:<%= fingerprint_name -%>] +<% end -%> +<% + request_props = if fingerprint_name + request_properties.merge({fingerprint_name => "new_resource[:#{fingerprint_name}]"}) + else + request_properties(props) + end +-%> auth.<%= key[:update_verb].downcase -%>( ''.join([ "<%= object.__product.base_url -%>", "<%= key[:update_url].gsub('{{', '{').gsub('}}', '}') -%>" ]).format(**module.params), -<%= lines(python_literal(request_properties(props), use_hash_brackets: true)) -%> +<%= lines(python_literal(request_props, use_hash_brackets: true)) -%> ) <% end # unless object.hidden.include? -%> From 42d438ec64e64f82622cd76f8736c42baa00b578 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 5 Dec 2019 12:32:00 -0800 Subject: [PATCH 02/11] bug fix --- templates/ansible/resource.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index 572d22ba3b11..d5fac1bb3dc4 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -266,7 +266,7 @@ def update_fields(module, request, response): <% update_props.each do |key, props| -%> <% func_name = "#{props.first.name.underscore}_update" -%> -<% fingerprint_name = props.map { |x| x.fingerprint_name }.first -%> +<% fingerprint_name = props.map { |x| x.fingerprint_name }.compact.first -%> <% unless object.hidden.include?(func_name) -%> def <%= func_name -%>(module, request, response): auth = GcpSession(module, <%= quote_string(prod_name) -%>) From f9ae39aec2336e5ab125b9bcbca86b82b1c379d9 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 5 Dec 2019 12:51:41 -0800 Subject: [PATCH 03/11] bug fix --- templates/ansible/resource.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index d5fac1bb3dc4..9090a538e1d7 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -279,7 +279,7 @@ def <%= func_name -%>(module, request, response): <% end -%> <% request_props = if fingerprint_name - request_properties.merge({fingerprint_name => "new_resource[:#{fingerprint_name}]"}) + request_properties(props).merge({fingerprint_name => "new_resource[:#{fingerprint_name}]"}) else request_properties(props) end From b0a449be98fa854b549d53355215bdbcdf802425 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 5 Dec 2019 16:56:40 -0800 Subject: [PATCH 04/11] bug --- templates/ansible/resource.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index 9090a538e1d7..2f16eb17755e 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -274,7 +274,7 @@ def <%= func_name -%>(module, request, response): new_resource = <%= method_call('fetch_resource', ['module', 'self_link(module)', ('kind' if object.kind?), ]) - -%> + %> fingerprint = new_resource[:<%= fingerprint_name -%>] <% end -%> <% From a49c895fb88fc20767e65d996ffa0da0cb6e5f65 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 5 Dec 2019 17:08:38 -0800 Subject: [PATCH 05/11] removing fingerprint and more --- products/compute/api.yaml | 6 ------ products/compute/terraform.yaml | 2 -- templates/ansible/resource.erb | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/products/compute/api.yaml b/products/compute/api.yaml index a0f1243ccb26..0884d2c2976e 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -10316,12 +10316,6 @@ objects: Only networks that are in the distributed mode can have subnetworks. input: true required: true - # TODO(rileykarson): Work with rambleraptor to remove this field from downstreams. - - !ruby/object:Api::Type::Fingerprint - name: 'fingerprint' - description: | - Fingerprint of this resource. This field is used internally during - updates of this resource. - !ruby/object:Api::Type::Enum name: 'purpose' min_version: beta diff --git a/products/compute/terraform.yaml b/products/compute/terraform.yaml index 2775cb2c663e..ee51b4a48a23 100644 --- a/products/compute/terraform.yaml +++ b/products/compute/terraform.yaml @@ -1726,8 +1726,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides secondaryIpRanges.ipCidrRange: !ruby/object:Overrides::Terraform::PropertyOverride validation: !ruby/object:Provider::Terraform::Validation function: 'validateIpCidrRange' - fingerprint: !ruby/object:Overrides::Terraform::PropertyOverride - exclude: false logConfig: !ruby/object:Overrides::Terraform::PropertyOverride send_empty_value: true custom_expand: 'templates/terraform/custom_expand/subnetwork_log_config.go.erb' diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index 2f16eb17755e..ce490f50c9c0 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -279,7 +279,7 @@ def <%= func_name -%>(module, request, response): <% end -%> <% request_props = if fingerprint_name - request_properties(props).merge({fingerprint_name => "new_resource[:#{fingerprint_name}]"}) + request_properties(props).merge({fingerprint_name => Google::PythonUtils::PythonCode.new("new_resource[:#{fingerprint_name}]")}) else request_properties(props) end From b28262add51cc414fe14020f50b9d0d5fe45351b Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Fri, 6 Dec 2019 12:55:24 -0800 Subject: [PATCH 06/11] the things --- products/compute/ansible.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/products/compute/ansible.yaml b/products/compute/ansible.yaml index 5669f9081db1..f55daacef737 100644 --- a/products/compute/ansible.yaml +++ b/products/compute/ansible.yaml @@ -286,9 +286,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides * global/gateways/default-internet-gateway Subnetwork: !ruby/object:Overrides::Ansible::ResourceOverride properties: - fingerprint: !ruby/object:Overrides::Ansible::PropertyOverride - update_verb: :PATCH - update_url: projects/{{project}}/regions/{{region}}/subnetworks/{{name}} logConfig: !ruby/object:Overrides::Ansible::PropertyOverride exclude: true TargetPool: !ruby/object:Overrides::Ansible::ResourceOverride From 5115ba7a281bff11fa9ce34f7aae92b0a660cfb0 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Fri, 6 Dec 2019 13:59:34 -0800 Subject: [PATCH 07/11] pr comments --- provider/core.rb | 2 +- templates/ansible/resource.erb | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/provider/core.rb b/provider/core.rb index 8cf273f19ebf..26ce08ee92cf 100644 --- a/provider/core.rb +++ b/provider/core.rb @@ -290,7 +290,7 @@ def properties_by_custom_update(properties, behavior = :new) # TODO(rambleraptor): Add support to Ansible for one-at-a-time updates. if behavior == :old update_props.group_by do |p| - { update_url: p.update_url, update_verb: p.update_verb } + { update_url: p.update_url, update_verb: p.update_verb, fingerprint: p.fingerprint_name } end else update_props.group_by do |p| diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index ce490f50c9c0..be323a724bf6 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -266,11 +266,10 @@ def update_fields(module, request, response): <% update_props.each do |key, props| -%> <% func_name = "#{props.first.name.underscore}_update" -%> -<% fingerprint_name = props.map { |x| x.fingerprint_name }.compact.first -%> <% unless object.hidden.include?(func_name) -%> def <%= func_name -%>(module, request, response): auth = GcpSession(module, <%= quote_string(prod_name) -%>) -<% if fingerprint_name -%> +<% if key[:fingerprint_name] -%> new_resource = <%= method_call('fetch_resource', ['module', 'self_link(module)', ('kind' if object.kind?), ]) @@ -279,7 +278,7 @@ def <%= func_name -%>(module, request, response): <% end -%> <% request_props = if fingerprint_name - request_properties(props).merge({fingerprint_name => Google::PythonUtils::PythonCode.new("new_resource[:#{fingerprint_name}]")}) + request_properties(props).merge({fingerprint_name => Google::PythonUtils::PythonCode.new("new_resource[:#{key[:fingerprint_name]}]")}) else request_properties(props) end From db1a5f286a1969bcc5b1a915fe7c4cada4c93fb5 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Fri, 6 Dec 2019 14:28:14 -0800 Subject: [PATCH 08/11] fix --- templates/ansible/resource.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index be323a724bf6..51ecd909b5e4 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -274,10 +274,10 @@ def <%= func_name -%>(module, request, response): ('kind' if object.kind?), ]) %> - fingerprint = new_resource[:<%= fingerprint_name -%>] + fingerprint = new_resource[:<%= key[:fingerprint_name] -%>] <% end -%> <% - request_props = if fingerprint_name + request_props = if key[:fingerprint_name] request_properties(props).merge({fingerprint_name => Google::PythonUtils::PythonCode.new("new_resource[:#{key[:fingerprint_name]}]")}) else request_properties(props) From 3f44768c76b5306a4ed706f6763cc6fa95a240da Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Fri, 6 Dec 2019 14:47:53 -0800 Subject: [PATCH 09/11] riley's fix --- templates/terraform/extra_schema_entry/subnetwork.erb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/templates/terraform/extra_schema_entry/subnetwork.erb b/templates/terraform/extra_schema_entry/subnetwork.erb index 87ad70ed4de9..33a621f39b97 100644 --- a/templates/terraform/extra_schema_entry/subnetwork.erb +++ b/templates/terraform/extra_schema_entry/subnetwork.erb @@ -17,4 +17,10 @@ Computed: true, Optional: true, Removed: "This field is being removed in favor of log_config. If log_config is present, flow logs are enabled. Please remove this field", -}, \ No newline at end of file +}, +"fingerprint": { + Type: schema.TypeString, + Computed: true, + Description: `Fingerprint of this resource. This field is used internally during updates of this resource.`, + Deprecated: `This field is not useful for users, and has been removed as an output.` +}, From fae88328fddae3501a609488bc99aad6c78be5b7 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Fri, 6 Dec 2019 14:58:10 -0800 Subject: [PATCH 10/11] more fixes --- templates/terraform/extra_schema_entry/subnetwork.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/terraform/extra_schema_entry/subnetwork.erb b/templates/terraform/extra_schema_entry/subnetwork.erb index 33a621f39b97..f9a451f81aba 100644 --- a/templates/terraform/extra_schema_entry/subnetwork.erb +++ b/templates/terraform/extra_schema_entry/subnetwork.erb @@ -19,8 +19,8 @@ Removed: "This field is being removed in favor of log_config. If log_config is present, flow logs are enabled. Please remove this field", }, "fingerprint": { - Type: schema.TypeString, - Computed: true, - Description: `Fingerprint of this resource. This field is used internally during updates of this resource.`, - Deprecated: `This field is not useful for users, and has been removed as an output.` + Type: schema.TypeString, + Computed: true, + Description: "Fingerprint of this resource. This field is used internally during updates of this resource.", + Deprecated: "This field is not useful for users, and has been removed as an output.", }, From 9ed241e1eb7c93bd3419f1479fe2e523510e0652 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Fri, 6 Dec 2019 23:40:23 +0000 Subject: [PATCH 11/11] Update tracked submodules -> HEAD on Fri Dec 6 23:40:23 UTC 2019 Tracked submodules are build/terraform-beta build/terraform-mapper build/terraform build/ansible build/inspec. --- build/ansible | 2 +- build/inspec | 2 +- build/terraform | 2 +- build/terraform-beta | 2 +- build/terraform-mapper | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/ansible b/build/ansible index e3afbd58f321..561dddd734b7 160000 --- a/build/ansible +++ b/build/ansible @@ -1 +1 @@ -Subproject commit e3afbd58f3211743fbfa0ee1e7d205505114847f +Subproject commit 561dddd734b758a02b6d018c1e4a42150d7f04c5 diff --git a/build/inspec b/build/inspec index 8e8b7c0231b4..afd143c24ebc 160000 --- a/build/inspec +++ b/build/inspec @@ -1 +1 @@ -Subproject commit 8e8b7c0231b4dcc737825afe8e0e5d5e47b10dec +Subproject commit afd143c24ebc714729a9ede884cdf0ae8e2be45e diff --git a/build/terraform b/build/terraform index 789f50dea63f..a660276d910f 160000 --- a/build/terraform +++ b/build/terraform @@ -1 +1 @@ -Subproject commit 789f50dea63f395ee4f1161f7c16fb08cf159c56 +Subproject commit a660276d910fa152238abb3557ad816e708bbef6 diff --git a/build/terraform-beta b/build/terraform-beta index 72bdd64371dc..b7a96bf4d051 160000 --- a/build/terraform-beta +++ b/build/terraform-beta @@ -1 +1 @@ -Subproject commit 72bdd64371dc4dd623377e0f2a2205819c15d04a +Subproject commit b7a96bf4d051672a38eaaceea086f01f0f37bd76 diff --git a/build/terraform-mapper b/build/terraform-mapper index d3b0dd6f4daa..daa9a44fb16f 160000 --- a/build/terraform-mapper +++ b/build/terraform-mapper @@ -1 +1 @@ -Subproject commit d3b0dd6f4daa141b2365fdf5ba815e9290e8bde3 +Subproject commit daa9a44fb16f74f116d633a57e92f24cce7c37a5