Skip to content

Commit

Permalink
Fix pulp-cli 0.25 compatibility and bump version
Browse files Browse the repository at this point in the history
closes #114
  • Loading branch information
quba42 committed May 6, 2024
1 parent 627b00c commit 6ff1851
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGES/114.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Installation with Pulp CLI >=0.25.0 is now supported.
1 change: 1 addition & 0 deletions CHANGES/114.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pulp CLI deb now requires at least Pulp CLI >=0.23.2 to run.
2 changes: 1 addition & 1 deletion lower_bounds_constraints.lock
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pulp-cli==0.18.2
pulp-cli==0.23.2
46 changes: 36 additions & 10 deletions pulp-glue-deb/pulp_glue/deb/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
PulpException,
PulpRepositoryContext,
PulpRepositoryVersionContext,
registered_repository_contexts,
)
from pulp_glue.common.i18n import get_translation

Expand All @@ -22,6 +21,8 @@ class PulpDebGenericContentContext(PulpContentContext):
HREF = "deb_generic_content_href"
ID_PREFIX = "content_deb_generic_contents"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "generic_content"


class PulpDebInstallerFileIndexContext(PulpContentContext):
Expand All @@ -30,6 +31,8 @@ class PulpDebInstallerFileIndexContext(PulpContentContext):
HREF = "deb_installer_file_index_href"
ID_PREFIX = "content_deb_installer_file_indices"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "installer_file_index"


class PulpDebInstallerPackageContext(PulpContentContext):
Expand All @@ -38,6 +41,8 @@ class PulpDebInstallerPackageContext(PulpContentContext):
HREF = "deb_installer_package_href"
ID_PREFIX = "content_deb_installer_packages"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "installer_package"


class PulpDebPackageIndexContext(PulpContentContext):
Expand All @@ -46,6 +51,8 @@ class PulpDebPackageIndexContext(PulpContentContext):
HREF = "deb_package_index_href"
ID_PREFIX = "content_deb_package_indices"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "package_index"


class PulpDebPackageReleaseComponentContext(PulpContentContext):
Expand All @@ -54,6 +61,8 @@ class PulpDebPackageReleaseComponentContext(PulpContentContext):
HREF = "deb_package_release_component_href"
ID_PREFIX = "content_deb_package_release_components"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "package_release_component"


class PulpDebPackageContext(PulpContentContext):
Expand All @@ -63,6 +72,8 @@ class PulpDebPackageContext(PulpContentContext):
HREF = "deb_package_href"
ID_PREFIX = "content_deb_packages"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "package"


class PulpDebReleaseArchitectureContext(PulpContentContext):
Expand All @@ -71,6 +82,8 @@ class PulpDebReleaseArchitectureContext(PulpContentContext):
HREF = "deb_release_architecture_href"
ID_PREFIX = "content_deb_release_architectures"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "release_architecture"


class PulpDebReleaseComponentContext(PulpContentContext):
Expand All @@ -79,6 +92,8 @@ class PulpDebReleaseComponentContext(PulpContentContext):
HREF = "deb_release_component_href"
ID_PREFIX = "content_deb_release_components"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "release_component"


class PulpDebReleaseFileContext(PulpContentContext):
Expand All @@ -87,6 +102,8 @@ class PulpDebReleaseFileContext(PulpContentContext):
HREF = "deb_release_file_href"
ID_PREFIX = "content_deb_release_files"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "release_file"


class PulpDebReleaseContext(PulpContentContext):
Expand All @@ -95,6 +112,8 @@ class PulpDebReleaseContext(PulpContentContext):
HREF = "deb_release_href"
ID_PREFIX = "content_deb_releases"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "release"


class PulpAptDistributionContext(PulpEntityContext):
Expand All @@ -103,6 +122,8 @@ class PulpAptDistributionContext(PulpEntityContext):
HREF = "deb_apt_distribution_href"
ID_PREFIX = "distributions_deb_apt"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "apt"


class PulpAptPublicationContext(PulpEntityContext):
Expand All @@ -111,9 +132,11 @@ class PulpAptPublicationContext(PulpEntityContext):
HREF = "deb_apt_publication_href"
ID_PREFIX = "publications_deb_apt"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "apt"

def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
body = super().preprocess_body(body)
def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> EntityDefinition:
body = super().preprocess_entity(body)
version = body.pop("version", None)
if version is not None:
repository_href = body.pop("repository")
Expand All @@ -128,9 +151,11 @@ class PulpVerbatimPublicationContext(PulpEntityContext):
HREF = "deb_verbatim_publication_href"
ID_PREFIX = "publications_deb_verbatim"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "verbatim"

