Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of contains/startswith to RPM content #1040

Merged
merged 1 commit into from
Aug 16, 2024
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
7 changes: 7 additions & 0 deletions CHANGES/687.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Added the following filters to `pulp rpm content list`:
- `--arch-contains`
- `--arch-startswith`
- `--name-contains`
- `--name-startswith`
- `--release-contains`
- `--release-startswith`
12 changes: 12 additions & 0 deletions pulp-glue/pulp_glue/rpm/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> En
self.pulp_ctx.needs_plugin(PluginRequirement("rpm", specifier=">=3.18.0"))
else:
PulpException(_("--relative-path must be provided"))
contains_startswith = [
"name__contains",
"name__startswith",
"release__contains",
"release__startswith",
"arch__contains",
"arch__startswith",
]
if any(k in body for k in contains_startswith):
self.pulp_ctx.needs_plugin(
PluginRequirement("rpm", specifier=">=3.20.0", feature=_("substring filters"))
)
return body


Expand Down
49 changes: 46 additions & 3 deletions pulpcore/cli/rpm/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from uuid import uuid4

import click
from pulp_glue.common.context import PulpContentContext, PulpEntityContext
from pulp_glue.common.context import PluginRequirement, PulpContentContext, PulpEntityContext
from pulp_glue.common.i18n import get_translation
from pulp_glue.core.context import PulpArtifactContext
from pulp_glue.rpm.context import (
Expand Down Expand Up @@ -113,9 +113,25 @@ def content() -> None:
pulp_option("--repository-version"),
pulp_option("--arch", allowed_with_contexts=(PulpRpmPackageContext,)),
pulp_option(
"--arch-in", "arch__in", multiple=True, allowed_with_contexts=(PulpRpmPackageContext,)
"--arch-contains",
"arch__contains",
allowed_with_contexts=(PulpRpmPackageContext,),
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
),
pulp_option(
"--arch-in",
"arch__in",
multiple=True,
allowed_with_contexts=(PulpRpmPackageContext,),
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
),
pulp_option("--arch-ne", "arch__ne", allowed_with_contexts=(PulpRpmPackageContext,)),
pulp_option(
"--arch-startswith",
"arch__startswith",
allowed_with_contexts=(PulpRpmPackageContext,),
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
),
pulp_option("--epoch", allowed_with_contexts=(PulpRpmPackageContext,)),
pulp_option(
"--epoch-in", "epoch__in", multiple=True, allowed_with_contexts=(PulpRpmPackageContext,)
Expand All @@ -133,6 +149,12 @@ def content() -> None:
allowed_with_contexts=(PulpRpmModulemdDefaultsContext,),
),
pulp_option("--name", allowed_with_contexts=(PulpRpmPackageContext, PulpRpmModulemdContext)),
pulp_option(
"--name-contains",
"name__contains",
allowed_with_contexts=(PulpRpmPackageContext, PulpRpmModulemdContext),
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
),
pulp_option(
"--name-in",
"name__in",
Expand All @@ -144,6 +166,12 @@ def content() -> None:
"name__ne",
allowed_with_contexts=(PulpRpmPackageContext, PulpRpmModulemdContext),
),
pulp_option(
"--name-startswith",
"name__startswith",
allowed_with_contexts=(PulpRpmPackageContext, PulpRpmModulemdContext),
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
),
pulp_option("--package-href", allowed_with_contexts=(PulpRpmPackageContext,)),
pulp_option("--pkgId", allowed_with_contexts=(PulpRpmPackageContext,)),
pulp_option(
Expand All @@ -154,9 +182,24 @@ def content() -> None:
),
pulp_option("--release", allowed_with_contexts=(PulpRpmPackageContext,)),
pulp_option(
"--release-in", "release__in", multiple=True, allowed_with_contexts=(PulpRpmPackageContext,)
"--release-contains",
"release__contains",
allowed_with_contexts=(PulpRpmPackageContext,),
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
),
pulp_option(
"--release-in",
"release__in",
multiple=True,
allowed_with_contexts=(PulpRpmPackageContext,),
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
),
pulp_option("--release-ne", "release__ne", allowed_with_contexts=(PulpRpmPackageContext,)),
pulp_option(
"--release-startswith",
"release__startswith",
allowed_with_contexts=(PulpRpmPackageContext,),
),
pulp_option("--severity", allowed_with_contexts=(PulpRpmAdvisoryContext,)),
pulp_option(
"--severity-in",
Expand Down
5 changes: 5 additions & 0 deletions tests/scripts/pulp_rpm/test_content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ do
fi
done

if pulp debug has-plugin --name "rpm" --specifier ">=3.20.0"
ggainey marked this conversation as resolved.
Show resolved Hide resolved
then
expect_succ pulp rpm content list --name-contains "${RPM_NAME}"
expect_succ pulp rpm content list --name-startswith "${RPM_NAME}"
fi
expect_succ pulp rpm content list --name-in "${RPM_NAME}" --name-in "${RPM2_NAME}"
pulp rpm content list
expect_succ test "$(echo "${OUTPUT}" | jq -r 'length')" -eq 2
Expand Down
Loading