Skip to content

Commit

Permalink
Bump the pulp-cli requirement
Browse files Browse the repository at this point in the history
This requirement is necessary to bump in order to install
pulp-cli-glue==0.25.

[noissue]
  • Loading branch information
lubosmj committed Apr 29, 2024
1 parent 9d8f6db commit 6316918
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pulp-glue-ostree/pulp_glue/ostree/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.0.dev"
__version__ = "0.4.0.dev"
38 changes: 24 additions & 14 deletions pulp-glue-ostree/pulp_glue/ostree/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,50 @@
PulpRemoteContext,
PulpRepositoryContext,
PulpRepositoryVersionContext,
registered_repository_contexts,
)


class PulpOstreeCommitContentContext(PulpContentContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "commit"
ENTITY = _("commit content")
ENTITIES = _("commit content")
HREF = "ostree_ostree_commit_href"
ID_PREFIX = "content_ostree_commits"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]


class PulpOstreeRefContentContext(PulpContentContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "ref"
ENTITY = _("ref content")
ENTITIES = _("ref content")
HREF = "ostree_ostree_ref_href"
ID_PREFIX = "content_ostree_refs"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]


class PulpOstreeConfigContentContext(PulpContentContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "config"
ENTITY = _("config content")
ENTITIES = _("config content")
HREF = "ostree_ostree_config_href"
ID_PREFIX = "content_ostree_configs"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]


class PulpOstreeDistributionContext(PulpEntityContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "ostree"
ENTITY = _("ostree distribution")
ENTITIES = _("ostree distributions")
HREF = "ostree_ostree_distribution_href"
ID_PREFIX = "distributions_ostree_ostree"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]

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, partial)
version = body.pop("version", None)
if version is not None:
repository_href = body.pop("repository")
Expand All @@ -54,29 +61,35 @@ def preprocess_body(self, body: EntityDefinition) -> EntityDefinition:


class PulpOstreeRemoteContext(PulpRemoteContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "ostree"
ENTITY = _("ostree remote")
ENTITIES = _("ostree remotes")
HREF = "ostree_ostree_remote_href"
ID_PREFIX = "remotes_ostree_ostree"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]


class PulpOstreeRepositoryVersionContext(PulpRepositoryVersionContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "ostree"
HREF = "ostree_ostree_repository_version_href"
ID_PREFIX = "repositories_ostree_ostree_versions"
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]


class PulpOstreeRepositoryContext(PulpRepositoryContext):
PLUGIN = "ostree"
RESOURCE_TYPE = "ostree"
HREF = "ostree_ostree_repository_href"
ID_PREFIX = "repositories_ostree_ostree"
IMPORT_ALL_ID: ClassVar[str] = "repositories_ostree_ostree_import_all"
IMPORT_COMMITS_ID: ClassVar[str] = "repositories_ostree_ostree_import_commits"
VERSION_CONTEXT = PulpOstreeRepositoryVersionContext
NEEDS_PLUGINS = [PluginRequirement("ostree", min="2.0.0")]
NEEDS_PLUGINS = [PluginRequirement("ostree", specifier=">=2.0.0")]
CAPABILITIES = {
"sync": [PluginRequirement("ostree")],
"import_all": [PluginRequirement("ostree", min="2.0.0")],
"import_all": [PluginRequirement("ostree", specifier=">=2.0.0")],
"import_commits": [PluginRequirement("ostree")],
}

Expand Down Expand Up @@ -110,6 +123,3 @@ def import_commits(
parameters={self.HREF: href},
body=body,
)


registered_repository_contexts["ostree:ostree"] = PulpOstreeRepositoryContext
2 changes: 1 addition & 1 deletion pulp-glue-ostree/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.20.0,<0.26",
"pulp-glue>=0.23.1,<0.26",
]

[project.urls]
Expand Down
4 changes: 4 additions & 0 deletions pulpcore/cli/ostree/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from typing import Any

import click
from pulp_glue.common.i18n import get_translation
from pulpcore.cli.common.generic import pulp_group

from pulpcore.cli.ostree.distribution import distribution
from pulpcore.cli.ostree.remote import remote
from pulpcore.cli.ostree.repository import repository

translation = get_translation(__package__)
_ = translation.gettext

__version__ = "0.4.0.dev"


Expand Down
23 changes: 12 additions & 11 deletions pulpcore/cli/ostree/distribution.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from gettext import gettext as _
from typing import Optional, Union, cast

import click
from pulp_glue.common.context import EntityDefinition, PluginRequirement, PulpEntityContext
from pulp_glue.common.i18n import get_translation
from pulp_glue.ostree.context import PulpOstreeDistributionContext, PulpOstreeRepositoryContext
from pulpcore.cli.common.generic import (
PulpCLIContext,
Expand All @@ -21,6 +21,10 @@
show_command,
)

translation = get_translation(__package__)
_ = translation.gettext


repository_option = resource_option(
"--repository",
default_plugin="ostree",
Expand Down Expand Up @@ -82,7 +86,6 @@ def update(
assert isinstance(distribution_ctx, PulpOstreeDistributionContext)

distribution: EntityDefinition = distribution_ctx.entity
href: str = distribution_ctx.pulp_href
body: EntityDefinition = {}

if base_path is not None:
Expand All @@ -98,28 +101,26 @@ def update(
repository = cast(PulpEntityContext, repository)
if version is not None:
if distribution["repository"]:
if pulp_ctx.has_plugin(PluginRequirement("ostree", min="2.0.0")):
if pulp_ctx.has_plugin(PluginRequirement("ostree", specifier=">=2.0.0")):
body["repository"] = ""
else:
distribution_ctx.update(href, body={"repository": ""}, non_blocking=True)
distribution_ctx.update(body={"repository": ""}, non_blocking=True)

body["repository_version"] = f"{repository.pulp_href}versions/{version}/"
else:
if distribution["repository_version"]:
if pulp_ctx.has_plugin(PluginRequirement("ostree", min="2.0.0")):
if pulp_ctx.has_plugin(PluginRequirement("ostree", specifier=">=2.0.0")):
body["repository_version"] = ""
else:
distribution_ctx.update(
href, body={"repository_version": ""}, non_blocking=True
)
distribution_ctx.update(body={"repository_version": ""}, non_blocking=True)
body["repository"] = repository.pulp_href
elif version is not None:
# keep current repository, change version
if distribution["repository"]:
if pulp_ctx.has_plugin(PluginRequirement("ostree", min="2.0.0")):
if pulp_ctx.has_plugin(PluginRequirement("ostree", specifier=">=2.0.0")):
body["repository"] = ""
else:
distribution_ctx.update(href, body={"repository": ""}, non_blocking=True)
distribution_ctx.update(body={"repository": ""}, non_blocking=True)

body["repository_version"] = f'{distribution["repository"]}versions/{version}/'
elif distribution["repository_version"]:
Expand All @@ -132,4 +133,4 @@ def update(
"please specify the repository to use with --repository"
).format(distribution=distribution["name"])
)
distribution_ctx.update(href, body=body)
distribution_ctx.update(body=body)
4 changes: 4 additions & 0 deletions pulpcore/cli/ostree/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any

import click
from pulp_glue.common.i18n import get_translation
from pulp_glue.ostree.context import PulpOstreeRemoteContext
from pulpcore.cli.common.generic import (
PulpCLIContext,
Expand All @@ -19,6 +20,9 @@
update_command,
)

translation = get_translation(__package__)
_ = translation.gettext


@click.group()
@click.option(
Expand Down
16 changes: 9 additions & 7 deletions pulpcore/cli/ostree/repository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from gettext import gettext as _
from typing import IO, Any, Dict, Optional

import click
Expand All @@ -9,6 +8,8 @@
PulpRemoteContext,
PulpRepositoryContext,
)
from pulp_glue.common.i18n import get_translation
from pulp_glue.core.context import PulpArtifactContext
from pulp_glue.ostree.context import (
PulpOstreeCommitContentContext,
PulpOstreeConfigContentContext,
Expand All @@ -32,16 +33,18 @@
pulp_option,
repository_content_command,
repository_href_option,
repository_option,
repository_lookup_option,
resource_option,
retained_versions_option,
show_command,
update_command,
version_command,
)
from pulpcore.cli.core.context import PulpArtifactContext
from pulpcore.cli.core.generic import task_command

translation = get_translation(__package__)
_ = translation.gettext

remote_option = resource_option(
"--remote",
default_plugin="ostree",
Expand Down Expand Up @@ -70,7 +73,7 @@ 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,
Expand Down Expand Up @@ -168,7 +171,6 @@ def sync(
raise click.ClickException(_("Repository type does not support sync."))

repository = repository_ctx.entity
repository_href = repository_ctx.pulp_href

body: Dict[str, Any] = {}

Expand All @@ -182,7 +184,7 @@ def sync(
).format(name=repository["name"])
)

repository_ctx.sync(href=repository_href, body=body)
repository_ctx.sync(body=body)


@repository.command(help=_("Import all refs and commits from a tarball"))
Expand Down Expand Up @@ -256,7 +258,7 @@ def import_commits(
"ref": ref,
}

if pulp_ctx.has_plugin(PluginRequirement("ostree", max="2.0.0")):
if pulp_ctx.has_plugin(PluginRequirement("ostree", specifier=">=2.0.0")):
if not all((ref, parent_commit)) and any((ref, parent_commit)):
raise click.ClickException(
"Please specify both the ref and parent_commit if you want to add new child "
Expand Down
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.20.0,<0.25",
"pulp-cli>=0.23.1,<0.26",
"pulp-glue-ostree==0.4.0.dev",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cleanup() {
trap cleanup EXIT

# workflow fixed in 2.2, https://github.com/pulp/pulp_ostree/issues/279
if pulp debug has-plugin --name "ostree" --min-version "2.2.0"
if pulp debug has-plugin --name "ostree" --specifier ">=2.2.0"
then
workdir=$(mktemp -d)
cd "${workdir}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tar --exclude="index.html" -cvf "fixtures_small_repo.tar" -C "$OSTREE_DOWNLOADED

expect_succ pulp ostree repository create --name "cli_test_ostree_repository"

if pulp debug has-plugin --name "ostree" --min-version "2.0.0"
if pulp debug has-plugin --name "ostree" --specifier ">=2.0.0"
then
expect_succ pulp ostree repository import-all --name "cli_test_ostree_repository" \
--file "fixtures_small_repo.tar" \
Expand All @@ -39,7 +39,7 @@ ostree --repo=small init --mode=archive
ostree --repo=small commit --branch "stable" tree/ --parent="$LATEST_COMMIT"
tar -cvf "fixtures_small_repo_new_commit.tar" "small"

if pulp debug has-plugin --name "ostree" --min-version "2.0.0"
if pulp debug has-plugin --name "ostree" --specifier ">=2.0.0"
then
expect_succ pulp ostree repository import-commits --name "cli_test_ostree_repository" \
--file "fixtures_small_repo_new_commit.tar" \
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/pulp_ostree/test_importing_two_refs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cleanup() {
trap cleanup EXIT

# workflow fixed in 2.2, https://github.com/pulp/pulp_ostree/issues/277
if pulp debug has-plugin --name "ostree" --min-version "2.2.0"
if pulp debug has-plugin --name "ostree" --specifier ">=2.2.0"
then
workdir=$(mktemp -d)
cd "${workdir}"
Expand Down
4 changes: 2 additions & 2 deletions tests/scripts/pulp_ostree/test_syncing_and_publishing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cleanup() {
}
trap cleanup EXIT

if pulp debug has-plugin --name "ostree" --min-version "2.0.0"
if pulp debug has-plugin --name "ostree" --specifier ">=2.0.0"
then
expect_succ pulp ostree remote create --name "cli_test_ostree_remote" \
--url "$OSTREE_REMOTE_URL" \
Expand All @@ -33,7 +33,7 @@ expect_succ pulp ostree distribution create --name "cli_test_ostree_distro" \
--base-path "cli_test_ostree_distro" \
--repository "cli_test_ostree_repository"

if pulp debug has-plugin --name "ostree" --min-version "2.0.0"
if pulp debug has-plugin --name "ostree" --specifier ">=2.0.0"
then
BASE_PATH=$(pulp ostree distribution show --name "cli_test_ostree_distro" | jq -r ".base_url")

Expand Down

0 comments on commit 6316918

Please sign in to comment.