Skip to content

Commit

Permalink
Reversing cf65149 as v1.6.0 has been a success.
Browse files Browse the repository at this point in the history
  • Loading branch information
seth-reeser committed Aug 6, 2015
1 parent bb53e42 commit dcdfcc9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 24 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ up or have a private ip configured will be added to the hosts file.
In addition, the `hostmanager.aliases` configuration attribute can be used
to provide aliases for your host names.

On some systems, long alias lines have been reported to cause issues
(see [#60](https://github.com/smdahlen/vagrant-hostmanager/issues/60)).
In such cases, you may render aliases on separate lines by setting
```hostmanager.aliases_on_separate_lines = true```.

Example configuration:

```ruby
Expand Down
3 changes: 0 additions & 3 deletions lib/vagrant-hostmanager/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Config < Vagrant.plugin('2', :config)
attr_accessor :aliases
attr_accessor :include_offline
attr_accessor :ip_resolver
attr_accessor :aliases_on_separate_lines

alias_method :enabled?, :enabled
alias_method :include_offline?, :include_offline
Expand All @@ -20,7 +19,6 @@ def initialize
@include_offline = UNSET_VALUE
@aliases = UNSET_VALUE
@ip_resolver = UNSET_VALUE
@aliases_on_separate_lines = UNSET_VALUE
end

def finalize!
Expand All @@ -30,7 +28,6 @@ def finalize!
@include_offline = false if @include_offline == UNSET_VALUE
@aliases = [] if @aliases == UNSET_VALUE
@ip_resolver = nil if @ip_resolver == UNSET_VALUE
@aliases_on_separate_lines = false if @aliases_on_separate_lines == UNSET_VALUE

@aliases = [ @aliases ].flatten
end
Expand Down
13 changes: 1 addition & 12 deletions lib/vagrant-hostmanager/hosts_file/updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,8 @@ def get_hosts_file_entry(machine, resolving_machine)
ip = get_ip_address(machine, resolving_machine)
host = machine.config.vm.hostname || machine.name
aliases = machine.config.hostmanager.aliases

if ip != nil
# As per GH-60, we optionally render aliases on separate lines
current_machine_config = ((resolving_machine && resolving_machine.config) || @config)
if current_machine_config.hostmanager.aliases_on_separate_lines
rendered_aliases = aliases.map { |a| "#{ip}\t#{a}" }.join("\n")
separator = "\n"
else
rendered_aliases = aliases.join(" ")
separator = "\t"
end

"#{ip}\t#{host}" + separator + rendered_aliases + "\n"
"#{ip}\t#{host}\n" + aliases.map{|a| "#{ip}\t#{a}"}.join("\n") + "\n"
end
end

Expand Down
5 changes: 1 addition & 4 deletions test/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ Vagrant.configure('2') do |config|

config.hostmanager.enabled = true
config.hostmanager.manage_host = true
# config.hostmanager.aliases_on_separate_lines = true

config.vm.define :server1 do |server|
server.vm.hostname = 'fry'
server.vm.network :private_network, :ip => '10.0.5.2'
server.hostmanager.aliases = %w(alias1 alias2)
server.hostmanager.aliases = %w(test-alias)
end

config.vm.define :server2 do |server|
server.vm.hostname = 'bender'
server.vm.network :private_network, :ip => '10.0.5.3'
server.hostmanager.aliases = %w(alias3 alias4)
server.hostmanager.aliases_on_separate_lines = true
end

config.vm.define :server3 do |server|
Expand Down

0 comments on commit dcdfcc9

Please sign in to comment.