Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add empty_requirements to collection_remote #419

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading