Browse Source

2.0.1: Don't require sshpubkeys

This should make pipx run sporestack work on FreeBSD.
v2 2.0.1
Teran McKinney 4 months ago
parent
commit
73c9191d84
  1. 2
      setup.cfg
  2. 1
      setup.py
  3. 4
      sporestack/client.py
  4. 14
      sporestack/validate.py
  5. 6
      sporestack/validate_test.py
  6. 2
      sporestack/version.py

2
setup.cfg

@ -1,2 +0,0 @@
[metadata]
description-file = README.md

1
setup.py

@ -46,7 +46,6 @@ setup(
"pyqrcode",
"requests[socks]>=2.22.0",
"aaargh",
"sshpubkeys",
],
entry_points={"console_scripts": ["sporestack = sporestack.client:main"]},
zip_safe=False, # This is so py.typed gets included.

4
sporestack/client.py

@ -270,6 +270,9 @@ def machine_info_path() -> Path:
else:
old_sporestack_dir.rename(sporestack_dir)
# Make it, if it doesn't exist already.
sporestack_dir.mkdir(exist_ok=True)
return sporestack_dir
@ -279,7 +282,6 @@ def save_machine_info(machine_info: Dict[str, Any], overwrite: bool = False) ->
"""
os.umask(0o0077)
directory = machine_info_path()
directory.mkdir(exist_ok=True)
hostname = machine_info["vm_hostname"]
json_file = directory.joinpath(f"{hostname}.json")
if overwrite is False:

14
sporestack/validate.py

@ -7,8 +7,6 @@ All functions return True if valid, or raise an exception.
import string
from typing import Optional
from sshpubkeys import SSHKey
def machine_id(machine_id: str) -> None:
"""
@ -73,13 +71,11 @@ def ssh_key(ssh_key: str) -> None:
Validates an ssh_key argument.
"""
if not isinstance(ssh_key, str):
raise TypeError("ssh_key must be null or a string.")
ssh_key_object = SSHKey(ssh_key, skip_option_parsing=True, disallow_options=True)
try:
ssh_key_object.parse()
except Exception as e:
raise ValueError(f"Invalid SSH key: {str(e)}")
raise TypeError("ssh_key must be a string.")
if len(ssh_key) < 10:
raise ValueError("ssh_key is too small.")
if len(ssh_key) > 8096:
raise ValueError("ssh_key is too big.")
def days(days: int, zero_allowed: bool = False) -> None:

6
sporestack/validate_test.py

@ -166,14 +166,16 @@ valid_ssh_key_with_comment = valid_ssh_key + " root@localhost"
def test_ssh_key() -> None:
validate.ssh_key(valid_ssh_key)
validate.ssh_key(valid_ssh_key_with_comment)
validate.ssh_key("a" * 10)
validate.ssh_key("a" * 8096)
with pytest.raises(TypeError):
validate.ssh_key(None) # type: ignore
with pytest.raises(TypeError):
validate.ssh_key(1) # type: ignore
with pytest.raises(ValueError):
validate.ssh_key("")
validate.ssh_key("a" * 9)
with pytest.raises(ValueError):
validate.ssh_key("ssh-rsa")
validate.ssh_key("a" * 8097)
def test_region() -> None:

2
sporestack/version.py

@ -1 +1 @@
__version__ = "2.0.0"
__version__ = "2.0.1"

Loading…
Cancel
Save