mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-05 18:30:27 -07:00
Ansible Cloud Source Repositories (#165)
Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
parent
2ebb8245b5
commit
e6ae9ac421
4 changed files with 42 additions and 43 deletions
|
@ -62,11 +62,11 @@ notes:
|
|||
EXAMPLES = '''
|
||||
- name: create a repository
|
||||
gcp_sourcerepo_repository:
|
||||
name: projects/test_project/repos/test_object
|
||||
project: test_project
|
||||
auth_kind: serviceaccount
|
||||
service_account_file: "/tmp/auth.pem"
|
||||
state: present
|
||||
name: projects/test_project/repos/test_object
|
||||
project: "test_project"
|
||||
auth_kind: "serviceaccount"
|
||||
service_account_file: "/tmp/auth.pem"
|
||||
state: present
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
|
@ -142,8 +142,7 @@ def create(module, link):
|
|||
|
||||
|
||||
def update(module, link):
|
||||
delete(module, self_link(module))
|
||||
create(module, collection(module))
|
||||
module.fail_json(msg="Repository cannot be edited")
|
||||
|
||||
|
||||
def delete(module, link):
|
||||
|
@ -186,8 +185,8 @@ def return_if_object(module, response, allow_not_found=False):
|
|||
try:
|
||||
module.raise_for_status(response)
|
||||
result = response.json()
|
||||
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
||||
|
||||
if navigate_hash(result, ['error', 'errors']):
|
||||
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
|
||||
|
|
|
@ -44,17 +44,16 @@ extends_documentation_fragment: gcp
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
- name: " a repository facts"
|
||||
- name: a repository facts
|
||||
gcp_sourcerepo_repository_facts:
|
||||
project: test_project
|
||||
auth_kind: serviceaccount
|
||||
service_account_file: "/tmp/auth.pem"
|
||||
state: facts
|
||||
project: test_project
|
||||
auth_kind: serviceaccount
|
||||
service_account_file: "/tmp/auth.pem"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
resources:
|
||||
description: List of resources
|
||||
items:
|
||||
description: List of items
|
||||
returned: always
|
||||
type: complex
|
||||
contains:
|
||||
|
@ -99,7 +98,7 @@ def main():
|
|||
items = items.get('repos')
|
||||
else:
|
||||
items = []
|
||||
return_value = {'resources': items}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
---
|
||||
resource_name: "{{ resource_prefix }}"
|
||||
# defaults file
|
||||
resource_name: '{{resource_prefix}}'
|
||||
|
|
|
@ -15,19 +15,19 @@
|
|||
# Pre-test setup
|
||||
- name: delete a repository
|
||||
gcp_sourcerepo_repository:
|
||||
name: projects/{{ gcp_project }}/repos/{{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
name: projects/{{ gcp_project }}/repos/{{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
#----------------------------------------------------------
|
||||
- name: create a repository
|
||||
gcp_sourcerepo_repository:
|
||||
name: projects/{{ gcp_project }}/repos/{{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
name: projects/{{ gcp_project }}/repos/{{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
register: result
|
||||
- name: assert changed is true
|
||||
assert:
|
||||
|
@ -48,11 +48,11 @@
|
|||
# ----------------------------------------------------------------------------
|
||||
- name: create a repository that already exists
|
||||
gcp_sourcerepo_repository:
|
||||
name: projects/{{ gcp_project }}/repos/{{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
name: projects/{{ gcp_project }}/repos/{{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
register: result
|
||||
- name: assert changed is false
|
||||
assert:
|
||||
|
@ -61,11 +61,11 @@
|
|||
#----------------------------------------------------------
|
||||
- name: delete a repository
|
||||
gcp_sourcerepo_repository:
|
||||
name: projects/{{ gcp_project }}/repos/{{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
name: projects/{{ gcp_project }}/repos/{{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: assert changed is true
|
||||
assert:
|
||||
|
@ -86,11 +86,11 @@
|
|||
# ----------------------------------------------------------------------------
|
||||
- name: delete a repository that does not exist
|
||||
gcp_sourcerepo_repository:
|
||||
name: projects/{{ gcp_project }}/repos/{{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
name: projects/{{ gcp_project }}/repos/{{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: assert changed is false
|
||||
assert:
|
||||
|
|
Loading…
Add table
Reference in a new issue