Skip to content

Commit

Permalink
new: Address breaking change in MDS plugin sshkeys command (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarber-akamai authored Feb 14, 2024
1 parent 287d6c5 commit 65bc15f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 9 additions & 4 deletions linodecli/plugins/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ def print_ssh_keys_table(data):
"""
table = Table(show_lines=True)

table.add_column("ssh keys")
table.add_column("user")
table.add_column("ssh key")

if data.users.root is not None:
for key in data.users.root:
table.add_row(key)
for name, keys in data.users.items():
# Keys will be None if no keys are configured for the user
if keys is None:
continue

for key in keys:
table.add_row(name, key)

rprint(table)

Expand Down
7 changes: 5 additions & 2 deletions tests/unit/test_plugin_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def test_ssh_key_table(capsys: CaptureFixture):
print_ssh_keys_table(SSH_KEYS)
captured_text = capsys.readouterr()

assert "ssh keys" in captured_text.out
assert "user" in captured_text.out
assert "ssh key" in captured_text.out
assert "root" in captured_text.out
assert "ssh-key-1" in captured_text.out
assert "ssh-key-2" in captured_text.out

Expand All @@ -125,4 +127,5 @@ def test_empty_ssh_key_table(capsys: CaptureFixture):
print_ssh_keys_table(SSH_KEYS_EMPTY)
captured_text = capsys.readouterr()

assert "ssh keys" in captured_text.out
assert "user" in captured_text.out
assert "ssh key" in captured_text.out

0 comments on commit 65bc15f

Please sign in to comment.