Sha256: 8b9da3809c39e75ec5e53c9f0b28f9b8fdb8e247317886612eb18860615340b7

Contents?: true

Size: 909 Bytes

Versions: 10

Compression:

Stored size: 909 Bytes

Contents

module VagrantPlugins
  module DockerProvider
    module Action
      class ForwardedPorts
        def initialize(app, env)
          @app = app
        end

        # Converts the `ports` docker provider param into proper network configs
        # of type :forwarded_port
        def call(env)
          env[:machine].provider_config.ports.each do |p|
            host_ip = nil
            protocol = "tcp"
            host, guest = p.split(":", 2)
            if guest.include?(":")
              host_ip = host
              host, guest = guest.split(":", 2)
            end

            guest, protocol = guest.split("/", 2) if guest.include?("/")
            env[:machine].config.vm.network "forwarded_port",
              host: host.to_i, guest: guest.to_i,
              host_ip: host_ip,
              protocol: protocol
          end

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/providers/docker/action/forwarded_ports.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/providers/docker/action/forwarded_ports.rb
vagrant-unbundled-2.3.3.0 plugins/providers/docker/action/forwarded_ports.rb
vagrant-unbundled-2.3.2.0 plugins/providers/docker/action/forwarded_ports.rb
vagrant-unbundled-2.2.19.0 plugins/providers/docker/action/forwarded_ports.rb
vagrant-unbundled-2.2.18.0 plugins/providers/docker/action/forwarded_ports.rb
vagrant-unbundled-2.2.16.0 plugins/providers/docker/action/forwarded_ports.rb
vagrant-unbundled-2.2.14.0 plugins/providers/docker/action/forwarded_ports.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/providers/docker/action/forwarded_ports.rb
vagrant-unbundled-2.2.10.0 plugins/providers/docker/action/forwarded_ports.rb