Skip to content
Merged
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
15 changes: 15 additions & 0 deletions plugins/modules/file_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
description:
- Whether to automatically create publications for new repository versions
type: bool
pulp_labels:
description:
- A dictionary assigning pulp labels using string keys and values
type: dict
version_added: "0.4.0"
extends_documentation_fragment:
- pulp.squeezer.pulp.entity_state
- pulp.squeezer.pulp
Expand Down Expand Up @@ -86,6 +91,7 @@
DESIRED_KEYS = {
"autopublish",
"description",
"pulp_labels",
}


Expand All @@ -99,6 +105,7 @@ def main():
"name": {},
"description": {},
"autopublish": {"type": "bool"},
"pulp_labels": {"type": "dict"},
},
required_if=[("state", "present", ["name"]), ("state", "absent", ["name"])],
) as module:
Expand All @@ -107,6 +114,14 @@ def main():
key: module.params[key] for key in DESIRED_KEYS if module.params[key] is not None
}

# Ensure `pulp_labels` contains only strings for keys and values
if "pulp_labels" in desired_attributes:
labels = desired_attributes["pulp_labels"]
if not all(isinstance(k, str) and isinstance(v, str) for k, v in labels.items()):
module.fail_json(
msg="pulp_labels must be a dictionary with strings as keys and values"
)

module.process(natural_key, desired_attributes)


Expand Down
4 changes: 3 additions & 1 deletion plugins/modules/rpm_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ def main():
if "pulp_labels" in desired_attributes:
labels = desired_attributes["pulp_labels"]
if not all(isinstance(k, str) and isinstance(v, str) for k, v in labels.items()):
module.fail_json(msg="pulp_labels must be a dictionary with strings as keys and values")
module.fail_json(
msg="pulp_labels must be a dictionary with strings as keys and values"
)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted the rpm_repository formatting as well to make the linter happy


module.process(natural_key, desired_attributes)

