From bf6e4b5c89beed6ceed37356ca0198b05e7e417d Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 6 Nov 2013 21:01:19 -0200 Subject: [PATCH] Respect Vagrantfile options to disable forwarded port Closes GH-149 --- CHANGELOG.md | 1 + lib/vagrant-lxc/action/forward_ports.rb | 3 +++ spec/unit/action/forward_ports_spec.rb | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6af3fe..d0bb17f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ IMPROVEMENTS: - Warn users about unsupported private / public networking configs [#154](https://github.com/fgrehm/vagrant-lxc/issues/154) + - Respect Vagrantfile options to disable forwarded port [#149](https://github.com/fgrehm/vagrant-lxc/issues/149) BUG FIXES: diff --git a/lib/vagrant-lxc/action/forward_ports.rb b/lib/vagrant-lxc/action/forward_ports.rb index dded6e2..5bc4efe 100644 --- a/lib/vagrant-lxc/action/forward_ports.rb +++ b/lib/vagrant-lxc/action/forward_ports.rb @@ -63,6 +63,9 @@ module Vagrant mappings = {} config.vm.networks.each do |type, options| + next if options[:disabled] + + # TODO: Deprecate this behavior of "automagically" skipping ssh forwarded ports if type == :forwarded_port && options[:id] != 'ssh' options.delete(:host_ip) if options.fetch(:host_ip, '').to_s.strip.empty? mappings[options[:host]] = options diff --git a/spec/unit/action/forward_ports_spec.rb b/spec/unit/action/forward_ports_spec.rb index e1fb312..126907e 100644 --- a/spec/unit/action/forward_ports_spec.rb +++ b/spec/unit/action/forward_ports_spec.rb @@ -63,6 +63,13 @@ describe Vagrant::LXC::Action::ForwardPorts do pid_file.should == pid end + it 'allows disabling a previously forwarded port' do + forward_conf[:disabled] = true + subject.stub(system: true) + subject.call(env) + subject.should_not have_received(:spawn) + end + it 'raises RedirNotInstalled error if `redir` is not installed' do subject.stub(system: false) lambda { subject.call(env) }.should raise_error(Vagrant::LXC::Errors::RedirNotInstalled)