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
23 changes: 20 additions & 3 deletions chipfoundry_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,33 @@ def config_cmd():
def _try_register_ssh_key(public_key: str) -> bool:
"""Attempt to register the SSH public key on the user's platform profile.

Returns True if the key was registered successfully, False otherwise.
Calls the CLI-specific ``PUT /auth/cli/ssh-key`` endpoint so the request
stays on the public API surface. Returns True on success, False otherwise.
Errors are swallowed silently so the caller can print the manual-registration
fallback without a scary ``API request failed`` line first.
"""
import httpx as _httpx

config = load_user_config()
if not config.get("api_key"):
return False

try:
_api_put("/users/me", {"ssh_public_key": public_key})
return True
client, _ = _api_client()
except SystemExit:
return False
try:
resp = client.put("/auth/cli/ssh-key", json={"ssh_public_key": public_key})
if resp.status_code == 200:
return True
return False
except _httpx.HTTPError:
return False
finally:
try:
client.close()
except Exception:
pass


def _print_manual_key_instructions():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "chipfoundry-cli"
version = "2.4.4"
version = "2.4.5"
description = "CLI tool to automate ChipFoundry project submission to SFTP server"
authors = ["ChipFoundry <marwan.abbas@chipfoundry.io>"]
readme = "README.md"
Expand Down
Loading