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

Commit

Permalink
Merge pull request #185 from SvenDowideit/reparse-port-forwards
Browse files Browse the repository at this point in the history
Found out that the port forwards are ordered dynamically
  • Loading branch information
Sven Dowideit authored and Sven Dowideit committed Jul 10, 2014
2 parents 7e20d36 + 7fc073a commit 5a4caec
Showing 1 changed file with 17 additions and 16 deletions.
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

0 comments on commit 5a4caec

Please sign in to comment.