Bug fixes for GCP modules (#58904)

This commit is contained in:
The Magician 2019-07-12 13:21:33 -07:00 committed by ansibot
parent 0dd3fb82eb
commit 119b8521a6
6 changed files with 6 additions and 16 deletions

View file

@ -153,7 +153,7 @@ def delete(module, link):
def resource_to_request(module):
request = {u'name': name_partial_to_full(module.params.get('name'), module.params)}
request = {u'name': name_pattern(module.params.get('name'), module)}
return_vals = {}
for k, v in request.items():
if v or v is False:
@ -217,17 +217,17 @@ def is_different(module, response):
# Remove unnecessary properties from the response.
# This is for doing comparisons with Ansible's current parameters.
def response_to_hash(module, response):
return {u'name': name_partial_to_full(module.params.get('name'), module.params), u'url': response.get(u'url'), u'size': response.get(u'size')}
return {u'name': name_pattern(module.params.get('name'), module), u'url': response.get(u'url'), u'size': response.get(u'size')}
def name_partial_to_full(name, params):
def name_pattern(name, module):
if name is None:
return
url = r"projects/.*/repos/.*"
regex = r"projects/.*/repos/.*"
if not re.match(url, name):
name = "projects/{project}/repos/{name}".format(**params)
if not re.match(regex, name):
name = "projects/{project}/repos/{name}".format(**module.params)
return name

View file

@ -97,7 +97,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that database was deleted
gcp_sql_database_facts:
instance: "{{ instance }}"
@ -126,7 +125,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -101,7 +101,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that instance was deleted
gcp_sql_instance_facts:
project: "{{ gcp_project }}"
@ -134,4 +133,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -101,7 +101,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that user was deleted
gcp_sql_user_facts:
instance: "{{ instance }}"
@ -131,7 +130,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

View file

@ -61,7 +61,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
# ----------------------------------------------------------------------------
- name: delete a bucket that does not exist
gcp_storage_bucket:
@ -75,4 +74,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

View file

@ -77,7 +77,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
# ----------------------------------------------------------------------------
- name: delete a bucket access control that does not exist
gcp_storage_bucket_access_control:
@ -93,7 +92,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!