vagrant-goodhosts 1.0.10 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/vagrant-goodhosts/Action/BaseAction.rb +44 -0
- data/lib/vagrant-goodhosts/Action/RemoveHosts.rb +7 -19
- data/lib/vagrant-goodhosts/Action/UpdateHosts.rb +4 -17
- data/lib/vagrant-goodhosts/GoodHosts.rb +20 -12
- data/lib/vagrant-goodhosts/config.rb +1 -1
- data/lib/vagrant-goodhosts/plugin.rb +4 -2
- data/lib/vagrant-goodhosts/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00dc15e9dc6876fb9f1610777d190e21c6bf6397531950a1cae0f35496e1e989
|
4
|
+
data.tar.gz: 30f87a2f1855fde5e646148f02f1861d400de9054109920302e04ab29b95b353
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9fd306e3cbff7ad32f524ba17f3248b1b5fdd113e59e341f34deb153f52c39212c1da1b97382d78567101e6edf74b1b1559180a3bdfbcadf3cabb7786c8edad
|
7
|
+
data.tar.gz: 908da7239733a24b072256659e453d3864c429306b42f3128a6856e7013b635e0c922d3436c5c4ef902c43c9935f1a91f247fa7a0a0b68c1daab8531d931b4d1
|
data/README.md
CHANGED
@@ -80,13 +80,13 @@ This disables `vagrant-goodhosts` from running on **suspend** and **halt**.
|
|
80
80
|
|
81
81
|
### Disable file hosts clean
|
82
82
|
|
83
|
-
If you
|
83
|
+
If you want `/etc/hosts` file cleaned add in your `VagrantFile`:
|
84
84
|
|
85
85
|
```ruby
|
86
|
-
config.goodhosts.disable_clean =
|
86
|
+
config.goodhosts.disable_clean = false
|
87
87
|
```
|
88
88
|
|
89
|
-
This
|
89
|
+
This enable `vagrant-goodhosts` from running the clean command in every call.
|
90
90
|
|
91
91
|
## Suppressing prompts for elevating privileges
|
92
92
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GoodHosts
|
3
|
+
module Action
|
4
|
+
class BaseAction
|
5
|
+
include GoodHosts
|
6
|
+
|
7
|
+
# Vagrant 2.2.14 has changed the hooks execution policy so they
|
8
|
+
# started to be triggered more than once (a lot actually) which
|
9
|
+
# is non-performant and floody. With this static property, we
|
10
|
+
# control the executions and allowing just one.
|
11
|
+
#
|
12
|
+
# - https://github.com/hashicorp/vagrant/issues/12070#issuecomment-732271918
|
13
|
+
# - https://github.com/hashicorp/vagrant/compare/v2.2.13..v2.2.14#diff-4d1af7c67af870f20d303c3c43634084bab8acc101055b2e53ddc0d07f6f64dcL176-L180
|
14
|
+
# - https://github.com/goodhosts/vagrant/issues/25
|
15
|
+
@@completed = {}
|
16
|
+
|
17
|
+
def initialize(app, env)
|
18
|
+
@app = app
|
19
|
+
@machine = env[:machine]
|
20
|
+
@ui = env[:ui]
|
21
|
+
end
|
22
|
+
|
23
|
+
def call(env)
|
24
|
+
# Check whether the plugin has been executed for a particular
|
25
|
+
# VM as it may happen that a single Vagrantfile defines multiple
|
26
|
+
# machines and having a static flag will result in a plugin being
|
27
|
+
# executed just once.
|
28
|
+
# https://github.com/goodhosts/vagrant/issues/30
|
29
|
+
if not @@completed.key?(@machine.name)
|
30
|
+
run(env)
|
31
|
+
@@completed[@machine.name] = true
|
32
|
+
end
|
33
|
+
|
34
|
+
@app.call(env)
|
35
|
+
end
|
36
|
+
|
37
|
+
def run(env)
|
38
|
+
raise NotImplementedError.new("Must be implemented!")
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,32 +1,20 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module GoodHosts
|
3
3
|
module Action
|
4
|
-
class RemoveHosts
|
5
|
-
include GoodHosts
|
6
|
-
@@updated = false
|
4
|
+
class RemoveHosts < BaseAction
|
7
5
|
|
8
|
-
def
|
9
|
-
@app = app
|
10
|
-
@machine = env[:machine]
|
11
|
-
@ui = env[:ui]
|
12
|
-
end
|
13
|
-
|
14
|
-
def call(env)
|
6
|
+
def run(env)
|
15
7
|
machine_action = env[:machine_action]
|
16
8
|
if machine_action != :destroy || !@machine.id
|
17
9
|
if machine_action != :suspend || false != @machine.config.goodhosts.remove_on_suspend
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
else
|
24
|
-
@ui.info "[vagrant-goodhosts] Removing hosts on suspend disabled"
|
25
|
-
end
|
10
|
+
if machine_action != :halt || false != @machine.config.goodhosts.remove_on_suspend
|
11
|
+
@ui.info "[vagrant-goodhosts] Removing hosts"
|
12
|
+
removeHostEntries
|
13
|
+
else
|
14
|
+
@ui.info "[vagrant-goodhosts] Removing hosts on suspend disabled"
|
26
15
|
end
|
27
16
|
end
|
28
17
|
end
|
29
|
-
@app.call(env)
|
30
18
|
end
|
31
19
|
|
32
20
|
end
|
@@ -1,24 +1,11 @@
|
|
1
|
-
require_relative "../GoodHosts"
|
2
1
|
module VagrantPlugins
|
3
2
|
module GoodHosts
|
4
3
|
module Action
|
5
|
-
class UpdateHosts
|
6
|
-
include GoodHosts
|
7
|
-
@@updated = false
|
4
|
+
class UpdateHosts < BaseAction
|
8
5
|
|
9
|
-
def
|
10
|
-
@
|
11
|
-
|
12
|
-
@ui = env[:ui]
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(env)
|
16
|
-
unless @@updated
|
17
|
-
@@updated = true
|
18
|
-
@ui.info "[vagrant-goodhosts] Checking for host entries"
|
19
|
-
addHostEntries()
|
20
|
-
end
|
21
|
-
@app.call(env)
|
6
|
+
def run(env)
|
7
|
+
@ui.info "[vagrant-goodhosts] Checking for host entries"
|
8
|
+
addHostEntries()
|
22
9
|
end
|
23
10
|
|
24
11
|
end
|
@@ -7,6 +7,11 @@ module VagrantPlugins
|
|
7
7
|
def getIps
|
8
8
|
ips = []
|
9
9
|
|
10
|
+
if @machine.config.vm.networks.length == 0
|
11
|
+
@ui.error("[vagrant-goodhosts] No ip address found for this virtual machine")
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
|
10
15
|
@machine.config.vm.networks.each do |network|
|
11
16
|
key, options = network[0], network[1]
|
12
17
|
ip = options[:ip] if (key == :private_network || key == :public_network) && options[:goodhosts] != "skip"
|
@@ -80,7 +85,7 @@ module VagrantPlugins
|
|
80
85
|
return hostnames
|
81
86
|
end
|
82
87
|
|
83
|
-
def
|
88
|
+
def disableClean(ip_address)
|
84
89
|
unless ip_address.nil?
|
85
90
|
return @machine.config.goodhosts.disable_clean
|
86
91
|
end
|
@@ -100,17 +105,18 @@ module VagrantPlugins
|
|
100
105
|
@ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
|
101
106
|
next
|
102
107
|
end
|
103
|
-
clean = ''
|
104
108
|
if cli.include? ".exe"
|
105
|
-
|
106
|
-
|
109
|
+
clean = "\"--clean\","
|
110
|
+
if disableClean(ip_address)
|
111
|
+
clean = ''
|
107
112
|
end
|
108
113
|
stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"add\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
|
109
114
|
else
|
110
|
-
|
111
|
-
|
115
|
+
clean = "--clean"
|
116
|
+
if disableClean(ip_address)
|
117
|
+
clean = ''
|
112
118
|
end
|
113
|
-
stdin, stdout, stderr, wait_thr = Open3.popen3("sudo
|
119
|
+
stdin, stdout, stderr, wait_thr = Open3.popen3("sudo '#{cli}' add #{clean} #{ip_address} #{hostnames}")
|
114
120
|
end
|
115
121
|
if !wait_thr.value.success?
|
116
122
|
error = true
|
@@ -134,15 +140,17 @@ module VagrantPlugins
|
|
134
140
|
next
|
135
141
|
end
|
136
142
|
if cli.include? ".exe"
|
137
|
-
|
138
|
-
|
143
|
+
clean = "\"--clean\","
|
144
|
+
if disableClean(ip_address)
|
145
|
+
clean = ''
|
139
146
|
end
|
140
147
|
stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"remove\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
|
141
148
|
else
|
142
|
-
|
143
|
-
|
149
|
+
clean = "\"--clean\","
|
150
|
+
if disableClean(ip_address)
|
151
|
+
clean = ''
|
144
152
|
end
|
145
|
-
stdin, stdout, stderr, wait_thr = Open3.popen3("sudo
|
153
|
+
stdin, stdout, stderr, wait_thr = Open3.popen3("sudo '#{cli}' remove #{clean} #{ip_address} #{hostnames}")
|
146
154
|
end
|
147
155
|
if !wait_thr.value.success?
|
148
156
|
error = true
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative "GoodHosts"
|
2
|
+
require_relative "Action/BaseAction"
|
3
|
+
require_relative "Action/UpdateHosts"
|
4
|
+
require_relative "Action/RemoveHosts"
|
3
5
|
|
4
6
|
module VagrantPlugins
|
5
7
|
module GoodHosts
|
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.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniele Scasciafratte
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- lib/vagrant-goodhosts.rb
|
54
|
+
- lib/vagrant-goodhosts/Action/BaseAction.rb
|
54
55
|
- lib/vagrant-goodhosts/Action/RemoveHosts.rb
|
55
56
|
- lib/vagrant-goodhosts/Action/UpdateHosts.rb
|
56
57
|
- lib/vagrant-goodhosts/GoodHosts.rb
|