Skip to content

Commit 25eafee

Browse files
committed
Drop quirks and workarounds for pulpcore<3.49
1 parent d745426 commit 25eafee

26 files changed

Lines changed: 146 additions & 554 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed compatibility checks and workaround for pulpcore < 3.49.

pulp-glue/src/pulp_glue/certguard/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PulpX509CertGuardContext(PulpContentGuardContext):
1212
ENTITIES = _("x509 certguards")
1313
HREF = "certguard_x509_cert_guard_href"
1414
ID_PREFIX = "contentguards_certguard_x509"
15-
NEEDS_PLUGINS = [PluginRequirement("certguard", specifier=">=1.4.0")]
15+
NEEDS_PLUGINS = [PluginRequirement("certguard")]
1616

1717

1818
class PulpRHSMCertGuardContext(PulpContentGuardContext):
@@ -22,4 +22,4 @@ class PulpRHSMCertGuardContext(PulpContentGuardContext):
2222
ENTITIES = _("RHSM certguards")
2323
HREF = "certguard_r_h_s_m_cert_guard_href"
2424
ID_PREFIX = "contentguards_certguard_rhsm"
25-
NEEDS_PLUGINS = [PluginRequirement("certguard", specifier=">=1.4.0")]
25+
NEEDS_PLUGINS = [PluginRequirement("certguard")]

pulp-glue/src/pulp_glue/common/context.py

Lines changed: 35 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -205,38 +205,6 @@ def _patch_api_hook(spec: t.Any) -> t.Any:
205205
return spec
206206

207207

208-
@api_spec_quirk(PluginRequirement("core", specifier="<3.20.0"))
209-
def patch_ordering_filters(api_spec: t.Any) -> t.Any:
210-
for path, method, operation_id, operation in walk_operations(api_spec):
211-
if method == "get" and "parameters" in operation:
212-
for parameter in operation["parameters"]:
213-
if (
214-
parameter["name"] == "ordering"
215-
and parameter["in"] == "query"
216-
and "schema" in parameter
217-
and parameter["schema"]["type"] == "string"
218-
):
219-
parameter["schema"] = {"type": "array", "items": {"type": "string"}}
220-
parameter["explode"] = False
221-
parameter["style"] = "form"
222-
return api_spec
223-
224-
225-
@api_spec_quirk(PluginRequirement("core", specifier="<3.22.0"))
226-
def patch_field_select_filters(api_spec: t.Any) -> t.Any:
227-
for path, method, operation_id, operation in walk_operations(api_spec):
228-
if method == "get" and "parameters" in operation:
229-
for parameter in operation["parameters"]:
230-
if (
231-
parameter["name"] in ["fields", "exclude_fields"]
232-
and parameter["in"] == "query"
233-
and "schema" in parameter
234-
and parameter["schema"]["type"] == "string"
235-
):
236-
parameter["schema"] = {"type": "array", "items": {"type": "string"}}
237-
return api_spec
238-
239-
240208
@api_spec_quirk(PluginRequirement("core", specifier="<99.99.0"))
241209
def patch_content_in_query_filters(api_spec: t.Any) -> t.Any:
242210
# https://github.com/pulp/pulpcore/issues/3634
@@ -259,13 +227,6 @@ def patch_content_in_query_filters(api_spec: t.Any) -> t.Any:
259227
return api_spec
260228

261229