Expand Down
2,717 changes: 1,591 additions & 1,126 deletions tests/fixtures/file_repository-0.yml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tests/fixtures/file_repository-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ interactions:
- User-Agent
state:
__istr_identity__: User-Agent
: - Squeezer/0.3.0-dev
: - Squeezer/0.4.0-dev
method: GET
uri: http://pulp.example.org/pulp/api/v3/repositories/file/file/?name=test_file_repository&offset=0&limit=1
response:
body:
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/","prn":"prn:file.filerepository:019dcf79-72b5-7dc7-b6cf-1e6e554e19af","pulp_created":"2026-04-27T15:05:36.186130Z","pulp_last_updated":"2026-04-27T15:05:36.208164Z","versions_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/0/","name":"test_file_repository","description":null,"retain_repo_versions":null,"retain_checkpoints":null,"remote":null,"autopublish":false,"manifest":"PULP_MANIFEST"}]}'
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/","prn":"prn:file.filerepository:019e6092-b01c-7ced-b14a-63a48112652b","pulp_created":"2026-05-25T19:18:06.621748Z","pulp_last_updated":"2026-05-25T19:18:06.627467Z","versions_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/0/","name":"test_file_repository","description":null,"retain_repo_versions":null,"retain_checkpoints":null,"remote":null,"autopublish":false,"manifest":"PULP_MANIFEST"}]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -35,11 +35,11 @@ interactions:
Content-Type:
- application/json
Correlation-ID:
- 466428ba54bc4966aaec5dd1ab68d02d
- 1ba0e82e49c84c46a7e8ac9265666ecc
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Mon, 27 Apr 2026 15:05:39 GMT
- Mon, 25 May 2026 19:18:07 GMT
Referrer-Policy:
- same-origin
Server:
Expand Down
11 changes: 6 additions & 5 deletions tests/fixtures/file_repository-10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ interactions:
- User-Agent
state:
__istr_identity__: User-Agent
: - Squeezer/0.3.0-dev
: - Squeezer/0.4.0-dev
method: GET
uri: http://pulp.example.org/pulp/api/v3/repositories/file/file/?name=test_file_repository&offset=0&limit=1
response:
body:
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/","prn":"prn:file.filerepository:019dcf79-72b5-7dc7-b6cf-1e6e554e19af","pulp_created":"2026-04-27T15:05:36.186130Z","pulp_last_updated":"2026-04-27T15:05:59.347748Z","versions_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/0/","name":"test_file_repository","description":null,"retain_repo_versions":null,"retain_checkpoints":null,"remote":null,"autopublish":true,"manifest":"PULP_MANIFEST"}]}'
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/","prn":"prn:file.filerepository:019e6092-b01c-7ced-b14a-63a48112652b","pulp_created":"2026-05-25T19:18:06.621748Z","pulp_last_updated":"2026-05-25T19:18:10.912445Z","versions_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/","pulp_labels":{"test_label":"1"},"latest_version_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/0/","name":"test_file_repository","description":"repository
created via ansible","retain_repo_versions":null,"retain_checkpoints":null,"remote":null,"autopublish":true,"manifest":"PULP_MANIFEST"}]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -31,15 +32,15 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '695'
- '739'
Content-Type:
- application/json
Correlation-ID:
- f0e98a88f4c84914b315a347bcd0e7af
- 6f07fccefcf34672add1335166d0dac1
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Mon, 27 Apr 2026 15:06:02 GMT
- Mon, 25 May 2026 19:18:13 GMT
Referrer-Policy:
- same-origin
Server:
Expand Down
55 changes: 28 additions & 27 deletions tests/fixtures/file_repository-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ interactions:
- User-Agent
state:
__istr_identity__: User-Agent
: - Squeezer/0.3.0-dev
: - Squeezer/0.4.0-dev
method: GET
uri: http://pulp.example.org/pulp/api/v3/repositories/file/file/?name=test_file_repository&offset=0&limit=1
response:
body:
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/","prn":"prn:file.filerepository:019dcf79-72b5-7dc7-b6cf-1e6e554e19af","pulp_created":"2026-04-27T15:05:36.186130Z","pulp_last_updated":"2026-04-27T15:05:59.347748Z","versions_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/0/","name":"test_file_repository","description":null,"retain_repo_versions":null,"retain_checkpoints":null,"remote":null,"autopublish":true,"manifest":"PULP_MANIFEST"}]}'
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/","prn":"prn:file.filerepository:019e6092-b01c-7ced-b14a-63a48112652b","pulp_created":"2026-05-25T19:18:06.621748Z","pulp_last_updated":"2026-05-25T19:18:10.912445Z","versions_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/","pulp_labels":{"test_label":"1"},"latest_version_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/0/","name":"test_file_repository","description":"repository
created via ansible","retain_repo_versions":null,"retain_checkpoints":null,"remote":null,"autopublish":true,"manifest":"PULP_MANIFEST"}]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -31,15 +32,15 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '695'
- '739'
Content-Type:
- application/json
Correlation-ID:
- 0caf977ab0c2489c88d5190d5759fd63
- 76bbea0e44ff4bab85d7630486f0346b
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Mon, 27 Apr 2026 15:06:04 GMT
- Mon, 25 May 2026 19:18:13 GMT
Referrer-Policy:
- same-origin
Server:
Expand All @@ -54,7 +55,7 @@ interactions:
code: 200
message: OK
- request:
body: '{"autopublish": false}'
body: '{"description": null}'
headers:
? !!python/object/new:multidict._multidict_py.istr
args:
Expand All @@ -67,22 +68,22 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '22'
- '21'
Correlation-Id:
- 0caf977ab0c2489c88d5190d5759fd63
- 76bbea0e44ff4bab85d7630486f0346b
? !!python/object/new:multidict._multidict_py.istr
args:
- User-Agent
state:
__istr_identity__: User-Agent
: - Squeezer/0.3.0-dev
: - Squeezer/0.4.0-dev
content-type:
- application/json
method: PATCH
uri: http://pulp.example.org/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/
uri: http://pulp.example.org/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/
response:
body:
string: '{"task":"/pulp/api/v3/tasks/019dcf79-e205-7a58-8c43-1d5e2eca9271/"}'
string: '{"task":"/pulp/api/v3/tasks/019e6092-cbad-7920-ab34-5d7b54636ced/"}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -95,11 +96,11 @@ interactions:
Content-Type:
- application/json
Correlation-ID:
- 0caf977ab0c2489c88d5190d5759fd63
- 76bbea0e44ff4bab85d7630486f0346b
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Mon, 27 Apr 2026 15:06:04 GMT
- Mon, 25 May 2026 19:18:13 GMT
Referrer-Policy:
- same-origin
Server:
Expand Down Expand Up @@ -127,18 +128,18 @@ interactions:
Connection:
- keep-alive
Correlation-Id:
- 0caf977ab0c2489c88d5190d5759fd63
- 76bbea0e44ff4bab85d7630486f0346b
? !!python/object/new:multidict._multidict_py.istr
args:
- User-Agent
state:
__istr_identity__: User-Agent
: - Squeezer/0.3.0-dev
: - Squeezer/0.4.0-dev
method: GET
uri: http://pulp.example.org/pulp/api/v3/tasks/019dcf79-e205-7a58-8c43-1d5e2eca9271/
uri: http://pulp.example.org/pulp/api/v3/tasks/019e6092-cbad-7920-ab34-5d7b54636ced/
response:
body:
string: '{"pulp_href":"/pulp/api/v3/tasks/019dcf79-e205-7a58-8c43-1d5e2eca9271/","prn":"prn:core.task:019dcf79-e205-7a58-8c43-1d5e2eca9271","pulp_created":"2026-04-27T15:06:04.681218Z","pulp_last_updated":"2026-04-27T15:06:04.677882Z","state":"completed","name":"pulpcore.app.tasks.base.ageneral_update","logging_cid":"0caf977ab0c2489c88d5190d5759fd63","created_by":"/pulp/api/v3/users/1/","unblocked_at":"2026-04-27T15:06:04.701344Z","started_at":"2026-04-27T15:06:04.710384Z","finished_at":"2026-04-27T15:06:04.745146Z","error":null,"worker":null,"parent_task":null,"child_tasks":[],"task_group":null,"progress_reports":[],"created_resources":[],"created_resource_prns":[],"reserved_resources_record":["prn:file.filerepository:019dcf79-72b5-7dc7-b6cf-1e6e554e19af","shared:prn:core.domain:34336c95-92ee-446b-adae-1152e7ac1ddd"],"result":{"prn":"prn:file.filerepository:019dcf79-72b5-7dc7-b6cf-1e6e554e19af","name":"test_file_repository","remote":null,"manifest":"PULP_MANIFEST","pulp_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/","autopublish":false,"description":null,"pulp_labels":{},"pulp_created":"2026-04-27T15:05:36.186130Z","versions_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/","pulp_last_updated":"2026-04-27T15:06:04.724624Z","retain_checkpoints":null,"latest_version_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/0/","retain_repo_versions":null}}'
string: '{"pulp_href":"/pulp/api/v3/tasks/019e6092-cbad-7920-ab34-5d7b54636ced/","prn":"prn:core.task:019e6092-cbad-7920-ab34-5d7b54636ced","pulp_created":"2026-05-25T19:18:13.679320Z","pulp_last_updated":"2026-05-25T19:18:13.677413Z","state":"completed","name":"pulpcore.app.tasks.base.ageneral_update","logging_cid":"76bbea0e44ff4bab85d7630486f0346b","created_by":"/pulp/api/v3/users/1/","unblocked_at":"2026-05-25T19:18:13.686060Z","started_at":"2026-05-25T19:18:13.689422Z","finished_at":"2026-05-25T19:18:13.697101Z","error":null,"worker":null,"parent_task":null,"child_tasks":[],"task_group":null,"progress_reports":[],"created_resources":[],"created_resource_prns":[],"reserved_resources_record":["prn:file.filerepository:019e6092-b01c-7ced-b14a-63a48112652b","shared:prn:core.domain:174af0ec-9de3-42c4-a419-2414acba26a6"],"result":{"prn":"prn:file.filerepository:019e6092-b01c-7ced-b14a-63a48112652b","name":"test_file_repository","remote":null,"manifest":"PULP_MANIFEST","pulp_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/","autopublish":true,"description":null,"pulp_labels":{"test_label":"1"},"pulp_created":"2026-05-25T19:18:06.621748Z","versions_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/","pulp_last_updated":"2026-05-25T19:18:13.693901Z","retain_checkpoints":null,"latest_version_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/0/","retain_repo_versions":null}}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -147,15 +148,15 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '1475'
- '1490'
Content-Type:
- application/json
Correlation-ID:
- 0caf977ab0c2489c88d5190d5759fd63
- 76bbea0e44ff4bab85d7630486f0346b
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Mon, 27 Apr 2026 15:06:05 GMT
- Mon, 25 May 2026 19:18:13 GMT
Referrer-Policy:
- same-origin
Server:
Expand Down Expand Up @@ -183,18 +184,18 @@ interactions:
Connection:
- keep-alive
Correlation-Id:
- 0caf977ab0c2489c88d5190d5759fd63
- 76bbea0e44ff4bab85d7630486f0346b
? !!python/object/new:multidict._multidict_py.istr
args:
- User-Agent
state:
__istr_identity__: User-Agent
: - Squeezer/0.3.0-dev
: - Squeezer/0.4.0-dev
method: GET
uri: http://pulp.example.org/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/
uri: http://pulp.example.org/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/
response:
body:
string: '{"pulp_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/","prn":"prn:file.filerepository:019dcf79-72b5-7dc7-b6cf-1e6e554e19af","pulp_created":"2026-04-27T15:05:36.186130Z","pulp_last_updated":"2026-04-27T15:06:04.724624Z","versions_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/0/","name":"test_file_repository","description":null,"retain_repo_versions":null,"retain_checkpoints":null,"remote":null,"autopublish":false,"manifest":"PULP_MANIFEST"}'
string: '{"pulp_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/","prn":"prn:file.filerepository:019e6092-b01c-7ced-b14a-63a48112652b","pulp_created":"2026-05-25T19:18:06.621748Z","pulp_last_updated":"2026-05-25T19:18:13.693901Z","versions_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/","pulp_labels":{"test_label":"1"},"latest_version_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/0/","name":"test_file_repository","description":null,"retain_repo_versions":null,"retain_checkpoints":null,"remote":null,"autopublish":true,"manifest":"PULP_MANIFEST"}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -203,15 +204,15 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '644'
- '659'
Content-Type:
- application/json
Correlation-ID:
- 0caf977ab0c2489c88d5190d5759fd63
- 76bbea0e44ff4bab85d7630486f0346b
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Mon, 27 Apr 2026 15:06:05 GMT
- Mon, 25 May 2026 19:18:13 GMT
Referrer-Policy:
- same-origin
Server:
Expand Down
10 changes: 5 additions & 5 deletions tests/fixtures/file_repository-12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ interactions:
- User-Agent
state:
__istr_identity__: User-Agent
: - Squeezer/0.3.0-dev
: - Squeezer/0.4.0-dev
method: GET
uri: http://pulp.example.org/pulp/api/v3/repositories/file/file/?name=test_file_repository&offset=0&limit=1
response:
body:
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/","prn":"prn:file.filerepository:019dcf79-72b5-7dc7-b6cf-1e6e554e19af","pulp_created":"2026-04-27T15:05:36.186130Z","pulp_last_updated":"2026-04-27T15:06:04.724624Z","versions_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/file/file/019dcf79-72b5-7dc7-b6cf-1e6e554e19af/versions/0/","name":"test_file_repository","description":null,"retain_repo_versions":null,"retain_checkpoints":null,"remote":null,"autopublish":false,"manifest":"PULP_MANIFEST"}]}'
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/","prn":"prn:file.filerepository:019e6092-b01c-7ced-b14a-63a48112652b","pulp_created":"2026-05-25T19:18:06.621748Z","pulp_last_updated":"2026-05-25T19:18:13.693901Z","versions_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/","pulp_labels":{"test_label":"1"},"latest_version_href":"/pulp/api/v3/repositories/file/file/019e6092-b01c-7ced-b14a-63a48112652b/versions/0/","name":"test_file_repository","description":null,"retain_repo_versions":null,"retain_checkpoints":null,"remote":null,"autopublish":true,"manifest":"PULP_MANIFEST"}]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -31,15 +31,15 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '696'
- '711'
Content-Type:
- application/json
Correlation-ID:
- 74981bc5f1b042809e255c2f12d6c2fb
- f262336c29c841ccb45bbd3de75a30fc
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Mon, 27 Apr 2026 15:06:07 GMT
- Mon, 25 May 2026 19:18:14 GMT
Referrer-Policy:
- same-origin
Server:
Expand Down
Loading