Skip to content

Commit

Permalink
Various fixes for issues encountered using the read me example (#16)
Browse files Browse the repository at this point in the history
* Fix the import in the example in the read me

Signed-off-by: mprahl <[email protected]>

* Pass --remove-signatures to skopeo copy

This adds support for copying from registries that leverage signatures
(e.g. registry.access.redhat.com).

Signed-off-by: mprahl <[email protected]>

* Add support for a string path for oci_layers_on_top

Without this code, Python would accept a string but verify_ocilayout
would fail when joining paths.

Signed-off-by: mprahl <[email protected]>

* Allow pushing container images with credentials

Signed-off-by: mprahl <[email protected]>

* code review remove redundant

Signed-off-by: tarilabs <[email protected]>

---------

Signed-off-by: mprahl <[email protected]>
Signed-off-by: tarilabs <[email protected]>
Co-authored-by: tarilabs <[email protected]>
  • Loading branch information
mprahl and tarilabs authored Feb 19, 2025
1 parent 36e7801 commit 574f4b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pip install olot
Import and add layers onto a locally available model (using skopeo):

```python
from olot.oci_artifact import oci_layers_on_top
from olot.basic import oci_layers_on_top
from olot.backend.skopeo import skopeo_pull, skopeo_push

model_dir = 'download'
Expand Down
4 changes: 2 additions & 2 deletions olot/backend/skopeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def is_skopeo() -> bool :
def skopeo_pull(base_image: str, dest: typing.Union[str, os.PathLike]):
if isinstance(dest, os.PathLike):
dest = str(dest)
return subprocess.run(["skopeo", "copy", "--multi-arch", "all", "docker://"+base_image, "oci:"+dest+":latest"], check=True)
return subprocess.run(["skopeo", "copy", "--multi-arch", "all", "--remove-signatures", "docker://"+base_image, "oci:"+dest+":latest"], check=True)


def skopeo_push(src: typing.Union[str, os.PathLike], oci_ref: str):
if isinstance(src, os.PathLike):
src = str(src)
return subprocess.run(["skopeo", "copy", "--multi-arch", "all", "--dest-tls-verify=false", "--dest-no-creds", "oci:"+src+":latest", "docker://"+oci_ref], check=True)
return subprocess.run(["skopeo", "copy", "--multi-arch", "all", "--dest-tls-verify=false", "oci:"+src+":latest", "docker://"+oci_ref], check=True)
5 changes: 4 additions & 1 deletion olot/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
from olot.utils.files import tarball_from_file, targz_from_file
from olot.utils.types import compute_hash_of_str

def oci_layers_on_top(ocilayout: Path, model_files: List[os.PathLike], modelcard: typing.Union[os.PathLike, None] = None):
def oci_layers_on_top(ocilayout: typing.Union[str, os.PathLike], model_files: List[os.PathLike], modelcard: typing.Union[os.PathLike, None] = None):
if not isinstance(ocilayout, Path):
ocilayout = Path(ocilayout)

verify_ocilayout(ocilayout)
ocilayout_root_index = read_ocilayout_root_index(ocilayout)
ocilayout_indexes: Dict[str, OCIImageIndex] = crawl_ocilayout_indexes(ocilayout, ocilayout_root_index)
Expand Down

0 comments on commit 574f4b4

Please sign in to comment.