Skip to content

Commit

Permalink
Added content redirect content guard
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
mdellweg committed Jun 13, 2022
1 parent 819fa20 commit 58a9aa0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/512.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added commands for the redirecting content guard.
24 changes: 22 additions & 2 deletions pulpcore/cli/core/content_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
update_command,
)
from pulpcore.cli.common.i18n import get_translation
from pulpcore.cli.core.context import PulpContentGuardContext, PulpRbacContentGuardContext
from pulpcore.cli.core.context import (
PulpContentGuardContext,
PulpContentRedirectContentGuardContext,
PulpRbacContentGuardContext,
)

translation = get_translation(__name__)
_ = translation.gettext
Expand All @@ -44,7 +48,7 @@ def content_guard(ctx: click.Context, pulp_ctx: PulpContext) -> None:
@pass_pulp_context
@click.pass_context
def rbac(ctx: click.Context, pulp_ctx: PulpContext) -> None:
pulp_ctx.needs_plugin(PluginRequirement("core", "3.15.0.dev"))
pulp_ctx.needs_plugin(PluginRequirement("core", "3.15.0"))
ctx.obj = PulpRbacContentGuardContext(pulp_ctx)


Expand Down Expand Up @@ -110,3 +114,19 @@ def remove(
href = guard_ctx.entity["pulp_href"]
result = guard_ctx.remove(href=href, users=users, groups=groups)
pulp_ctx.output_result(result)


@content_guard.group()
@pass_pulp_context
@click.pass_context
def redirect(ctx: click.Context, pulp_ctx: PulpContext) -> None:
pulp_ctx.needs_plugin(PluginRequirement("core", "3.18.0"))
ctx.obj = PulpContentRedirectContentGuardContext(pulp_ctx)


redirect.add_command(list_command(decorators=filter_options))
redirect.add_command(create_command(decorators=create_options))
redirect.add_command(show_command(decorators=lookup_options))
redirect.add_command(update_command(decorators=lookup_options))
redirect.add_command(destroy_command(decorators=lookup_options))
redirect.add_command(role_command(decorators=lookup_options))
7 changes: 7 additions & 0 deletions pulpcore/cli/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ class PulpContentGuardContext(PulpEntityContext):
HREF_PATTERN = r"contentguards/(?P<plugin>\w+)/(?P<resource_type>\w+)/"


class PulpContentRedirectContentGuardContext(PulpEntityContext):
ENTITY = "content redirect content guard"
ENTITIES = "content redirect content guards"
HREF = "content_redirect_content_guard_href"
ID_PREFIX = "contentguards_core_content_redirect"


class PulpImporterContext(PulpEntityContext):
ENTITY = _("Pulp importer")
ENTITIES = _("Pulp importers")
Expand Down

0 comments on commit 58a9aa0

Please sign in to comment.