Esempio n. 1
0
        type=int,
        help=_("a repository version number, leave blank for latest")),
    click.option(
        "-t",
        "--repository-type",
        "repository_type",
        type=click.Choice(["container", "push"], case_sensitive=False),
        default="container",
        is_eager=True,
        expose_value=False,
        callback=_repository_type_callback,
    ),
]

distribution.add_command(list_command())
distribution.add_command(show_command(decorators=lookup_options))
distribution.add_command(create_command(decorators=create_options))
distribution.add_command(destroy_command(decorators=lookup_options))


@distribution.command()
@href_option
@name_option
@click.option("--base-path")
@click.option("--repository", callback=_repository_callback)
@click.option("--version",
              type=int,
              help=_("a repository version number, leave blank for latest"))
@click.option(
    "-t",
    "--repository-type",
Esempio n. 2
0
    default="rpm",
)
@pass_pulp_context
@click.pass_context
def remote(ctx: click.Context, pulp_ctx: PulpContext,
           remote_type: str) -> None:
    if remote_type == "rpm":
        ctx.obj = PulpRpmRemoteContext(pulp_ctx)
    else:
        raise NotImplementedError()


lookup_options = [href_option, name_option]
rpm_remote_options = [
    click.option("--policy",
                 type=click.Choice(["immediate", "on_demand", "streamed"],
                                   case_sensitive=False)),
    click.option("--sles-auth-token"),
]

remote.add_command(list_command(decorators=[label_select_option]))
remote.add_command(show_command(decorators=lookup_options))
remote.add_command(
    create_command(decorators=common_remote_create_options +
                   rpm_remote_options))
remote.add_command(
    update_command(decorators=lookup_options + common_remote_update_options +
                   rpm_remote_options))
remote.add_command(destroy_command(decorators=lookup_options))
remote.add_command(label_command())
Esempio n. 3
0
    "publication_type",
    type=click.Choice(["rpm"], case_sensitive=False),
    default="rpm",
)
@pass_pulp_context
@click.pass_context
def publication(ctx: click.Context, pulp_ctx: PulpContext, publication_type: str) -> None:
    if publication_type == "rpm":
        ctx.obj = PulpRpmPublicationContext(pulp_ctx)
    else:
        raise NotImplementedError()


lookup_options = [href_option]
create_options = [
    resource_option(
        "--repository",
        default_plugin="rpm",
        default_type="rpm",
        context_table={"rpm:rpm": PulpRpmRepositoryContext},
    ),
    click.option(
        "--version", type=int, help=_("a repository version number, leave blank for latest")
    ),
]

