vagrant-goodhosts 1.0.2 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a413f4af6b28126f7bfa544c51fd1861d6809d3f2092ca512f4f3cb92b66a98
4
- data.tar.gz: 278595e91fb77a7f0b1e9a439f21718c3c89c88d6cba2642cc15fc41f063c959
3
+ metadata.gz: e083ea939c0b8d617df7e7edd73baf1d56fa3b34898009596811ed7741fb7809
4
+ data.tar.gz: 5dc851d568aef47c267dcddfb6cdc4474887423c3d50a4904ce6b1536d57ca71
5
5
  SHA512:
6
- metadata.gz: e23da17547129d300c21c3c4850994ff34f936feb65cfb06d102cca35051ed679d22c535f4e7d0edb9019687b7816c9e755b64f4cef871c063aa00a7d2fa615a
7
- data.tar.gz: db90290bfcfa853afc27f4993ab87cf0bafe81b2ad094888b1dafb83664cb3837847f6e814211b22676ede0f4ed3f24debfe3ba56490d8efdb4b7450c3ba9ac5
6
+ metadata.gz: f1da2f9460ac88dd0b98170cba82383d9cde45d9b55ee3f0ab70a8ad73a8ea1aab9204e6babf225a7508f63d566162e11115f2da0b2449a4272e38d8e1ca6cb4
7
+ data.tar.gz: be40aee11d67c11c296ae6be6570cc6331660fd15091f6731c2c2345b4274482f7fca353889a80421ba40b5918e845ad442c6785b64647f46e877847b007bc7e
@@ -5,7 +5,6 @@ module VagrantPlugins
5
5
  class UpdateHosts
6
6
  include GoodHosts
7
7
 
8
-
9
8
  def initialize(app, env)
10
9
  @app = app
11
10
  @machine = env[:machine]
@@ -36,12 +36,13 @@ module VagrantPlugins
36
36
  end
37
37
  end
38
38
 
39
- return ips
39
+
40
40
  end
41
+ return ips
41
42
  end
42
43
 
43
44
  # https://stackoverflow.com/a/13586108/1902215
44
- def get_OS
45
+ def get_os_binary
45
46
  return os ||= (host_os = RbConfig::CONFIG["host_os"]
46
47
  case host_os
47
48
  when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
@@ -56,9 +57,9 @@ module VagrantPlugins
56
57
  end
57
58
 
58
59
  def get_cli
59
- cli = get_OS
60
+ binary = get_os_binary
60
61
  path = File.expand_path(File.dirname(File.dirname(__FILE__))) + "/vagrant-goodhosts/bundle/"
61
- path = "#{path}#{cli}"
62
+ path = "#{path}#{binary}"
62
63
 
63
64
  return path
64
65
  end
@@ -80,15 +81,6 @@ module VagrantPlugins
80
81
  end
81
82
  end
82
83
 
83
- # handle default hostname(s) if not already specified in the aliases
84
- Array(@machine.config.vm.hostname).each do |host|
85
- if hostnames.none? { |k, v| v.include?(host) }
86
- ips.each do |ip|
87
- hostnames[ip].unshift host
88
- end
89
- end
90
- end
91
-
92
84
  return hostnames
93
85
  end
94
86
 
@@ -97,11 +89,15 @@ module VagrantPlugins
97
89
  errorText = ""
98
90
  cli = get_cli
99
91
  hostnames_by_ips = generateHostnamesByIps
100
- hostnames_by_ips.each do |hostnames, ip_address|
92
+ hostnames_by_ips.each do |ip_address, hostnames|
93
+ if ip_address.nil?
94
+ @ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
95
+ next
96
+ end
101
97
  if cli.include? ".exe"
102
- stdin, stdout, stderr, wait_thr = Open3.popen3(cli, "a", ip_address, hostnames)
98
+ stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"add\",\"--clean\",\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
103
99
  else
104
- stdin, stdout, stderr, wait_thr = Open3.popen3("sudo", cli, "a", ip_address, hostnames)
100
+ stdin, stdout, stderr, wait_thr = Open3.popen3("sudo", cli, "add", "--clean", ip_address, hostnames)
105
101
  end
106
102
  if !wait_thr.value.success?
107
103
  error = true
@@ -116,11 +112,15 @@ module VagrantPlugins
116
112
  errorText = ""
117
113
  cli = get_cli
118
114
  hostnames_by_ips = generateHostnamesByIps
119
- hostnames_by_ips.each do |hostnames, ip_address|
115
+ hostnames_by_ips.each do |ip_address, hostnames|
116
+ if ip_address.nil?
117
+ @ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
118
+ next
119
+ end
120
120
  if cli.include? ".exe"
121
- stdin, stdout, stderr, wait_thr = Open3.popen3(cli, "r", ip_address, hostnames)
121
+ stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"remove\",\"--clean\",\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
122
122
  else
123
- stdin, stdout, stderr, wait_thr = Open3.popen3("sudo", cli, "r", ip_address, hostnames)
123
+ stdin, stdout, stderr, wait_thr = Open3.popen3("sudo", cli, "remove", "--clean", ip_address, hostnames)
124
124
  end
125
125
  if !wait_thr.value.success?
126
126
  error = true
@@ -153,7 +153,7 @@ module VagrantPlugins
153
153
  ip_address = ip
154
154
  hostnames[ip].each do |hostname|
155
155
  if !ip_address.nil?
156
- @ui.info "[vagrant-goodhosts] - remove entry for: #{ip_address} #{hostname}"
156
+ @ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
157
157
  end
158
158
  end
159
159
  hostnames_by_ips = { ip_address => hostnames[ip].join(" ") }
@@ -162,7 +162,7 @@ module VagrantPlugins
162
162
  ip_address = ips[0]
163
163
  hostnames[ip_address].each do |hostname|
164
164
  if !ip_address.nil?
165
- @ui.info "[vagrant-goodhosts] - remove entry for: #{ip_address} #{hostname}"
165
+ @ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
166
166
  end
167
167
  end
168
168
  hostnames_by_ips = { ip_address => hostnames[ip_address].join(" ") }
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module GoodHosts
3
- VERSION = '1.0.2'
3
+ VERSION = '1.0.8'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-goodhosts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniele Scasciafratte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubygems_version: 3.1.2
84
+ rubygems_version: 3.2.0.rc.1
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Enables Vagrant to update hosts file on the host machine with goodhosts