Skip to content
Draft
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
11 changes: 11 additions & 0 deletions pulp-glue/src/pulp_glue/file/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ class PulpFileRemoteContext(PulpRemoteContext):
NEEDS_PLUGINS = [PluginRequirement("file", specifier=">=1.6.0")]


class PulpFileGitRemoteContext(PulpRemoteContext):
PLUGIN = "file"
RESOURCE_TYPE = "git"
ENTITY = _("file git remote")
ENTITIES = _("file git remotes")
HREF = "file_git_remote_href"
ID_PREFIX = "remotes_file_git"
CAPABILITIES = {"roles": [PluginRequirement("file", specifier=">=3.104.0.dev")]}
NEEDS_PLUGINS = [PluginRequirement("file", specifier=">=3.104.0.dev")]


class PulpFileRepositoryVersionContext(PulpRepositoryVersionContext):
HREF = "file_file_repository_version_href"
ID_PREFIX = "repositories_file_file_versions"
Expand Down
18 changes: 14 additions & 4 deletions src/pulpcore/cli/file/remote.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import click

from pulp_glue.common.i18n import get_translation
from pulp_glue.file.context import PulpFileRemoteContext
from pulp_glue.file.context import PulpFileGitRemoteContext, PulpFileRemoteContext

from pulp_cli.generic import (
PulpCLIContext,
Expand All @@ -15,6 +15,7 @@
name_option,
pass_pulp_context,
pulp_group,
pulp_option,
remote_filter_options,
remote_lookup_option,
role_command,
Expand All @@ -31,23 +32,32 @@
"-t",
"--type",
"remote_type",
type=click.Choice(["file"], case_sensitive=False),
type=click.Choice(["file", "git"], case_sensitive=False),
default="file",
)
@pass_pulp_context
@click.pass_context
def remote(ctx: click.Context, pulp_ctx: PulpCLIContext, /, remote_type: str) -> None:
if remote_type == "file":
ctx.obj = PulpFileRemoteContext(pulp_ctx)
elif remote_type == "git":
ctx.obj = PulpFileGitRemoteContext(pulp_ctx)
else:
raise NotImplementedError()


lookup_options = [href_option, name_option, remote_lookup_option]
nested_lookup_options = [remote_lookup_option]
file_remote_options = [
click.option(
"--policy", type=click.Choice(["immediate", "on_demand", "streamed"], case_sensitive=False)
pulp_option(
"--policy",
type=click.Choice(["immediate", "on_demand", "streamed"], case_sensitive=False),
allowed_with_contexts=(PulpFileRemoteContext,),
),
pulp_option(
"--git-ref",
help=_("The git ref (branch, tag, or commit hash) to sync from. Defaults to HEAD."),
allowed_with_contexts=(PulpFileGitRemoteContext,),
),
]

Expand Down
6 changes: 5 additions & 1 deletion src/pulpcore/cli/file/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pulp_glue.common.i18n import get_translation
from pulp_glue.file.context import (
PulpFileContentContext,
PulpFileGitRemoteContext,
PulpFileRemoteContext,
PulpFileRepositoryContext,
)
Expand Down Expand Up @@ -54,7 +55,10 @@
"--remote",
default_plugin="file",
default_type="file",
context_table={"file:file": PulpFileRemoteContext},
context_table={
"file:file": PulpFileRemoteContext,
"file:git": PulpFileGitRemoteContext,
},
href_pattern=PulpRemoteContext.HREF_PATTERN,
help=_("Remote used for syncing in the form '[[<plugin>:]<resource_type>:]<name>' or by href."),
)
Expand Down
Loading