vagrant-virtual-hostsupdater 1.3.0 → 1.4.0
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 +4 -4
- data/Gemfile +1 -1
- data/README.md +4 -0
- data/lib/vagrant-virtual-hostsupdater/Action/BaseAction.rb +44 -0
- data/lib/vagrant-virtual-hostsupdater/Action/CacheHosts.rb +2 -9
- data/lib/vagrant-virtual-hostsupdater/Action/RemoveHosts.rb +11 -18
- data/lib/vagrant-virtual-hostsupdater/Action/UpdateHosts.rb +3 -13
- data/lib/vagrant-virtual-hostsupdater/plugin.rb +2 -3
- data/lib/vagrant-virtual-hostsupdater/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf3391d6244305c873b8834efcf5b5e5c893e7baa370e5104d28902b96e76597
|
4
|
+
data.tar.gz: 86a47931ca6969f238aad159bdcae64b580e7997cc77536643d5e082364813ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 907a8beaa9333e35530a92248e07f82dda257e82cecd7c118f07ea79de50766422b722bb1f18d2766d592ad6fc115ff98e6ecc8f77a46e5e9a83e43b8a06e422
|
7
|
+
data.tar.gz: ed97599fa8b29267a0798dc6a6a9b9fdaf29d90ccf28b98524ee9eee21598fa4598b8f104e07854e48830f07c3ab65bc4d3fda488304f3c37bd69b6a3e99f96c
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VirtualHostsUpdater
|
3
|
+
module Action
|
4
|
+
class BaseAction
|
5
|
+
include VirtualHostsUpdater
|
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/agiledivider/vagrant-hostsupdater/issues/187
|
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/agiledivider/vagrant-hostsupdater/issues/198
|
29
|
+
if @machine.id and not @@completed.key?("#{self.class.name}-#{@machine.name}")
|
30
|
+
run(env)
|
31
|
+
@@completed["#{self.class.name}-#{@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,17 +1,10 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module VirtualHostsUpdater
|
3
3
|
module Action
|
4
|
-
class CacheHosts
|
5
|
-
include VirtualHostsUpdater
|
4
|
+
class CacheHosts < BaseAction
|
6
5
|
|
7
|
-
def
|
8
|
-
@app = app
|
9
|
-
@machine = env[:machine]
|
10
|
-
end
|
11
|
-
|
12
|
-
def call(env)
|
6
|
+
def run(env)
|
13
7
|
cacheHostEntries
|
14
|
-
@app.call(env)
|
15
8
|
end
|
16
9
|
|
17
10
|
end
|
@@ -1,28 +1,21 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module VirtualHostsUpdater
|
3
3
|
module Action
|
4
|
-
class RemoveHosts
|
5
|
-
include VirtualHostsUpdater
|
4
|
+
class RemoveHosts < BaseAction
|
6
5
|
|
7
|
-
def
|
8
|
-
@app = app
|
9
|
-
@machine = env[:machine]
|
10
|
-
@ui = env[:ui]
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(env)
|
6
|
+
def run(env)
|
14
7
|
machine_action = env[:machine_action]
|
15
|
-
if
|
16
|
-
if
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@ui.info "[vagrant-virtual-hostsupdater] Removing hosts on suspend disabled"
|
22
|
-
end
|
8
|
+
if [:suspend, :halt].include? machine_action
|
9
|
+
if @machine.config.virtualhostsupdater.remove_on_suspend == false
|
10
|
+
@ui.info "[vagrant-virtual-hostsupdater] Not removing hosts (remove_on_suspend false)"
|
11
|
+
else
|
12
|
+
@ui.info "[vagrant-virtual-hostsupdater] Removing hosts on suspend"
|
13
|
+
removeHostEntries
|
23
14
|
end
|
15
|
+
else
|
16
|
+
@ui.info "[vagrant-virtual-hostsupdater] Removing hosts"
|
17
|
+
removeHostEntries
|
24
18
|
end
|
25
|
-
@app.call(env)
|
26
19
|
end
|
27
20
|
|
28
21
|
end
|
@@ -1,24 +1,14 @@
|
|
1
|
-
require_relative "../VirtualHostsUpdater"
|
2
1
|
module VagrantPlugins
|
3
2
|
module VirtualHostsUpdater
|
4
3
|
module Action
|
5
|
-
class UpdateHosts
|
6
|
-
include VirtualHostsUpdater
|
4
|
+
class UpdateHosts < BaseAction
|
7
5
|
|
8
|
-
|
9
|
-
def initialize(app, env)
|
10
|
-
@app = app
|
11
|
-
@machine = env[:machine]
|
12
|
-
@ui = env[:ui]
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(env)
|
6
|
+
def run(env)
|
16
7
|
@ui.info "[vagrant-virtual-hostsupdater] Checking for host entries"
|
17
8
|
addHostEntries()
|
18
|
-
@app.call(env)
|
19
9
|
end
|
20
10
|
|
21
11
|
end
|
22
12
|
end
|
23
13
|
end
|
24
|
-
end
|
14
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "vagrant-virtual-hostsupdater/VirtualHostsUpdater.rb"
|
2
|
+
require "vagrant-virtual-hostsupdater/Action/BaseAction"
|
1
3
|
require "vagrant-virtual-hostsupdater/Action/UpdateHosts"
|
2
4
|
require "vagrant-virtual-hostsupdater/Action/CacheHosts"
|
3
5
|
require "vagrant-virtual-hostsupdater/Action/RemoveHosts"
|
@@ -34,9 +36,6 @@ module VagrantPlugins
|
|
34
36
|
|
35
37
|
action_hook(:virtualhostsupdater, :machine_action_destroy) do |hook|
|
36
38
|
hook.prepend(Action::CacheHosts)
|
37
|
-
end
|
38
|
-
|
39
|
-
action_hook(:virtualhostsupdater, :machine_action_destroy) do |hook|
|
40
39
|
hook.append(Action::RemoveHosts)
|
41
40
|
end
|
42
41
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-virtual-hostsupdater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Falk Kühnel
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-06-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- README.md
|
56
56
|
- Rakefile
|
57
57
|
- lib/vagrant-virtual-hostsupdater.rb
|
58
|
+
- lib/vagrant-virtual-hostsupdater/Action/BaseAction.rb
|
58
59
|
- lib/vagrant-virtual-hostsupdater/Action/CacheHosts.rb
|
59
60
|
- lib/vagrant-virtual-hostsupdater/Action/RemoveHosts.rb
|
60
61
|
- lib/vagrant-virtual-hostsupdater/Action/UpdateHosts.rb
|
@@ -83,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
84
|
- !ruby/object:Gem::Version
|
84
85
|
version: '0'
|
85
86
|
requirements: []
|
86
|
-
rubygems_version: 3.2.
|
87
|
+
rubygems_version: 3.2.33
|
87
88
|
signing_key:
|
88
89
|
specification_version: 4
|
89
90
|
summary: Enables Vagrant to update hosts file on the host machine
|