Skip to content

Commit

Permalink
Add empty_requirements to collection_remote
Browse files Browse the repository at this point in the history
* Fixes ansible#413

Signed-off-by: Hideki Saito <[email protected]>
  • Loading branch information
saito-hideki committed Jul 19, 2024
1 parent 96775c1 commit c6bb3f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/add_empty_requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- add new parameter empty_requirements to collection_remote. This parameter clears the contents by setting null in requirements.yml (#413).
14 changes: 13 additions & 1 deletion plugins/modules/collection_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
description:
- A yaml requirements file to download from remote.
type: str
empty_requirements:
description:
- Empty the contents of requirements.yml for collection remote.
- If a new collection remote is created, the content of requirements.yml will be empty.
- If a collection remote already exists, empty the contents of requirements.yml.
type: bool
default: False
username:
description:
- Username to authenticate to the remote repository.
Expand Down Expand Up @@ -189,6 +196,7 @@ def main():
policy=dict(choices=['immediate', 'When syncing, download all metadata and content now.'], default='immediate'),
requirements=dict(type="list", elements="str"),
requirements_file=dict(),
empty_requirements=dict(type="bool", default=False),
username=dict(),
password=dict(no_log=True),
tls_validation=dict(type="bool", default=True),
Expand All @@ -214,7 +222,7 @@ def main():
argument_spec=argument_spec,
supports_check_mode=True,
mutually_exclusive=[
("requirements", "requirements_file"),
("requirements", "requirements_file", "empty_requirements"),
("client_key", "client_key_path"),
("client_cert", "client_cert_path"),
("ca_cert", "ca_cert_path"),
Expand All @@ -238,6 +246,10 @@ def main():
if requirements_file:
new_fields["requirements_file"] = module.getFileContent(requirements_file)

empty_requirements = module.params.get("empty_requirements")
if empty_requirements:
new_fields["requirements_file"] = None

for field_name in (
"name",
"url",
Expand Down

0 comments on commit c6bb3f9

Please sign in to comment.