Skip to content

Commit 66cdff0

Browse files
committed
Add support of contains/startswith to RPM content
fixes pulp#687
1 parent 838502d commit 66cdff0

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

pulp-glue/pulp_glue/rpm/context.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> En
9494
self.pulp_ctx.needs_plugin(PluginRequirement("rpm", specifier=">=3.18.0"))
9595
else:
9696
PulpException(_("--relative-path must be provided"))
97+
contains_startswith = ["name__contains", "name__startswith", "release__contains", "release__startswith", "arch__contains", "arch__startswith"]
98+
if any(k in body for k in contains_startswith):
99+
self.pulp_ctx.needs_plugin(PluginRequirement("rpm", specifier = ">=3.20.0"))
97100
return body
98101

99102

pulpcore/cli/rpm/content.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import typing as t
22

33
import click
4-
from pulp_glue.common.context import PulpEntityContext
4+
from pulp_glue.common.context import (
5+
PluginRequirement,
6+
PulpEntityContext,
7+
)
58
from pulp_glue.common.i18n import get_translation
69
from pulp_glue.core.context import PulpArtifactContext
710
from pulp_glue.rpm.context import (
@@ -108,10 +111,18 @@ def content() -> None:
108111
exclude_field_option,
109112
pulp_option("--repository-version"),
110113
pulp_option("--arch", allowed_with_contexts=(PulpRpmPackageContext,)),
114+
pulp_option(
115+
"--arch-contains", "arch__contains", allowed_with_contexts=(PulpRpmPackageContext,),
116+
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
117+
),
111118
pulp_option(
112119
"--arch-in", "arch__in", multiple=True, allowed_with_contexts=(PulpRpmPackageContext,)
113120
),
114121
pulp_option("--arch-ne", "arch__ne", allowed_with_contexts=(PulpRpmPackageContext,)),
122+
pulp_option(
123+
"--arch-startswith", "arch__startswith", allowed_with_contexts=(PulpRpmPackageContext,),
124+
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
125+
),
115126
pulp_option("--epoch", allowed_with_contexts=(PulpRpmPackageContext,)),
116127
pulp_option(
117128
"--epoch-in", "epoch__in", multiple=True, allowed_with_contexts=(PulpRpmPackageContext,)
@@ -129,6 +140,12 @@ def content() -> None:
129140
allowed_with_contexts=(PulpRpmModulemdDefaultsContext,),
130141
),
131142
pulp_option("--name", allowed_with_contexts=(PulpRpmPackageContext, PulpRpmModulemdContext)),
143+
pulp_option(
144+
"--name-contains",
145+
"name__contains",
146+
allowed_with_contexts=(PulpRpmPackageContext, PulpRpmModulemdContext),
147+
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
148+
),
132149
pulp_option(
133150
"--name-in",
134151
"name__in",
@@ -140,6 +157,12 @@ def content() -> None:
140157
"name__ne",
141158
allowed_with_contexts=(PulpRpmPackageContext, PulpRpmModulemdContext),
142159
),
160+
pulp_option(
161+
"--name-startswith",
162+
"name__startswith",
163+
allowed_with_contexts=(PulpRpmPackageContext, PulpRpmModulemdContext),
164+
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
165+
),
143166
pulp_option("--package-href", allowed_with_contexts=(PulpRpmPackageContext,)),
144167
pulp_option("--pkgId", allowed_with_contexts=(PulpRpmPackageContext,)),
145168
pulp_option(
@@ -149,10 +172,20 @@ def content() -> None:
149172
allowed_with_contexts=(PulpRpmPackageContext,),
150173
),
151174
pulp_option("--release", allowed_with_contexts=(PulpRpmPackageContext,)),
175+
pulp_option(
176+
"--release-contains", "release__contains", allowed_with_contexts=(PulpRpmPackageContext,),
177+
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
178+
),
152179
pulp_option(
153180
"--release-in", "release__in", multiple=True, allowed_with_contexts=(PulpRpmPackageContext,)
154181
),
155182
pulp_option("--release-ne", "release__ne", allowed_with_contexts=(PulpRpmPackageContext,)),
183+
pulp_option(
184+
"--release-startswith",
185+
"release__startswith",
186+
allowed_with_contexts=(PulpRpmPackageContext,),
187+
needs_plugins=[PluginRequirement("rpm", specifier=">=3.20.0")],
188+
),
156189
pulp_option("--severity", allowed_with_contexts=(PulpRpmAdvisoryContext,)),
157190
pulp_option(
158191
"--severity-in",

tests/scripts/pulp_rpm/test_content.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ do
126126
done
127127

128128
expect_succ pulp rpm content list --name-in "${RPM_NAME}" --name-in "${RPM2_NAME}"
129+
expect_succ pulp rpm content list --name-contains "${RPM_NAME}"
130+
expect_succ pulp rpm content list --name-startswith "${RPM_NAME}"
129131
pulp rpm content list
130132
expect_succ test "$(echo "${OUTPUT}" | jq -r 'length')" -eq 2
131133

0 commit comments

Comments
 (0)