From 09ef5194085614bb8259ca61bdb214f7853b1d03 Mon Sep 17 00:00:00 2001 From: Andres Montalban Date: Fri, 8 Jul 2016 10:03:08 -0300 Subject: [PATCH] Fix for devopsgroup-io/vagrant-hostmanager#182 devopsgroup-io/vagrant-hostmanager#131 --- lib/vagrant-hostmanager/action/update_all.rb | 4 ++-- lib/vagrant-hostmanager/config.rb | 24 ++++++++++++++++++++ lib/vagrant-hostmanager/util.rb | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/vagrant-hostmanager/action/update_all.rb b/lib/vagrant-hostmanager/action/update_all.rb index ee87734..a6d7696 100644 --- a/lib/vagrant-hostmanager/action/update_all.rb +++ b/lib/vagrant-hostmanager/action/update_all.rb @@ -27,7 +27,7 @@ def call(env) @app.call(env) # update /etc/hosts file on active machines - if @machine.config.hostmanager.manage_guest? + if @config.hostmanager.manage_guest? env[:ui].info I18n.t('vagrant_hostmanager.action.update_guests') @global_env.active_machines.each do |name, p| if p == @provider @@ -38,7 +38,7 @@ def call(env) end # update /etc/hosts files on host if enabled - if @machine.config.hostmanager.manage_host? + if @config.hostmanager.manage_host? env[:ui].info I18n.t('vagrant_hostmanager.action.update_host') @updater.update_host end diff --git a/lib/vagrant-hostmanager/config.rb b/lib/vagrant-hostmanager/config.rb index 1ae26f4..175d93a 100644 --- a/lib/vagrant-hostmanager/config.rb +++ b/lib/vagrant-hostmanager/config.rb @@ -24,6 +24,30 @@ def initialize @ip_resolver = UNSET_VALUE end + def merge(other) + super.tap do |result| + @enabled = false if @enabled == UNSET_VALUE + other.enabled = false if other.enabled == UNSET_VALUE + result.enabled = [@enabled, other.enabled].any? + + @manage_host = false if @manage_host == UNSET_VALUE + other.manage_host = false if other.manage_host == UNSET_VALUE + result.manage_host = [@manage_host, other.manage_host].any? + + @manage_guest = true if @manage_guest == UNSET_VALUE + other.manage_guest = true if other.manage_guest == UNSET_VALUE + result.manage_guest = [@manage_guest, other.manage_guest].any? + + @ignore_private_ip = false if @ignore_private_ip == UNSET_VALUE + other.ignore_private_ip = false if other.ignore_private_ip == UNSET_VALUE + result.ignore_private_ip = [@ignore_private_ip, other.ignore_private_ip].any? + + @include_offline = false if @include_offline == UNSET_VALUE + other.include_offline = false if other.include_offline == UNSET_VALUE + result.include_offline = [@include_offline, other.include_offline].any? + end + end + def finalize! @enabled = false if @enabled == UNSET_VALUE @manage_host = false if @manage_host == UNSET_VALUE diff --git a/lib/vagrant-hostmanager/util.rb b/lib/vagrant-hostmanager/util.rb index 0bc4dcd..3817140 100644 --- a/lib/vagrant-hostmanager/util.rb +++ b/lib/vagrant-hostmanager/util.rb @@ -4,7 +4,7 @@ module Util def self.get_config(env) # config_global has been removed from v1.5 if Gem::Version.new(::Vagrant::VERSION) >= Gem::Version.new('1.5') - env.vagrantfile.config + env.vagrantfile.config[:hostmanager] else env.config_global end