Skip to content
This repository has been archived by the owner on Feb 27, 2018. It is now read-only.

Found out that the port forwards are ordered dynamically #185

Merged
merged 1 commit into from
Jul 10, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions virtualbox/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,28 +241,29 @@ func GetMachine(id string) (*Machine, error) {
case "CfgFile":
m.CfgFile = val
m.BaseFolder = filepath.Dir(val)
case "Forwarding(0)":
// Forwarding(0)="docker,tcp,127.0.0.1,5555,,"
vals := strings.Split(val, ",")
n, err := strconv.ParseUint(vals[3], 10, 32)
if err != nil {
return nil, err
}
m.DockerPort = uint(n)
case "Forwarding(1)":
// Forwarding(1)="ssh,tcp,127.0.0.1,2222,,22"
vals := strings.Split(val, ",")
n, err := strconv.ParseUint(vals[3], 10, 32)
if err != nil {
return nil, err
}
m.SSHPort = uint(n)
case "uartmode1":
// uartmode1="server,/home/sven/.boot2docker/boot2docker-vm.sock"
vals := strings.Split(val, ",")
if len(vals) >= 2 {
m.SerialFile = vals[1]
}
default:
if strings.HasPrefix(key, "Forwarding(") {
// "Forwarding(\d*)" are ordered by the name inside the val, not fixed order.
// Forwarding(0)="docker,tcp,127.0.0.1,5555,,"
// Forwarding(1)="ssh,tcp,127.0.0.1,2222,,22"
vals := strings.Split(val, ",")
n, err := strconv.ParseUint(vals[3], 10, 32)
if err != nil {
return nil, err
}
switch vals[0] {
case "docker":
m.DockerPort = uint(n)
case "ssh":
m.SSHPort = uint(n)
}
}
}
}
if err := s.Err(); err != nil {
Expand Down