From fc0546e3338e1666cf2bba9b02b166ac01feee40 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 20 Nov 2024 18:26:07 -0500 Subject: [PATCH] Failover to OCI when push fails with default push mechanism Signed-off-by: Daniel J Walsh --- ramalama/cli.py | 16 ++++++++++++++-- ramalama/model.py | 1 - 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ramalama/cli.py b/ramalama/cli.py index 8e1fbeca..60742c44 100644 --- a/ramalama/cli.py +++ b/ramalama/cli.py @@ -15,6 +15,7 @@ perror, run_cmd, ) +from ramalama.model import model_types from ramalama.oci import OCI from ramalama.ollama import Ollama from ramalama.shortnames import Shortnames @@ -584,8 +585,19 @@ def push_cli(args): if not tgt: tgt = target - model = New(tgt, args) - model.push(source, args) + try: + model = New(tgt, args) + model.push(source, args) + except KeyError as e: + for mtype in model_types: + if model.startswith(mtype + "://"): + raise e + try: + # attempt to push as a container image + m = OCI(model, config.get('engine', container_manager())) + m.push(args) + except Exception: + raise e def run_parser(subparsers): diff --git a/ramalama/model.py b/ramalama/model.py index 3f4ebf4f..0e6775c7 100644 --- a/ramalama/model.py +++ b/ramalama/model.py @@ -100,7 +100,6 @@ def remove(self, args): self.garbage_collection(args) - def _image(self, args): if args.image != default_image(): return args.image