From d37f00df9b10c1c72f4607d4602b7959082eaef5 Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 3 Jan 2020 12:36:10 -0800 Subject: [PATCH] Bug fixes for GCP modules (#65445) --- .../modules/cloud/google/gcp_redis_instance.py | 4 ++-- .../cloud/google/gcp_redis_instance_info.py | 2 +- .../cloud/google/gcp_sourcerepo_repository.py | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/ansible/modules/cloud/google/gcp_redis_instance.py b/lib/ansible/modules/cloud/google/gcp_redis_instance.py index de7ab0bb2b9..422e2fca3e2 100644 --- a/lib/ansible/modules/cloud/google/gcp_redis_instance.py +++ b/lib/ansible/modules/cloud/google/gcp_redis_instance.py @@ -89,7 +89,7 @@ options: type: str name: description: - - The ID of the instance or a fully qualified identifier for the instance. . + - The ID of the instance or a fully qualified identifier for the instance. required: true type: str memory_size_gb: @@ -267,7 +267,7 @@ locationId: type: str name: description: - - The ID of the instance or a fully qualified identifier for the instance. . + - The ID of the instance or a fully qualified identifier for the instance. returned: success type: str memorySizeGb: diff --git a/lib/ansible/modules/cloud/google/gcp_redis_instance_info.py b/lib/ansible/modules/cloud/google/gcp_redis_instance_info.py index a6233c5e8a8..dfdcbfbe850 100644 --- a/lib/ansible/modules/cloud/google/gcp_redis_instance_info.py +++ b/lib/ansible/modules/cloud/google/gcp_redis_instance_info.py @@ -172,7 +172,7 @@ resources: type: str name: description: - - The ID of the instance or a fully qualified identifier for the instance. . + - The ID of the instance or a fully qualified identifier for the instance. returned: success type: str memorySizeGb: diff --git a/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository.py b/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository.py index 273872b4854..536ee2bab61 100644 --- a/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository.py +++ b/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository.py @@ -166,7 +166,7 @@ def main(): if fetch: if state == 'present': if is_different(module, fetch): - update(module, self_link(module)) + update(module, self_link(module), fetch) fetch = fetch_resource(module, self_link(module)) changed = True else: @@ -190,9 +190,17 @@ def create(module, link): return return_if_object(module, auth.post(link, resource_to_request(module))) -def update(module, link): - delete(module, self_link(module)) - create(module, collection(module)) +def update(module, link, fetch): + auth = GcpSession(module, 'sourcerepo') + params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))} + request = resource_to_request(module) + del request['name'] + return return_if_object(module, auth.patch(link, request, params=params)) + + +def updateMask(request, response): + update_mask = [] + return ','.join(update_mask) def delete(module, link):