def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
body = super().preprocess_body(body)
def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> EntityDefinition:
body = super().preprocess_entity(body)
fields = self.APT_ONLY.intersection(body.keys())
if fields:
raise PulpException(
Expand All @@ -150,6 +175,8 @@ class PulpAptRemoteContext(PulpEntityContext):
ID_PREFIX = "remotes_deb_apt"
NEEDS_PLUGINS = [PluginRequirement("deb")]
NULLABLES = {"architectures", "components"}
PLUGIN = "deb"
RESOURCE_TYPE = "apt"

@staticmethod
def tuple_to_whitespace_separated_string(field_name: str, body: EntityDefinition) -> None:
Expand All @@ -165,8 +192,8 @@ def tuple_to_whitespace_separated_string(field_name: str, body: EntityDefinition
string_field = " ".join(field).strip()
body[field_name] = string_field if string_field else None

def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:
body = super().preprocess_body(body)
def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> EntityDefinition:
body = super().preprocess_entity(body)
self.tuple_to_whitespace_separated_string("distributions", body)
if "distributions" in body and body["distributions"] is None:
raise PulpException("Must have at least one distribution for remote.")
Expand All @@ -188,7 +215,6 @@ class PulpAptRepositoryContext(PulpRepositoryContext):
HREF = "deb_apt_repository_href"
ID_PREFIX = "repositories_deb_apt"
NEEDS_PLUGINS = [PluginRequirement("deb")]
PLUGIN = "deb"
RESOURCE_TYPE = "apt"
VERSION_CONTEXT = PulpAptRepositoryVersionContext


registered_repository_contexts["deb:apt"] = PulpAptRepositoryContext
2 changes: 1 addition & 1 deletion pulp-glue-deb/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
"Typing :: Typed",
]
dependencies = [
"pulp-glue>=0.18.2,<0.25",
"pulp-glue>=0.23.2,<0.26",
]

[project.urls]
Expand Down
18 changes: 7 additions & 11 deletions pulpcore/cli/deb/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
pulp_option,
repository_content_command,
repository_href_option,
repository_option,
repository_lookup_option,
resource_option,
retained_versions_option,
show_command,
Expand Down Expand Up @@ -93,7 +93,7 @@ def _content_callback(ctx: click.Context, param: click.Parameter, value: Any) ->
default_plugin="deb",
default_type="apt",
context_table={"deb:apt": PulpAptRemoteContext},
needs_plugins=[PluginRequirement("deb", "2.12.0")],
needs_plugins=[PluginRequirement("deb", specifier=">=2.12.0")],
)


Expand All @@ -115,13 +115,13 @@ def repository(ctx: click.Context, pulp_ctx: PulpCLIContext, repo_type: str) ->


lookup_options = [href_option, name_option]
nested_lookup_options = [repository_href_option, repository_option]
nested_lookup_options = [repository_href_option, repository_lookup_option]
update_options = [
click.option("--description"),
remote_option,
# pulp_option(
# "--autopublish/--no-autopublish",
# needs_plugins=[PluginRequirement("deb", "999.0.0")],
# needs_plugins=[PluginRequirement("deb", specifier=">=999.0.0")],
# default=None,
# ),
retained_versions_option,
Expand Down Expand Up @@ -166,7 +166,7 @@ def repository(ctx: click.Context, pulp_ctx: PulpCLIContext, repo_type: str) ->
"since the last sync. This greately improves re-sync performance in such cases. Disable if "
"the sync result does not match expectations."
),
needs_plugins=[PluginRequirement("deb", min="2.20.0.dev")],
needs_plugins=[PluginRequirement("deb", specifier=">=2.20.0")],
)
@pass_repository_context
def sync(
Expand All @@ -176,7 +176,6 @@ def sync(
optimize: Optional[bool],
) -> None:
repository = repository_ctx.entity
repository_href = repository_ctx.pulp_href

body: Dict[str, Any] = {}

Expand All @@ -187,7 +186,7 @@ def sync(
body["optimize"] = optimize

if isinstance(remote, PulpEntityContext):
body["remote"] = remote.pulp_href
body["remote"] = remote
elif repository["remote"] is None:
raise click.ClickException(
_(
Expand All @@ -196,7 +195,4 @@ def sync(
).format(name=repository["name"])
)

repository_ctx.sync(
href=repository_href,
body=body,
)
repository_ctx.sync(body=body)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers=[
"Typing :: Typed",
]
dependencies = [
"pulp-cli>=0.18.2,<0.25",
"pulp-cli>=0.23.2,<0.26",
"pulp-glue-deb==0.1.0.dev",
]

Expand Down

0 comments on commit 6ff1851

Please sign in to comment.