Skip to content

Commit

Permalink
Merge pull request #517 from rhatdan/login
Browse files Browse the repository at this point in the history
Fix handling of missing args for login/logout
  • Loading branch information
ericcurtin authored Dec 17, 2024
2 parents 61cb824 + bca53a6 commit ec8ba6f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/ramalama-login.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ramalama\-login - login to remote registry
**ramalama login** [*options*] [*registry*]

## DESCRIPTION
login to remote registry
login to remote model registry

## OPTIONS
Options are specific to registry types.
Expand Down
2 changes: 1 addition & 1 deletion docs/ramalama-logout.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ramalama\-logout - logout from remote registry

## SYNOPSIS
**ramalama logout** [*options*]
**ramalama logout** [*options*] [*registry*]

## DESCRIPTION
Logout to remote model registry
Expand Down
14 changes: 8 additions & 6 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,12 @@ def login_parser(subparsers):


def normalize_registry(registry):
if registry in ["", "ollama", "hf" "huggingface"]:
return registry
if registry.startswith("oci://"):
if not registry or registry == "" or registry.startswith("oci://"):
return "oci://"

if registry in ["ollama", "hf" "huggingface"]:
return registry

return "oci://" + registry


Expand All @@ -294,13 +296,13 @@ def logout_parser(subparsers):
# Do not run in a container
parser.add_argument("--container", default=False, action="store_false", help=argparse.SUPPRESS)
parser.add_argument("--token", help="token for registry")
parser.add_argument("TRANSPORT", nargs="?", type=str, default=config.get("transport")) # positional argument
parser.add_argument("REGISTRY", nargs="?", type=str, help="OCI Registry where AI models are stored")
parser.set_defaults(func=logout_cli)


def logout_cli(args):
transport = args.TRANSPORT
model = New(str(transport), args)
registry = normalize_registry(args.REGISTRY)
model = New(registry, args)
return model.logout(args)


Expand Down
3 changes: 2 additions & 1 deletion ramalama/oci.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def login(self, args):
conman_args.extend([f"--password={args.password}"])
if args.passwordstdin:
conman_args.append("--password-stdin")
conman_args.append(args.REGISTRY.removeprefix(prefix))
if args.REGISTRY:
conman_args.append(args.REGISTRY.removeprefix(prefix))
return exec_cmd(conman_args, debug=args.debug)

def logout(self, args):
Expand Down

0 comments on commit ec8ba6f

Please sign in to comment.