Skip to content

Commit

Permalink
Cast Vagrant SSH data to the correct types
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Krigsman authored and Fizzadar committed May 12, 2024
1 parent 5643c01 commit 9d67e9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions pyinfra/connectors/vagrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ def _make_name_data(host):
"ssh_hostname": host["HostName"],
}

for config_key, data_key in (
("Port", "ssh_port"),
("User", "ssh_user"),
("IdentityFile", "ssh_key"),
for config_key, data_key, data_cast in (
("Port", "ssh_port", int),
("User", "ssh_user", str),
("IdentityFile", "ssh_key", str),
):
if config_key in host:
data[data_key] = host[config_key]
data[data_key] = data_cast(host[config_key])

# Update any configured JSON data
if vagrant_host in vagrant_options.get("data", {}):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_connectors/test_vagrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_make_names_data_with_options(self):
(
"@vagrant/ubuntu16",
{
"ssh_port": "2222",
"ssh_port": 2222,
"ssh_user": "vagrant",
"ssh_hostname": "127.0.0.1",
"ssh_key": "path/to/key",
Expand All @@ -85,7 +85,7 @@ def test_make_names_data_with_options(self):
(
"@vagrant/centos7",
{
"ssh_port": "2200",
"ssh_port": 2200,
"ssh_user": "vagrant",
"ssh_hostname": "127.0.0.1",
"ssh_key": "path/to/key",
Expand All @@ -109,7 +109,7 @@ def test_make_names_data_with_limit(self):
(
"@vagrant/ubuntu16",
{
"ssh_port": "2222",
"ssh_port": 2222,
"ssh_user": "vagrant",
"ssh_hostname": "127.0.0.1",
"ssh_key": "path/to/key",
Expand Down

0 comments on commit 9d67e9b

Please sign in to comment.