Skip to content

fix(cli): add the key given to rp ssh add --key and --key-file - #792

Open
irisfield wants to merge 1 commit into
runpod:mainfrom
irisfield:fix/ssh-add-key
Open

irisfield wants to merge 1 commit into
runpod:mainfrom
irisfield:fix/ssh-add-key

Conversation

@irisfield

Copy link
Copy Markdown

Fixes #791

Problem

With --key or --key-file, add_key prints the success message without reading or sending the key.

Fix

When --key or --key-file is given, add_key calls add_ssh_key with the key text, stripped (the file's contents for --key-file), and then prints the existing success message. --key-file is read through click.File, as in rp endpoint. Passing both flags raises a usage error, and an empty key file raises an error. The no-flags path is unchanged.

Tests

Five tests in tests/test_cli/test_cli_groups/test_ssh_commands.py mock add_ssh_key: --key, --key-file, both flags, a missing file, and an empty file. They fail without this change.

Before and after

Starting from an account with no SSH keys, one rp ssh add --key and one rp ssh add --key-file:

runpod 2.4.1 With this change
both commands print "The key has been added to your account." same message
rp ssh list afterwards empty table both keys (demo-a, demo-b)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rp ssh add --key and --key-file report success but do not add the key

1 participant