262-
@api_spec_quirk(PluginRequirement("core", specifier=">=3.23,<3.30.0"))
263-
def patch_upstream_pulp_replicate_request_body(api_spec: t.Any) -> t.Any:
264-
operation = api_spec["paths"]["{upstream_pulp_href}replicate/"]["post"]
265-
operation.pop("requestBody", None)
266-
return api_spec
267-
268-
269230
@api_spec_quirk(PluginRequirement("core", specifier="<3.85"))
270231
def patch_security_scheme_mutual_tls(api_spec: t.Any) -> t.Any:
271232
# Trick to allow tls cert auth on older Pulp.
@@ -342,7 +303,8 @@ def __init__(
342303
# If this is "only" true and we have the PULP_CA_BUNDLE variable set, use it.
343304
self.verify_ssl = os.environ.get("PULP_CA_BUNDLE", True)
344305
self._needed_plugins: list[PluginRequirement] = [
345-
PluginRequirement("core", specifier=">=3.11.0")
306+
# This should be the currently oldest supported release branch.
307+
PluginRequirement("core", specifier=">=3.49.0")
346308
]
347309
self.pulp_domain: str = domain
348310

@@ -823,15 +785,16 @@ class PulpEntityContext(PulpViewSetContext):
823785
"""
824786
List of capabilities this entity provides.
825787
826-
Subclasses can specify version dependent capabilities here
788+
Subclasses can specify version dependent capabilities here.
827789
828790
Example:
829791
```
830792
CAPABILITIES = {
831793
"feature1": [
832794
PluginRequirement("file"),
833-
PluginRequirement("core", specifier=">=3.7.0")
795+
PluginRequirement("core", specifier=">=5.6.7")
834796
]
797+
"feature2": [], # Feature2 does not depend on any extra versions/plugins.
835798
}
836799
```
837800
"""
@@ -1239,20 +1202,19 @@ def set_label(self, key: str, value: str, non_blocking: bool = False) -> t.Any:
12391202
assert self._entity is not None
12401203
self._entity["pulp_labels"][key] = value
12411204
return None
1242-
if self.pulp_ctx.has_plugin(PluginRequirement("core", specifier=">=3.34.0")):
1243-
try:
1244-
return self.call(
1245-
"set_label",
1246-
parameters={self.HREF: self.pulp_href},
1247-
body={"key": key, "value": value},
1248-
)
1249-
except PulpHTTPError as e:
1250-
if e.status_code != 403:
1251-
raise
1252-
# Workaround for broken access policies: Try the old mechanism.
1253-
labels = self.entity["pulp_labels"]
1254-
labels[key] = value
1255-
return self.update(body={"pulp_labels": labels}, non_blocking=non_blocking)
1205+
try:
1206+
return self.call(
1207+
"set_label",
1208+
parameters={self.HREF: self.pulp_href},
1209+
body={"key": key, "value": value},
1210+
)
1211+
except PulpHTTPError as e:
1212+
if e.status_code != 403:
1213+
raise
1214+
# Workaround for broken access policies: Try the old mechanism.
1215+
labels = self.entity["pulp_labels"]
1216+
labels[key] = value
1217+
return self.update(body={"pulp_labels": labels}, non_blocking=non_blocking)
12561218

12571219
def unset_label(self, key: str, non_blocking: bool = False) -> t.Any:
12581220
"""
@@ -1268,23 +1230,23 @@ def unset_label(self, key: str, non_blocking: bool = False) -> t.Any:
12681230
assert self._entity is not None
12691231
self._entity["pulp_labels"].pop(key)
12701232
return None
1271-
if self.pulp_ctx.has_plugin(PluginRequirement("core", specifier=">=3.34.0")):
1272-
try:
1273-
return self.call(
1274-
"unset_label",
1275-
parameters={self.HREF: self.pulp_href},
1276-
body={"key": key},
1277-
)
1278-
except PulpHTTPError as e:
1279-
if e.status_code != 403:
1280-
raise
1281-
# Workaround for broken access policies: Try the old mechanism.
1282-
labels = self.entity["pulp_labels"]
1233+
12831234
try:
1284-
labels.pop(key)
1285-
except KeyError:
1286-
raise PulpException(_("Could not find label with key '{key}'.").format(key=key))
1287-
return self.update(body={"pulp_labels": labels}, non_blocking=non_blocking)
1235+
return self.call(
1236+
"unset_label",
1237+
parameters={self.HREF: self.pulp_href},
1238+
body={"key": key},
1239+
)
1240+
except PulpHTTPError as e:
1241+
if e.status_code != 403:
1242+
raise
1243+
# Workaround for broken access policies: Try the old mechanism.
1244+
labels = self.entity["pulp_labels"]
1245+
try:
1246+
labels.pop(key)
1247+
except KeyError:
1248+
raise PulpException(_("Could not find label with key '{key}'.").format(key=key))
1249+
return self.update(body={"pulp_labels": labels}, non_blocking=non_blocking)
12881250

12891251
def show_label(self, key: str) -> str | None:
12901252
"""
@@ -1477,13 +1439,6 @@ def __init_subclass__(cls, **kwargs: t.Any) -> None:
14771439
)
14781440
cls.TYPE_REGISTRY[f"{cls.PLUGIN}:{cls.RESOURCE_TYPE}"] = cls
14791441

