From 030cc79530e8f8181c74a7d4ebd24269c788e633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Austerm=C3=BChle?= Date: Fri, 11 Apr 2025 15:35:41 +0200 Subject: [PATCH 1/3] Support the autopublish flag for Python repos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stephan Austermühle --- plugins/modules/python_repository.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/modules/python_repository.py b/plugins/modules/python_repository.py index d78e532..a86faa8 100644 --- a/plugins/modules/python_repository.py +++ b/plugins/modules/python_repository.py @@ -19,6 +19,12 @@ description: - Description of the repository type: str + autopublish: + description: + - Publish new versions automatically. + required: false + type: bool + default: false extends_documentation_fragment: - pulp.squeezer.pulp.entity_state - pulp.squeezer.pulp @@ -89,13 +95,16 @@ def main(): argument_spec={ "name": {}, "description": {}, + "autopublish": {"type": "bool", "default": False}, }, required_if=[("state", "present", ["name"]), ("state", "absent", ["name"])], ) as module: natural_key = {"name": module.params["name"]} - desired_attributes = {} - if module.params["description"] is not None: - desired_attributes["description"] = module.params["description"] + desired_attributes = { + k: module.params[k] + for k in ("description", "autopublish") + if module.params.get(k) is not None + } module.process(natural_key, desired_attributes) From e923e820b2ab2bc0f5d8836a51f4581f3004d3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Austerm=C3=BChle?= Date: Fri, 11 Apr 2025 19:07:38 +0200 Subject: [PATCH 2/3] Remove default for autopublish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A default for autopublish could cause unwanted repository changes. Signed-off-by: Stephan Austermühle --- plugins/modules/python_repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/python_repository.py b/plugins/modules/python_repository.py index a86faa8..6450710 100644 --- a/plugins/modules/python_repository.py +++ b/plugins/modules/python_repository.py @@ -95,7 +95,7 @@ def main(): argument_spec={ "name": {}, "description": {}, - "autopublish": {"type": "bool", "default": False}, + "autopublish": {"type": "bool"}, }, required_if=[("state", "present", ["name"]), ("state", "absent", ["name"])], ) as module: From 8a2d8db9b08f6276eba0a58925aa92d5f1a0c7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Austerm=C3=BChle?= Date: Mon, 14 Apr 2025 13:07:43 +0200 Subject: [PATCH 3/3] Add tests for the autopublish flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stephan Austermühle --- tests/playbooks/python_repository.yaml | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/playbooks/python_repository.yaml b/tests/playbooks/python_repository.yaml index ea42f30..49855cc 100644 --- a/tests/playbooks/python_repository.yaml +++ b/tests/playbooks/python_repository.yaml @@ -31,12 +31,15 @@ name: test_python_repository description: "" state: present + autopublish: false register: result - name: Verify create repository assert: that: - result.changed == true - result.repository.name == 'test_python_repository' + - result.repository.description == '' + - result.repository.autopublish == false - name: Create repository (2nd try) pulp.squeezer.python_repository: @@ -71,6 +74,41 @@ that: - result.changed == false + - name: Enable autopublish + pulp.squeezer.python_repository: + name: test_python_repository + state: present + autopublish: true + register: result + - name: Verify enabled autopublish flag + assert: + that: + - result.changed == true + - result.repository.autopublish == true + + - name: Enable autopublish (2nd try) + pulp.squeezer.python_repository: + name: test_python_repository + state: present + autopublish: true + register: result + - name: Verify enabled autopublish flag + assert: + that: + - result.changed == false + + - name: Disable autopublish + pulp.squeezer.python_repository: + name: test_python_repository + state: present + autopublish: false + register: result + - name: Verify cleared autopublish flag + assert: + that: + - result.changed == true + - result.repository.autopublish == false + - name: Fake modify repository pulp.squeezer.python_repository: name: test_python_repository