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:
|
||||
if not self.command_prefix:
|
||||
self.command_prefix = self.host
|
||||
if not self.user:
|
||||
self.user = "root"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.target
|
||||
|
||||
@property
|
||||
def target(self) -> str:
|
||||
return f"{self.user or 'root'}@{self.host}"
|
||||
return f"{self.user}@{self.host}"
|
||||
|
||||
@classmethod
|
||||
def from_host(cls, host: "Host") -> "Host":
|
||||
|
||||
@@ -114,7 +114,9 @@ def test_parse_deployment_address(
|
||||
|
||||
assert result.host == expected_host
|
||||
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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user