Skip to main content

enterprise_ai.packs.oci

Source: sdks/python/src/enterprise_ai/packs/oci.py. Back to the Python SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Functions​

repository_of​

repository_of(ref: str) -> str

host:5000/packs/hr:1.0.0 or ...@sha256:... -> host:5000/packs/hr.

NameTypeDefaultRequiredDescription
refstryesOCI reference with a tag or a digest.

Returns: str. The repository without tag nor digest; the port of the registry host is kept.

push​

push(ref: str, files: list[Path], plain_http: bool = False) -> dict

oras push: returns {reference, digest, repository}.

NameTypeDefaultRequiredDescription
refstryesTarget reference in the registry, such as <registry>/packs/hr:1.0.0.
fileslist[Path]yesArchive, SBOM and descriptor to upload as layers; they must sit in the same folder.
plain_httpboolFalsenoTalk to the registry over plain HTTP (--plain-http), default False.

Returns: dict. Dict {reference, digest, repository}, digest being the manifest digest.

pull​

pull(ref: str, out_dir: Path, plain_http: bool = False) -> list[Path]

Download an OCI artifact with oras pull into a folder.

NameTypeDefaultRequiredDescription
refstryesReference of the artifact, by tag or by @sha256: digest.
out_dirPathyesDestination folder, created when missing.
plain_httpboolFalsenoTalk to the registry over plain HTTP (--plain-http), default False.

Returns: list[Path]. Sorted paths of the files in out_dir after the pull.

sign_artifact​

sign_artifact(repository: str, digest: str, key: str | Path, password: str | None = None, insecure_registry: bool = False) -> None

Sign <repository>@<digest> with cosign sign --key, without transparency log upload; a failure raises RuntimeError.

NameTypeDefaultRequiredDescription
repositorystryesRepository of the artifact, without tag (see repository_of).
digeststryesManifest digest sha256:<hex> returned by push.
keystr | PathyesPath of the cosign private key (cosign.key).
passwordstr | NoneNonenoPassword of the key; default the COSIGN_PASSWORD environment variable.
insecure_registryboolFalsenoAllow a registry without TLS (--allow-insecure-registry), default False.

Returns: None.

verify_artifact​

verify_artifact(repository: str, digest: str, public_key: str | Path, insecure_registry: bool = False) -> bool

Check the cosign signature of <repository>@<digest> with a public key, ignoring the transparency log.

NameTypeDefaultRequiredDescription
repositorystryesRepository of the artifact, without tag.
digeststryesManifest digest sha256:<hex> of the artifact.
public_keystr | PathyesPath of the cosign public key (cosign.pub).
insecure_registryboolFalsenoAllow a registry without TLS (--allow-insecure-registry), default False.

Returns: bool. True when cosign verify succeeds, else False.