Skip to content
Merged
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
8 changes: 7 additions & 1 deletion crpy/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def _pull(args):
if not filename:
# make file name compatible
filename = ri.repository.replace(":", "_").replace("/", "_")
await ri.pull(filename, args.architecture[0] if args.architecture else None)
await ri.pull(filename, args.architecture[0] if args.architecture else None, not args.no_cache)


async def _push(args):
Expand Down Expand Up @@ -173,6 +173,12 @@ def main(*args):
help="Architecture for the to be pulled.",
default=None,
)
pull.add_argument(
"--no-cache",
action="store_true",
help="If should not use the cache when pulling the image.",
default=False,
)
pull.add_argument("url", nargs=1, help="Remote repository to pull from.")
pull.add_argument("filename", nargs="?", help="Output file for the compressed image.")

Expand Down
8 changes: 6 additions & 2 deletions crpy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@ async def get_response_content(self, layer: str, file_obj: Optional[io.BytesIO])
return file_obj.getvalue()

async def pull(
self, output_file: Union[str, pathlib.Path, io.BytesIO], architecture: Union[str, Platform, None] = None
self,
output_file: Union[str, pathlib.Path, io.BytesIO],
architecture: Union[str, Platform, None] = None,
use_cache: bool = True,
):
"""
Pulls an image from a remote repository. The image will be packed into a tar-file and saved to disk (or to a
Expand All @@ -372,6 +375,7 @@ async def pull(
:param output_file: path or file-like object to save the binary data.
:param architecture: architecture to pull the image. If not set, the default registry architecture will be
used.
:param use_cache: enables the local cache, saving layers to ~/.crpy/ folder.
:return:
"""
print(f"{self.tag}: Pulling from {self.registry}/{self.repository}")
Expand All @@ -382,7 +386,7 @@ async def pull(
for layer in await self.get_layers(architecture):
layer_without_prefix = layer.split(":")[1]
image.layers.append(
Blob.from_any(await self.pull_layer(layer, use_cache=True), digest=layer_without_prefix)
Blob.from_any(await self.pull_layer(layer, use_cache=use_cache), digest=layer_without_prefix)
)
print(f"{layer_without_prefix[0:12]}: Pull complete")
image.to_disk(output_file, tags=[str(self)])
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ authors = [
]
requires-python = ">=3.9.0"
dependencies = [
"requests>=2",
"async-lru>=2",
"aiohttp>=3",
"async-lru>=2",
Expand Down
Loading