Refactor documentation structure and improve validation checks; update VM state handling and error management.
This commit is contained in:
+5
-1
@@ -86,7 +86,7 @@ def parse_password(value: str) -> str:
|
||||
|
||||
|
||||
def parse_name(value: str) -> str:
|
||||
if re.fullmatch(r"[a-z][a-z0-9-]{0,62}", value) is None:
|
||||
if not isinstance(value, str) or re.fullmatch(r"[a-z][a-z0-9-]{0,62}", value) is None:
|
||||
raise ValidationError("VM name must be 1-63 lowercase letters, digits, or hyphens, starting with a letter")
|
||||
if re.fullmatch(r"vm-[0-9a-f]{32}", value):
|
||||
raise ValidationError("VM names must not impersonate generated VM IDs")
|
||||
@@ -94,8 +94,12 @@ def parse_name(value: str) -> str:
|
||||
|
||||
|
||||
def parse_ports(values: Sequence[str]) -> tuple[PortRule, ...]:
|
||||
if not isinstance(values, Sequence) or isinstance(values, (str, bytes)):
|
||||
raise ValidationError("ports must be a sequence of PORT[:TYPE] strings")
|
||||
ports: dict[int, PortRule] = {}
|
||||
for value in values:
|
||||
if not isinstance(value, str):
|
||||
raise ValidationError("each port specification must be a string")
|
||||
for item in value.split(","):
|
||||
match = re.fullmatch(r"\s*(\d+)(?::(TCP|HTTP|HTTPS))?\s*", item, re.IGNORECASE)
|
||||
if match is None:
|
||||
|
||||
Reference in New Issue
Block a user