Skip to content

Commit

Permalink
feat(rpm_repository): add retain_repo_versions
Browse files Browse the repository at this point in the history
This change adds `retain_repo_versions` parameter option to
`rpm_repository` module. It also adds tests and associated
fixtures.

fixes #165
  • Loading branch information
Joey Grant authored and joey-grant committed Jul 29, 2024
1 parent 3c1f0e4 commit 1b30512
Show file tree
Hide file tree
Showing 26 changed files with 2,831 additions and 2,198 deletions.
16 changes: 14 additions & 2 deletions plugins/modules/rpm_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@
version_added: "0.0.16"
retain_package_versions:
description:
- Max number of latest versions of each package to keep (optional)
- Max number of latest versions of each package to keep
type: int
version_added: "0.0.16"
retain_repo_versions:
description:
- Max number of repository versions to keep
type: int
version_added: "0.0.16"
extends_documentation_fragment:
Expand Down Expand Up @@ -103,7 +108,13 @@
PulpRpmRepository,
)

DESIRED_KEYS = {"autopublish", "remote", "repo_config", "retain_package_versions"}
DESIRED_KEYS = {
"autopublish",
"remote",
"repo_config",
"retain_package_versions",
"retain_repo_versions",
}


def main():
Expand All @@ -115,6 +126,7 @@ def main():
"remote": {},
"repo_config": {"type": "raw"},
"retain_package_versions": {"type": "int"},
"retain_repo_versions": {"type": "int"},
},
required_if=[("state", "present", ["name"]), ("state", "absent", ["name"])],
) as module:
Expand Down
3,947 changes: 2,148 additions & 1,799 deletions tests/fixtures/rpm_repository-0.yml

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions tests/fixtures/rpm_repository-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ interactions:
Host:
- localhost:8080
User-Agent:
- Python-urllib/3.9
- Python-urllib/3.10
method: GET
uri: http://pulp.example.org/pulp/api/v3/remotes/rpm/rpm/?limit=1&name=test_rpm_remote
response:
body:
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/remotes/rpm/rpm/018f8307-f364-772e-99d8-d7d98185a9d4/","pulp_created":"2024-05-16T20:11:27.461460Z","pulp_last_updated":"2024-05-16T20:11:27.461481Z","name":"test_rpm_remote","url":"https://fixtures.pulpproject.org/rpm-signed/","ca_cert":null,"client_cert":null,"tls_validation":true,"proxy_url":null,"pulp_labels":{},"download_concurrency":null,"max_retries":null,"policy":"immediate","total_timeout":null,"connect_timeout":null,"sock_connect_timeout":null,"sock_read_timeout":null,"headers":null,"rate_limit":null,"hidden_fields":[{"name":"client_key","is_set":false},{"name":"proxy_username","is_set":false},{"name":"proxy_password","is_set":false},{"name":"username","is_set":false},{"name":"password","is_set":false}],"sles_auth_token":null}]}'
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/remotes/rpm/rpm/0190f53c-23d5-73c8-8641-e94d3ae6dfa2/","pulp_created":"2024-07-27T17:27:57.654285Z","pulp_last_updated":"2024-07-27T17:27:57.654296Z","name":"test_rpm_remote","url":"https://fixtures.pulpproject.org/rpm-signed/","ca_cert":null,"client_cert":null,"tls_validation":true,"proxy_url":null,"pulp_labels":{},"download_concurrency":null,"max_retries":null,"policy":"immediate","total_timeout":null,"connect_timeout":null,"sock_connect_timeout":null,"sock_read_timeout":null,"headers":null,"rate_limit":null,"hidden_fields":[{"name":"client_key","is_set":false},{"name":"proxy_username","is_set":false},{"name":"proxy_password","is_set":false},{"name":"username","is_set":false},{"name":"password","is_set":false}],"sles_auth_token":null}]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -29,11 +29,11 @@ interactions:
Content-Type:
- application/json
Correlation-ID:
- 7b1b119c608443cba4646afb0848dc30
- 6fe2a6ac30124d97809077280f9ded55
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Thu, 16 May 2024 20:11:36 GMT
- Sat, 27 Jul 2024 17:28:01 GMT
Referrer-Policy:
- same-origin
Server:
Expand All @@ -59,7 +59,7 @@ interactions:
Host:
- localhost:8080
User-Agent:
- Python-urllib/3.9
- Python-urllib/3.10
method: GET
uri: http://pulp.example.org/pulp/api/v3/repositories/rpm/rpm/?limit=1&name=test_rpm_repository
response:
Expand All @@ -77,11 +77,11 @@ interactions:
Content-Type:
- application/json
Correlation-ID:
- ed58d2c33bdb4d5fb2ad0ee292f6f924
- c0dc7961f33142f6bfb50baf5ef8d067
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Thu, 16 May 2024 20:11:37 GMT
- Sat, 27 Jul 2024 17:28:01 GMT
Referrer-Policy:
- same-origin
Server:
Expand All @@ -96,7 +96,7 @@ interactions:
code: 200
message: OK
- request:
body: '{"name": "test_rpm_repository", "remote": "/pulp/api/v3/remotes/rpm/rpm/018f8307-f364-772e-99d8-d7d98185a9d4/",
body: '{"name": "test_rpm_repository", "remote": "/pulp/api/v3/remotes/rpm/rpm/0190f53c-23d5-73c8-8641-e94d3ae6dfa2/",
"description": null}'
headers:
Accept:
Expand All @@ -110,12 +110,12 @@ interactions:
Host:
- localhost:8080
User-Agent:
- Python-urllib/3.9
- Python-urllib/3.10
method: POST
uri: http://pulp.example.org/pulp/api/v3/repositories/rpm/rpm/
response:
body:
string: '{"pulp_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/","pulp_created":"2024-05-16T20:11:38.120669Z","pulp_last_updated":"2024-05-16T20:11:38.134173Z","versions_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/versions/0/","name":"test_rpm_repository","description":null,"retain_repo_versions":null,"remote":"/pulp/api/v3/remotes/rpm/rpm/018f8307-f364-772e-99d8-d7d98185a9d4/","autopublish":false,"metadata_signing_service":null,"retain_package_versions":0,"checksum_type":null,"metadata_checksum_type":null,"package_checksum_type":null,"gpgcheck":null,"repo_gpgcheck":null,"sqlite_metadata":false,"repo_config":{},"compression_type":null}'
string: '{"pulp_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/","pulp_created":"2024-07-27T17:28:02.079193Z","pulp_last_updated":"2024-07-27T17:28:02.088704Z","versions_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/versions/0/","name":"test_rpm_repository","description":null,"retain_repo_versions":null,"remote":"/pulp/api/v3/remotes/rpm/rpm/0190f53c-23d5-73c8-8641-e94d3ae6dfa2/","autopublish":false,"metadata_signing_service":null,"package_signing_service":null,"package_signing_fingerprint":"","retain_package_versions":0,"checksum_type":null,"metadata_checksum_type":null,"package_checksum_type":null,"gpgcheck":null,"repo_gpgcheck":null,"sqlite_metadata":false,"repo_config":{},"compression_type":null}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -124,17 +124,17 @@ interactions:
Connection:
- close
Content-Length:
- '821'
- '885'
Content-Type:
- application/json
Correlation-ID:
- 21101262aee14f4db76efada70c4a5e8
- 27fe8ac081194e328936761d3dfe4d01
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Thu, 16 May 2024 20:11:38 GMT
- Sat, 27 Jul 2024 17:28:02 GMT
Location:
- /pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/
- /pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/
Referrer-Policy:
- same-origin
Server:
Expand Down
12 changes: 6 additions & 6 deletions tests/fixtures/rpm_repository-10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ interactions:
Host:
- localhost:8080
User-Agent:
- Python-urllib/3.9
- Python-urllib/3.10
method: GET
uri: http://pulp.example.org/pulp/api/v3/repositories/rpm/rpm/?limit=1&name=test_rpm_repository
response:
body:
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/","pulp_created":"2024-05-16T20:11:38.120669Z","pulp_last_updated":"2024-05-16T20:11:55.307073Z","versions_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/versions/0/","name":"test_rpm_repository","description":"repository
created via ansible","retain_repo_versions":null,"remote":"/pulp/api/v3/remotes/rpm/rpm/018f8307-f364-772e-99d8-d7d98185a9d4/","autopublish":true,"metadata_signing_service":null,"retain_package_versions":3,"checksum_type":null,"metadata_checksum_type":null,"package_checksum_type":null,"gpgcheck":null,"repo_gpgcheck":null,"sqlite_metadata":false,"repo_config":{},"compression_type":null}]}'
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/","pulp_created":"2024-07-27T17:28:02.079193Z","pulp_last_updated":"2024-07-27T17:28:07.148800Z","versions_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/versions/0/","name":"test_rpm_repository","description":"repository
created via ansible","retain_repo_versions":null,"remote":"/pulp/api/v3/remotes/rpm/rpm/0190f53c-23d5-73c8-8641-e94d3ae6dfa2/","autopublish":true,"metadata_signing_service":null,"package_signing_service":null,"package_signing_fingerprint":"","retain_package_versions":3,"checksum_type":null,"metadata_checksum_type":null,"package_checksum_type":null,"gpgcheck":null,"repo_gpgcheck":null,"sqlite_metadata":false,"repo_config":{},"compression_type":null}]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -26,15 +26,15 @@ interactions:
Connection:
- close
Content-Length:
- '900'
- '964'
Content-Type:
- application/json
Correlation-ID:
- 16bcefb5d3b14158be2eb37d58d31190
- d912a1c2657c41c6a3e46a63ea26cdd9
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Thu, 16 May 2024 20:11:57 GMT
- Sat, 27 Jul 2024 17:28:07 GMT
Referrer-Policy:
- same-origin
Server:
Expand Down
48 changes: 24 additions & 24 deletions tests/fixtures/rpm_repository-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ interactions:
Host:
- localhost:8080
User-Agent:
- Python-urllib/3.9
- Python-urllib/3.10
method: GET
uri: http://pulp.example.org/pulp/api/v3/repositories/rpm/rpm/?limit=1&name=test_rpm_repository
response:
body:
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/","pulp_created":"2024-05-16T20:11:38.120669Z","pulp_last_updated":"2024-05-16T20:11:55.307073Z","versions_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/versions/0/","name":"test_rpm_repository","description":"repository
created via ansible","retain_repo_versions":null,"remote":"/pulp/api/v3/remotes/rpm/rpm/018f8307-f364-772e-99d8-d7d98185a9d4/","autopublish":true,"metadata_signing_service":null,"retain_package_versions":3,"checksum_type":null,"metadata_checksum_type":null,"package_checksum_type":null,"gpgcheck":null,"repo_gpgcheck":null,"sqlite_metadata":false,"repo_config":{},"compression_type":null}]}'
string: '{"count":1,"next":null,"previous":null,"results":[{"pulp_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/","pulp_created":"2024-07-27T17:28:02.079193Z","pulp_last_updated":"2024-07-27T17:28:07.148800Z","versions_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/versions/0/","name":"test_rpm_repository","description":"repository
created via ansible","retain_repo_versions":null,"remote":"/pulp/api/v3/remotes/rpm/rpm/0190f53c-23d5-73c8-8641-e94d3ae6dfa2/","autopublish":true,"metadata_signing_service":null,"package_signing_service":null,"package_signing_fingerprint":"","retain_package_versions":3,"checksum_type":null,"metadata_checksum_type":null,"package_checksum_type":null,"gpgcheck":null,"repo_gpgcheck":null,"sqlite_metadata":false,"repo_config":{},"compression_type":null}]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -26,15 +26,15 @@ interactions:
Connection:
- close
Content-Length:
- '900'
- '964'
Content-Type:
- application/json
Correlation-ID:
- 80877f090fa54f6bbb37587fc8813055
- a902eee4d5e2442a8a5e56489b0a5c71
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Thu, 16 May 2024 20:11:59 GMT
- Sat, 27 Jul 2024 17:28:08 GMT
Referrer-Policy:
- same-origin
Server:
Expand Down Expand Up @@ -62,12 +62,12 @@ interactions:
Host:
- localhost:8080
User-Agent:
- Python-urllib/3.9
- Python-urllib/3.10
method: PATCH
uri: http://pulp.example.org/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/
uri: http://pulp.example.org/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/
response:
body:
string: '{"task":"/pulp/api/v3/tasks/018f8308-7223-7382-80b1-a5d6654b1b75/"}'
string: '{"task":"/pulp/api/v3/tasks/0190f53c-4e17-77cf-aabf-a58accb72ed1/"}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -80,11 +80,11 @@ interactions:
Content-Type:
- application/json
Correlation-ID:
- ba2363f6846c4ac7a5ac4b3fa53b9007
- 80617a6154b84a609db5bc844f91bf85
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Thu, 16 May 2024 20:11:59 GMT
- Sat, 27 Jul 2024 17:28:08 GMT
Referrer-Policy:
- same-origin
Server:
Expand All @@ -110,12 +110,12 @@ interactions:
Host:
- localhost:8080
User-Agent:
- Python-urllib/3.9
- Python-urllib/3.10
method: GET
uri: http://pulp.example.org/pulp/api/v3/tasks/018f8308-7223-7382-80b1-a5d6654b1b75/
uri: http://pulp.example.org/pulp/api/v3/tasks/0190f53c-4e17-77cf-aabf-a58accb72ed1/
response:
body:
string: '{"pulp_href":"/pulp/api/v3/tasks/018f8308-7223-7382-80b1-a5d6654b1b75/","pulp_created":"2024-05-16T20:11:59.908571Z","pulp_last_updated":"2024-05-16T20:11:59.908592Z","state":"completed","name":"pulpcore.app.tasks.base.general_update","logging_cid":"ba2363f6846c4ac7a5ac4b3fa53b9007","created_by":"/pulp/api/v3/users/1/","unblocked_at":"2024-05-16T20:11:59.921103Z","started_at":"2024-05-16T20:11:59.925172Z","finished_at":"2024-05-16T20:11:59.940705Z","error":null,"worker":null,"parent_task":null,"child_tasks":[],"task_group":null,"progress_reports":[],"created_resources":[],"reserved_resources_record":["prn:rpm.rpmrepository:018f8308-1d06-7339-a2ba-e5f788d08591","/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/","shared:prn:core.domain:018f8306-2afe-7e45-b817-16798214d4ae","shared:/pulp/api/v3/domains/018f8306-2afe-7e45-b817-16798214d4ae/"]}'
string: '{"pulp_href":"/pulp/api/v3/tasks/0190f53c-4e17-77cf-aabf-a58accb72ed1/","pulp_created":"2024-07-27T17:28:08.471857Z","pulp_last_updated":"2024-07-27T17:28:08.471867Z","state":"completed","name":"pulpcore.app.tasks.base.general_update","logging_cid":"80617a6154b84a609db5bc844f91bf85","created_by":"/pulp/api/v3/users/1/","unblocked_at":"2024-07-27T17:28:08.489564Z","started_at":"2024-07-27T17:28:08.490687Z","finished_at":"2024-07-27T17:28:08.495843Z","error":null,"worker":null,"parent_task":null,"child_tasks":[],"task_group":null,"progress_reports":[],"created_resources":[],"reserved_resources_record":["prn:rpm.rpmrepository:0190f53c-351d-732c-b78c-fb4a7b3206ba","shared:prn:core.domain:0190f53b-4160-7112-b97a-003c23c374a7"]}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -124,15 +124,15 @@ interactions:
Connection:
- close
Content-Length:
- '874'
- '732'
Content-Type:
- application/json
Correlation-ID:
- 8a8312dc994041159cbbae36cce41828
- 2a1719578a9e46db9ea826d2dea51803
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Thu, 16 May 2024 20:12:00 GMT
- Sat, 27 Jul 2024 17:28:08 GMT
Referrer-Policy:
- same-origin
Server:
Expand All @@ -158,13 +158,13 @@ interactions:
Host:
- localhost:8080
User-Agent:
- Python-urllib/3.9
- Python-urllib/3.10
method: GET
uri: http://pulp.example.org/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/
uri: http://pulp.example.org/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/
response:
body:
string: '{"pulp_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/","pulp_created":"2024-05-16T20:11:38.120669Z","pulp_last_updated":"2024-05-16T20:11:59.935173Z","versions_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/rpm/rpm/018f8308-1d06-7339-a2ba-e5f788d08591/versions/0/","name":"test_rpm_repository","description":"repository
created via ansible","retain_repo_versions":null,"remote":"/pulp/api/v3/remotes/rpm/rpm/018f8307-f364-772e-99d8-d7d98185a9d4/","autopublish":true,"metadata_signing_service":null,"retain_package_versions":0,"checksum_type":null,"metadata_checksum_type":null,"package_checksum_type":null,"gpgcheck":null,"repo_gpgcheck":null,"sqlite_metadata":false,"repo_config":{},"compression_type":null}'
string: '{"pulp_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/","pulp_created":"2024-07-27T17:28:02.079193Z","pulp_last_updated":"2024-07-27T17:28:08.493886Z","versions_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/versions/","pulp_labels":{},"latest_version_href":"/pulp/api/v3/repositories/rpm/rpm/0190f53c-351d-732c-b78c-fb4a7b3206ba/versions/0/","name":"test_rpm_repository","description":"repository
created via ansible","retain_repo_versions":null,"remote":"/pulp/api/v3/remotes/rpm/rpm/0190f53c-23d5-73c8-8641-e94d3ae6dfa2/","autopublish":true,"metadata_signing_service":null,"package_signing_service":null,"package_signing_fingerprint":"","retain_package_versions":0,"checksum_type":null,"metadata_checksum_type":null,"package_checksum_type":null,"gpgcheck":null,"repo_gpgcheck":null,"sqlite_metadata":false,"repo_config":{},"compression_type":null}'
headers:
Access-Control-Expose-Headers:
- Correlation-ID
Expand All @@ -173,15 +173,15 @@ interactions:
Connection:
- close
Content-Length:
- '848'
- '912'
Content-Type:
- application/json
Correlation-ID:
- efd36400670d448a9ec2c7437fc8adf6
- 5be34e3efa8e462799d1c8f95370c306
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Thu, 16 May 2024 20:12:01 GMT
- Sat, 27 Jul 2024 17:28:08 GMT
Referrer-Policy:
- same-origin
Server:
Expand Down
Loading

0 comments on commit 1b30512

Please sign in to comment.