publication.add_command(list_command(decorators=publication_filter_options))
publication.add_command(show_command(decorators=lookup_options))
publication.add_command(create_command(decorators=create_options))
publication.add_command(destroy_command(decorators=lookup_options))
Esempio n. 4
0
    The argument prefixed with the '@' can be the path to a JSON file with a list of objects."""
        ),
    ),
    click.option(
        "--remove-content",
        callback=content_json_callback,
        help=_(
            """JSON string with a list of objects to remove from the repository.
    Each object should have the key: "filename"
    The argument prefixed with the '@' can be the path to a JSON file with a list of objects."""
        ),
    ),
]

repository.add_command(list_command(decorators=[label_select_option]))
repository.add_command(show_command(decorators=lookup_options))
repository.add_command(create_command(decorators=create_options))
repository.add_command(update_command(decorators=lookup_options + update_options))
repository.add_command(destroy_command(decorators=lookup_options))
repository.add_command(task_command(decorators=nested_lookup_options))
repository.add_command(version_command(decorators=nested_lookup_options))
repository.add_command(label_command(decorators=nested_lookup_options))
repository.add_command(
    repository_content_command(
        contexts={"package": PulpPythonContentContext},
        add_decorators=[package_option],
        remove_decorators=[package_option],
        modify_decorators=modify_options,
    )
)
Esempio n. 5
0
    click.option(
        "--sha256",
        "artifact",
        required=True,
        help=_("Digest of the artifact to use"),
        callback=_sha256_artifact_callback,
    ),
]
content.add_command(
    list_command(
        decorators=[
            click.option("--filename", type=str),
        ]
    )
)
content.add_command(show_command(decorators=[href_option]))
content.add_command(create_command(decorators=create_options))


@content.command()
@click.option("--relative-path", required=True, help=_("Exact name of file"))
@click.option("--file", type=click.File("rb"), required=True, help=_("Path to file"))
@click.option(
    "--chunk-size", default=1000000, type=int, help=_("Chunk size in bytes (default is 1 MB)")
)
@pass_entity_context
@pass_pulp_context
def upload(
    pulp_ctx: PulpContext,
    entity_ctx: PulpPythonContentContext,
    relative_path: str,
Esempio n. 6
0
    href_option,
    list_command,
    show_command,
)
from pulpcore.cli.migration.context import PulpMigrationPlanContext


@click.group()
@pass_pulp_context
@click.pass_context
def plan(ctx: click.Context, pulp_ctx: PulpContext) -> None:
    ctx.obj = PulpMigrationPlanContext(pulp_ctx)


plan.add_command(list_command())
plan.add_command(show_command(decorators=[href_option]))
plan.add_command(destroy_command(decorators=[href_option]))

create_options = [click.option("--plan", required=True, help="Migration plan in JSON format")]
plan.add_command(create_command(decorators=create_options))


@plan.command(help="Run migration plan")
@click.option("--href", required=True, help="HREF of the plan")
@pass_entity_context
def run(plan_ctx: PulpMigrationPlanContext, href: str) -> None:
    plan_ctx.run(href)


@plan.command(help="Reset Pulp 3 data for plugins specified in the migration plan")
@click.option("--href", required=True, help="HREF of the plan")
Esempio n. 7
0
_ = gettext.gettext


@click.group()
@pass_pulp_context
@click.pass_context
def artifact(ctx: click.Context, pulp_ctx: PulpContext) -> None:
    ctx.obj = PulpArtifactContext(pulp_ctx)


filter_options = [click.option("--sha256")]
lookup_options = [href_option]

artifact.add_command(list_command(decorators=filter_options))
artifact.add_command(show_command(decorators=lookup_options))


@artifact.command()
@click.option("--file", type=click.File("rb"), required=True)
@click.option(
    "--chunk-size", default=1000000, type=int, help=_("Chunk size in bytes (default is 1 MB)")
)
@pass_entity_context
@pass_pulp_context
def upload(
    pulp_ctx: PulpContext,
    artifact_ctx: PulpArtifactContext,
    file: IO[bytes],
    chunk_size: int,
) -> None:
Esempio n. 8
0
import click

from pulpcore.cli.common.context import PulpContext, pass_pulp_context
from pulpcore.cli.common.generic import href_option, list_command, name_option, show_command
from pulpcore.cli.common.i18n import get_translation
from pulpcore.cli.core.context import PulpWorkerContext

translation = get_translation(__name__)
_ = translation.gettext


@click.group()
@pass_pulp_context
@click.pass_context
def worker(ctx: click.Context, pulp_ctx: PulpContext) -> None:
    ctx.obj = PulpWorkerContext(pulp_ctx)


filter_options = [
    click.option("--name"),
    click.option("--name-contains", "name__contains"),
    click.option("--name-icontains", "name__icontains"),
    click.option("--missing/--not-missing", default=None),
    click.option("--online/--not-online", default=None),
]

worker.add_command(list_command(decorators=filter_options))
worker.add_command(show_command(decorators=[href_option, name_option]))
Esempio n. 9
0
        group=["name", "version"],
        expose_value=False,
        cls=GroupOption,
    ),
    click.option(
        "--version",
        help=_("Version of {entity}"),
        group=["namespace", "name"],
        expose_value=False,
        cls=GroupOption,
    ),
    href_option,
]

content.add_command(list_command(decorators=list_options + fields_options))
content.add_command(show_command(decorators=lookup_options))


@content.command()
@click.option("--file", type=click.File("rb"), required=True)
@chunk_size_option
@pulp_option("--name",
             help=_("Name of {entity}"),
             allowed_with_contexts=role_context,
             required=True)
@pulp_option(
    "--namespace",
    help=_("Namespace of {entity}"),
    allowed_with_contexts=role_context,
    required=True,
)
Esempio n. 10
0
_ = gettext.gettext


@click.group()
@click.option(
    "-t",
    "--type",
    "namespace_type",
    type=click.Choice(["container"], case_sensitive=False),
    default="container",
)
@pass_pulp_context
@click.pass_context
def namespace(ctx: click.Context, pulp_ctx: PulpContext,
              namespace_type: str) -> None:
    if namespace_type == "container":
        ctx.obj = PulpContainerNamespaceContext(pulp_ctx)
    else:
        raise NotImplementedError()


lookup_options = [href_option, name_option]
create_options = [
    click.option("--name", required=True),
]

namespace.add_command(list_command())
namespace.add_command(show_command(decorators=lookup_options))
namespace.add_command(create_command(decorators=create_options))
namespace.add_command(destroy_command(decorators=lookup_options))
Esempio n. 11
0
    if value is not None:
        entity_ctx = ctx.find_object(PulpEntityContext)
        assert entity_ctx is not None
        entity_ctx.entity = {"viewset_name": value}
    return value


@click.group()
@pass_pulp_context
@click.pass_context
def access_policy(ctx: click.Context, pulp_ctx: PulpContext) -> None:
    ctx.obj = PulpAccessPolicyContext(pulp_ctx)


lookup_options = [
    href_option,
    click.option("--viewset-name",
                 callback=_vs_name_callback,
                 expose_value=False),
]

update_options = [
    click.option("--statements", callback=load_json_callback),
    click.option("--permissions-assignment", callback=load_json_callback),
]

access_policy.add_command(list_command())
access_policy.add_command(show_command(decorators=lookup_options))
access_policy.add_command(
    update_command(decorators=lookup_options + update_options))
Esempio n. 12
0
import click

from pulpcore.cli.common.context import PulpContext, pass_pulp_context
from pulpcore.cli.common.generic import href_option, list_command, name_option, show_command
from pulpcore.cli.common.i18n import get_translation
from pulpcore.cli.core.context import PulpSigningServiceContext

translation = get_translation(__name__)
_ = translation.gettext


@click.group()
@pass_pulp_context
@click.pass_context
def signing_service(ctx: click.Context, pulp_ctx: PulpContext) -> None:
    ctx.obj = PulpSigningServiceContext(pulp_ctx)


lookup_options = [
    name_option,
    href_option,
]

signing_service.add_command(list_command())
signing_service.add_command(show_command(decorators=lookup_options))
Esempio n. 13
0
import gettext

import click

from pulpcore.cli.common.context import PulpContext, pass_pulp_context
from pulpcore.cli.common.generic import href_option, list_command, show_command
from pulpcore.cli.core.context import PulpTaskGroupContext

_ = gettext.gettext


@click.group()
@pass_pulp_context
@click.pass_context
def task_group(ctx: click.Context, pulp_ctx: PulpContext) -> None:
    ctx.obj = PulpTaskGroupContext(pulp_ctx)


task_group.add_command(list_command())
task_group.add_command(show_command(decorators=[href_option]))