cli: fix unnecessary sudo when unspecified user defaults to root
This commit is contained in:
@@ -38,13 +38,15 @@ class Host:
|
|||||||
def __post_init__(self) -> None:
|
def __post_init__(self) -> None:
|
||||||
if not self.command_prefix:
|
if not self.command_prefix:
|
||||||
self.command_prefix = self.host
|
self.command_prefix = self.host
|
||||||
|
if not self.user:
|
||||||
|
self.user = "root"
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.target
|
return self.target
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target(self) -> str:
|
def target(self) -> str:
|
||||||
return f"{self.user or 'root'}@{self.host}"
|
return f"{self.user}@{self.host}"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_host(cls, host: "Host") -> "Host":
|
def from_host(cls, host: "Host") -> "Host":
|
||||||
|
|||||||
@@ -114,7 +114,9 @@ def test_parse_deployment_address(
|
|||||||
|
|
||||||
assert result.host == expected_host
|
assert result.host == expected_host
|
||||||
assert result.port == expected_port
|
assert result.port == expected_port
|
||||||
assert result.user == expected_user
|
assert result.user == expected_user or (
|
||||||
|
expected_user == "" and result.user == "root"
|
||||||
|
)
|
||||||
assert result.ssh_options == expected_options
|
assert result.ssh_options == expected_options
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user