2014-05-08 20:37:55 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module DockerProvider
|
|
|
|
module Action
|
|
|
|
class ForwardedPorts
|
|
|
|
def initialize(app, env)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
env[:machine].provider_config.ports.each do |p|
|
2014-10-22 00:17:34 +00:00
|
|
|
host_ip = nil
|
|
|
|
protocol = "tcp"
|
2014-05-08 20:37:55 +00:00
|
|
|
host, guest = p.split(":", 2)
|
2014-10-22 00:17:34 +00:00
|
|
|
if guest.include?(":")
|
|
|
|
host_ip = host
|
|
|
|
host, guest = guest.split(":", 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
guest, protocol = guest.split("/", 2) if guest.include?("/")
|
2014-05-08 20:37:55 +00:00
|
|
|
env[:machine].config.vm.network "forwarded_port",
|
2014-10-22 00:17:34 +00:00
|
|
|
host: host.to_i, guest: guest.to_i,
|
|
|
|
host_ip: host_ip,
|
|
|
|
protocol: protocol
|
2014-05-08 20:37:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@app.call(env)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|