Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast Vagrant SSH data to the correct types #1090

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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