diff --git a/build/ansible b/build/ansible index 90f433017971..989e29377f30 160000 --- a/build/ansible +++ b/build/ansible @@ -1 +1 @@ -Subproject commit 90f4330179715380fa3ac002c623258f1319555a +Subproject commit 989e29377f30d149f4ad5eacd4f1bf3cd00e8b2f diff --git a/build/terraform b/build/terraform index 14bac81a71c3..95211daafeb6 160000 --- a/build/terraform +++ b/build/terraform @@ -1 +1 @@ -Subproject commit 14bac81a71c3f9c32df020ca0a279a4fa828a173 +Subproject commit 95211daafeb660fad5e526dd6eb614e4ee3fbc81 diff --git a/templates/ansible/resource.erb b/templates/ansible/resource.erb index 904e296838be..2b02fa855753 100644 --- a/templates/ansible/resource.erb +++ b/templates/ansible/resource.erb @@ -406,13 +406,14 @@ def unwrap_resource(result, module): <% end -%> <%= lines(method_decl('return_if_object', ['module', 'response', - ('kind' if object.kind?)])) + ('kind' if object.kind?), + 'allow_not_found=False'])) -%> <% if object.return_if_object -%> <%= lines(indent(object.return_if_object, 4)) -%> <% else # if object.return_if_object -%> # If not found, return nothing. - if response.status_code == 404: + if allow_not_found and response.status_code == 404: return None # If no content, return nothing. diff --git a/templates/ansible/transport.erb b/templates/ansible/transport.erb index f3c88da1df75..832f5b1a74a7 100644 --- a/templates/ansible/transport.erb +++ b/templates/ansible/transport.erb @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -%> -<% if object.kind? -%> -def fetch_resource(module, link, kind): +<%= + method_decl('fetch_resource', ['module', 'link', ('kind' if object.kind?), + 'allow_not_found=True']) +%> auth = GcpSession(module, <%= quote_string(prod_name) -%>) - return return_if_object(module, auth.get(link), kind) -<% else # object.kind? -%> -def fetch_resource(module, link): - auth = GcpSession(module, <%= quote_string(prod_name) -%>) - return return_if_object(module, auth.get(link)) - -<% end # object.kind? -%> + return <%= method_call('return_if_object', ['module', 'auth.get(link)', + ('kind' if object.kind?), + 'allow_not_found']) %> <% unless object.self_link_query.nil? -%>