vagrant-goodhosts 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56e892a7cfa68be113df9fb991f5fa52d72e2bc450ead6e1c75b6ef7ad569cb5
4
- data.tar.gz: 53ee630010bc772f0fc7825e0e4ef25a32973d6d82ac0a6eec75a2854b8ed7dc
3
+ metadata.gz: b6661999d4e2dfba792e5a925f4674cca24b6b3e523b8f2b3427933ce09570c6
4
+ data.tar.gz: c869c926f280627a4198f8cebcfe47aefffc24e1993e6558a637726d0471dd1a
5
5
  SHA512:
6
- metadata.gz: 84e845186cdf8f2458c325cba423ac735c1f1099ac72a9bb86717fa9d199f394159f6a2befe9c76a14eeefcbabf5d39953353f2faedd0d37aec66db092a798da
7
- data.tar.gz: 407011091f694bbdc4fe85708ec3b11277f2c5be004fb5dfdeccab8eb1d905d0a73bc132f64a8e06653e2ca7ac2af1b699321b0388659e107541a5e7bbbf06a6
6
+ metadata.gz: ee107d64bdd466fe0d96778dff5f71a9783ebe0e77392909eb0e7f041941fe436987c39a1d1967b89ef4922aed18ae579c117677c5c3b0e08e276be318d3e1e0
7
+ data.tar.gz: 5ccb050a4ff37df1db7c0ba61788cf1149d28c6b05d9e470e91263538c3ef9c287ac1777f03500f84ae205c3460ac1793aed94e49bc0506dc4f057501d9230df
data/README.md CHANGED
@@ -78,6 +78,15 @@ config.goodhosts.remove_on_suspend = false
78
78
 
79
79
  This disables `vagrant-goodhosts` from running on **suspend** and **halt**.
80
80
 
81
+ ### Disable file hosts clean
82
+
83
+ If you don't want `/etc/hosts` file cleaned add in your `VagrantFile`:
84
+
85
+ ```ruby
86
+ config.goodhosts.disable_clean = true
87
+ ```
88
+
89
+ This disables `vagrant-goodhosts` from running the clean command.
81
90
 
82
91
  ## Suppressing prompts for elevating privileges
83
92
 
@@ -79,25 +79,38 @@ module VagrantPlugins
79
79
 
80
80
  return hostnames
81
81
  end
82
+
83
+ def shouldClean(ip_address)
84
+ unless ip_address.nil?
85
+ return @machine.config.goodhosts.disable_clean
86
+ end
87
+ return true
88
+ end
82
89
 
83
90
  def addHostEntries
84
91
  error = false
85
92
  errorText = ""
86
93
  cli = get_cli
87
94
  hostnames_by_ips = generateHostnamesByIps
88
-
89
- return if hostnames_by_ips.empty?
95
+
96
+ return if not hostnames_by_ips.any?
90
97
 
91
98
  hostnames_by_ips.each do |ip_address, hostnames|
92
- next if hostnames.empty?
93
99
  if ip_address.nil?
94
100
  @ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
95
101
  next
96
102
  end
103
+ clean = ''
97
104
  if cli.include? ".exe"
98
- stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"add\",\"--clean\",\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
105
+ if not shouldClean(ip_address)
106
+ clean = "\"--clean\","
107
+ end
108
+ stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"add\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
99
109
  else
100
- stdin, stdout, stderr, wait_thr = Open3.popen3("sudo", cli, "add", "--clean", ip_address, hostnames)
110
+ if not shouldClean(ip_address)
111
+ clean = "--clean"
112
+ end
113
+ stdin, stdout, stderr, wait_thr = Open3.popen3("sudo", cli, "add", clean, ip_address, hostnames)
101
114
  end
102
115
  if !wait_thr.value.success?
103
116
  error = true
@@ -113,18 +126,23 @@ module VagrantPlugins
113
126
  cli = get_cli
114
127
  hostnames_by_ips = generateHostnamesByIps
115
128
 
116
- return if hostnames_by_ips.empty?
129
+ return if not hostnames_by_ips.any?
117
130
 
118
131
  hostnames_by_ips.each do |ip_address, hostnames|
119
- next if hostnames.empty?
120
132
  if ip_address.nil?
121
133
  @ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
122
134
  next
123
135
  end
124
136
  if cli.include? ".exe"
125
- stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"remove\",\"--clean\",\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
137
+ if not shouldClean(ip_address)
138
+ clean = "\"--clean\","
139
+ end
140
+ stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"remove\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
126
141
  else
127
- stdin, stdout, stderr, wait_thr = Open3.popen3("sudo", cli, "remove", "--clean", ip_address, hostnames)
142
+ if not shouldClean(ip_address)
143
+ clean = "--clean"
144
+ end
145
+ stdin, stdout, stderr, wait_thr = Open3.popen3("sudo", cli, "remove", clean, ip_address, hostnames)
128
146
  end
129
147
  if !wait_thr.value.success?
130
148
  error = true
@@ -6,6 +6,11 @@ module VagrantPlugins
6
6
  attr_accessor :aliases
7
7
  attr_accessor :id
8
8
  attr_accessor :remove_on_suspend
9
+ attr_accessor :disable_clean
10
+
11
+ def initialize
12
+ @disable_clean = false
13
+ end
9
14
  end
10
15
  end
11
16
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module GoodHosts
3
- VERSION = '1.0.9'
3
+ VERSION = '1.0.10'
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.9
4
+ version: 1.0.10
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-12-14 00:00:00.000000000 Z
11
+ date: 2021-01-18 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.2.0.rc.2
84
+ rubygems_version: 3.2.5
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Enables Vagrant to update hosts file on the host machine with goodhosts