Skip to content

Commit 2e54e3f

Browse files
committed
migrate UpdateAll action to use Updater class and remove hosts_file.rb
1 parent 5581f1c commit 2e54e3f

File tree

3 files changed

+6
-219
lines changed

3 files changed

+6
-219
lines changed

lib/vagrant-hostmanager/action/update_all.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
require 'vagrant-hostmanager/hosts_file'
1+
require 'vagrant-hostmanager/hosts_file/updater'
22
require 'vagrant-hostmanager/util'
33

44
module VagrantPlugins
55
module HostManager
66
module Action
77
class UpdateAll
8-
include HostsFile
98

109
def initialize(app, env)
1110
@app = app
1211
@machine = env[:machine]
1312
@global_env = @machine.env
1413
@provider = @machine.provider_name
1514
@config = Util.get_config(@global_env)
15+
@updater = HostsFile::Updater.new(@global_env, @provider)
1616
@logger = Log4r::Logger.new('vagrant::hostmanager::update_all')
1717
end
1818

@@ -31,14 +31,14 @@ def call(env)
3131
@global_env.active_machines.each do |name, p|
3232
if p == @provider
3333
machine = @global_env.machine(name, p)
34-
update_guest(machine)
34+
@updater.update_guest(machine)
3535
end
3636
end
3737

3838
# update /etc/hosts files on host if enabled
3939
if @machine.config.hostmanager.manage_host?
4040
env[:ui].info I18n.t('vagrant_hostmanager.action.update_host')
41-
update_host
41+
@updater.update_host
4242
end
4343
end
4444
end

lib/vagrant-hostmanager/hosts_file.rb

Lines changed: 0 additions & 213 deletions
This file was deleted.

lib/vagrant-hostmanager/hosts_file/updater.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def update_content(file_content, resolving_machine, include_id)
9292
def get_hosts_file_entry(machine, resolving_machine)
9393
ip = get_ip_address(machine, resolving_machine)
9494
host = machine.config.vm.hostname || machine.name
95-
aliases = machine.config.hostmanager.aliases.join(' ').chomp
95+
aliases = machine.config.hostmanager.aliases
9696
if ip != nil
97-
"#{ip}\t#{host} #{aliases}\n"
97+
"#{ip}\t#{host}\n" + aliases.map{|a| "#{ip}\t#{a}"}.join("\n") + "\n"
9898
end
9999
end
100100

0 commit comments

Comments
 (0)