1480-
def list(self, limit: int, offset: int, parameters: dict[str, t.Any]) -> list[t.Any]:
1481-
if parameters.get("repository") is not None:
1482-
self.pulp_ctx.needs_plugin(
1483-
PluginRequirement("core", specifier=">=3.20.0", feature=_("repository filter"))
1484-
)
1485-
return super().list(limit, offset, parameters)
1486-
14871442

14881443
class PulpDistributionContext(PulpEntityContext):
14891444
"""Base class for distribution contexts."""
@@ -1621,17 +1576,6 @@ def get_version_context(
16211576
pulp_ctx=self.pulp_ctx, repository_ctx=self, pulp_href=version_href
16221577
)
16231578

1624-
def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> EntityDefinition:
1625-
body = super().preprocess_entity(body, partial=partial)
1626-
if "retain_repo_versions" in body:
1627-
self.pulp_ctx.needs_plugin(PluginRequirement("core", specifier=">=3.13.0"))
1628-
if self.pulp_ctx.has_plugin(PluginRequirement("core", specifier=">=3.13.0,<3.15.0")):
1629-
# "retain_repo_versions" has been named "retained_versions" until pulpcore 3.15
1630-
# https://github.com/pulp/pulpcore/pull/1472
1631-
if "retain_repo_versions" in body:
1632-
body["retained_versions"] = body.pop("retain_repo_versions")
1633-
return body
1634-
16351579
def sync(self, body: EntityDefinition | None = None) -> t.Any:
16361580
"""
16371581
Trigger a sync task for this repository.
@@ -1692,7 +1636,6 @@ def reclaim(
16921636
Returns:
16931637
Record of the reclaim space task.
16941638
"""
1695-
self.pulp_ctx.needs_plugin(PluginRequirement("core", specifier=">=3.19.0"))
16961639
body: dict[str, t.Any] = {}
16971640
body["repo_hrefs"] = repo_hrefs
16981641
if repo_versions_keeplist:
@@ -1753,17 +1696,12 @@ def _prepare_upload(
17531696
if not self.pulp_ctx.fake_mode: # Skip the uploading part in fake_mode
17541697
if _chunk_size is None or _chunk_size > size:
17551698
body["file"] = file
1756-
elif self.pulp_ctx.has_plugin(PluginRequirement("core", specifier=">=3.20.0")):
1699+
else:
17571700
self.needs_capability("upload")
17581701
from pulp_glue.core.context import PulpUploadContext
17591702

17601703
upload_href = PulpUploadContext(self.pulp_ctx).upload_file(file, _chunk_size)
17611704
body["upload"] = upload_href
1762-
else:
1763-
from pulp_glue.core.context import PulpArtifactContext
1764-
1765-
artifact_href = PulpArtifactContext(self.pulp_ctx).upload(file, _chunk_size)
1766-
body["artifact"] = artifact_href
17671705

17681706
def create(
17691707
self,

0 commit comments

Comments
 (0)