Skip to content

Commit 4f03669

Browse files
committed
port data is int64 in packer>1.11 for some reason
1 parent 02633c6 commit 4f03669

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

provisioner/communication.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,22 @@ func (provisioner *Provisioner) determineUserAddr(connectionType string, ui pack
175175
return "", "", errors.New("unknown host address")
176176
}
177177
}
178+
178179
// valid ip address so now determine port
179180
port, ok := provisioner.generatedData[genDataMap[connectionType]["port"]].(int)
180181
if !ok || port == 0 {
181182
// fallback to general port
182183
port, ok = provisioner.generatedData["Port"].(int)
183184

184185
if !ok || port == 0 {
185-
ui.Errorf("host port could not be determined from available Packer data: %d", port)
186-
return "", "", errors.New("unknown host port")
186+
// packer > 1.11 now casts "port" as int64 so try again with that
187+
// never mind that sshport is still int (but dropped now for some reason), and either would actually be uint16...
188+
port, ok := provisioner.generatedData["Port"].(int64)
189+
190+
if !ok || port == 0 {
191+
ui.Error("host port could not be determined from available Packer data")
192+
return "", "", errors.New("unknown host port")
193+
}
187194
}
188195
}
189196

0 commit comments

Comments
 (0)