Exemplo n.º 1
0
def upload(
    pulp_ctx: PulpContext,
    artifact_ctx: PulpArtifactContext,
    file: IO[bytes],
    chunk_size: int,
) -> None:
    artifact_href = artifact_ctx.upload(file, chunk_size)
    result = artifact_ctx.show(artifact_href)
    pulp_ctx.output_result(result)
Exemplo n.º 2
0
def _sha256_artifact_callback(
        ctx: click.Context, param: click.Parameter,
        value: Optional[str]) -> Optional[Union[str, PulpEntityContext]]:
    # Pass None and "" verbatim
    if value:
        pulp_ctx: PulpContext = ctx.find_object(PulpContext)
        return PulpArtifactContext(pulp_ctx, entity={"sha256": value})
    return value
Exemplo n.º 3
0
def upload(
    pulp_ctx: PulpContext,
    entity_ctx: PulpPythonContentContext,
    relative_path: str,
    file: IO[bytes],
    chunk_size: int,
) -> None:
    """Create a Python package content unit through uploading a file"""
    artifact_href = PulpArtifactContext(pulp_ctx).upload(file, chunk_size)
    content = {"relative_path": relative_path, "artifact": artifact_href}
    result = entity_ctx.create(body=content)
    pulp_ctx.output_result(result)
Exemplo n.º 4
0
def upload(
    pulp_ctx: PulpContext,
    entity_ctx: PulpFileContentContext,
    relative_path: str,
    file: IO[bytes],
    chunk_size: int,
) -> None:
    """Create a file content unit by uploading a file"""
    artifact_href = PulpArtifactContext(pulp_ctx).upload(file, chunk_size)
    content = {"relative_path": relative_path, "artifact": artifact_href}
    task = entity_ctx.create(body=content)
    result = entity_ctx.show(task["created_resources"][0])
    pulp_ctx.output_result(result)
Exemplo n.º 5
0
def create(
    pulp_ctx: PulpContext,
    entity_ctx: PulpFileContentContext,
    relative_path: str,
    sha256: str,
) -> None:
    """Create a file content unit from an existing artifact"""
    artifact = PulpArtifactContext(pulp_ctx).find(sha256=sha256)
    content = {
        "relative_path": relative_path,
        "artifact": artifact["pulp_href"]
    }
    task = entity_ctx.create(body=content)
    result = entity_ctx.show(task["created_resources"][0])
    pulp_ctx.output_result(result)
Exemplo n.º 6
0
def upload(
    pulp_ctx: PulpContext,
    content_ctx: Union[PulpAnsibleRoleContext,
                       PulpAnsibleCollectionVersionContext],
    file: IO[bytes],
    chunk_size: int,
    **kwargs: Any,
) -> None:

    if isinstance(content_ctx, PulpAnsibleRoleContext):
        artifact_href = PulpArtifactContext(pulp_ctx).upload(file, chunk_size)
        body = {"artifact": artifact_href}
        body.update(kwargs)
        result = content_ctx.create(body=body)
        pulp_ctx.output_result(result)
    else:
        result = content_ctx.upload(file=file)
        pulp_ctx.output_result(result)
Exemplo n.º 7
0
def artifact(ctx: click.Context, pulp_ctx: PulpContext) -> None:
    ctx.obj = PulpArtifactContext(pulp_ctx)