vagrant-hostsupdater 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/lib/vagrant-hostsupdater/Action/BaseAction.rb +39 -0
- data/lib/vagrant-hostsupdater/Action/CacheHosts.rb +2 -9
- data/lib/vagrant-hostsupdater/Action/RemoveHosts.rb +2 -10
- data/lib/vagrant-hostsupdater/Action/UpdateHosts.rb +3 -13
- data/lib/vagrant-hostsupdater/HostsUpdater.rb +2 -3
- data/lib/vagrant-hostsupdater/plugin.rb +5 -6
- data/lib/vagrant-hostsupdater/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: 28da9dcc8ae93032fce5f1005a560e515d04c52dd7fbd8b59a4fe02a5dc28d9f
|
4
|
+
data.tar.gz: 9b52816b56418ef87eeb9d4570832af2b21f4a54e1ff3fff8410f58cf79cb42a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 017dd22e81cec47f73a0af31ecfa58489fd8bc89c57b722d97ef4c381a5fd8d04365138268f5466bda9a486f7fad075071eb1b0ecc484dea7842a26e74dccbe3
|
7
|
+
data.tar.gz: 0f6b2d84f9c791d35e930ac6b75472a0fc38272b88bccfaa9c8b60df2476dcd1c3dd7d9a16b9bed0a9108b960dc077798216fb63c35e0dbaab233a4aa6df6554
|
data/README.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# NOT MAINTAINED
|
2
|
+
# USE AN ALTERNATIVE
|
3
|
+
|
4
|
+
March 3, 2021
|
5
|
+
|
6
|
+
Hi Everyone. @cgsmith here. I took maintenance over from @agiledivider (Falk Kühnel) in 2015. Myself and the company I worked for relied on Vagrant for our development machines and I relied on vagrant-hostsupdater for changing hosts files. When I found out he was no longer maintaining the project I reached out to him on Twitter and he was willing to let me maintain it and apply some much needed pull requests.
|
7
|
+
|
8
|
+
Maintaining a large project is extremely rewarding. I enjoyed doing so but have stopped using Vagrant for development. There are other plugins to help you manage your hosts file or you can feel free to fork this one into your own.
|
9
|
+
|
10
|
+
Don't worry if you don't know Ruby... I didn't. I'm a PHP developer. I figured it out though and asked the right questions to get the problem solved.
|
11
|
+
|
12
|
+
So long... may we meet elsewhere on this vast planet.
|
13
|
+
|
14
|
+
- Chris Smith
|
15
|
+
|
16
|
+
|
1
17
|
# Vagrant::Hostsupdater
|
2
18
|
|
3
19
|
[![Gem Version](https://badge.fury.io/rb/vagrant-hostsupdater.svg)](https://badge.fury.io/rb/vagrant-hostsupdater)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module HostsUpdater
|
3
|
+
module Action
|
4
|
+
class BaseAction
|
5
|
+
include HostsUpdater
|
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
|
+
if not @@completed.key?(self.class.name)
|
25
|
+
run(env)
|
26
|
+
@@completed[self.class.name] = true
|
27
|
+
end
|
28
|
+
|
29
|
+
@app.call(env)
|
30
|
+
end
|
31
|
+
|
32
|
+
def run(env)
|
33
|
+
raise NotImplementedError.new("Must be implemented!")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,17 +1,10 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module HostsUpdater
|
3
3
|
module Action
|
4
|
-
class CacheHosts
|
5
|
-
include HostsUpdater
|
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,16 +1,9 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module HostsUpdater
|
3
3
|
module Action
|
4
|
-
class RemoveHosts
|
5
|
-
include HostsUpdater
|
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
8
|
if machine_action != :destroy || !@machine.id
|
16
9
|
if machine_action != :suspend || false != @machine.config.hostsupdater.remove_on_suspend
|
@@ -22,7 +15,6 @@ module VagrantPlugins
|
|
22
15
|
end
|
23
16
|
end
|
24
17
|
end
|
25
|
-
@app.call(env)
|
26
18
|
end
|
27
19
|
|
28
20
|
end
|
@@ -1,24 +1,14 @@
|
|
1
|
-
require_relative "../HostsUpdater"
|
2
1
|
module VagrantPlugins
|
3
2
|
module HostsUpdater
|
4
3
|
module Action
|
5
|
-
class UpdateHosts
|
6
|
-
include HostsUpdater
|
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-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
|
@@ -78,14 +78,13 @@ module VagrantPlugins
|
|
78
78
|
|
79
79
|
def addHostEntries
|
80
80
|
ips = getIps
|
81
|
-
hostnames = getHostnames(ips)
|
82
81
|
file = File.open(@@hosts_path, "rb")
|
83
82
|
hostsContents = file.read
|
84
83
|
uuid = @machine.id
|
85
84
|
name = @machine.name
|
86
85
|
entries = []
|
87
|
-
ips.each do |ip|
|
88
|
-
hostnames
|
86
|
+
getHostnames(ips).each do |ip, hostnames|
|
87
|
+
hostnames.each do |hostname|
|
89
88
|
entryPattern = hostEntryPattern(ip, hostname)
|
90
89
|
|
91
90
|
if hostsContents.match(/#{entryPattern}/)
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative "HostsUpdater"
|
2
|
+
require_relative "Action/BaseAction"
|
3
|
+
require_relative "Action/UpdateHosts"
|
4
|
+
require_relative "Action/CacheHosts"
|
5
|
+
require_relative "Action/RemoveHosts"
|
4
6
|
|
5
7
|
module VagrantPlugins
|
6
8
|
module HostsUpdater
|
@@ -34,9 +36,6 @@ module VagrantPlugins
|
|
34
36
|
|
35
37
|
action_hook(:hostsupdater, :machine_action_destroy) do |hook|
|
36
38
|
hook.prepend(Action::CacheHosts)
|
37
|
-
end
|
38
|
-
|
39
|
-
action_hook(:hostsupdater, :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-hostsupdater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Falk Kühnel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- README.md
|
54
54
|
- Rakefile
|
55
55
|
- lib/vagrant-hostsupdater.rb
|
56
|
+
- lib/vagrant-hostsupdater/Action/BaseAction.rb
|
56
57
|
- lib/vagrant-hostsupdater/Action/CacheHosts.rb
|
57
58
|
- lib/vagrant-hostsupdater/Action/RemoveHosts.rb
|
58
59
|
- lib/vagrant-hostsupdater/Action/UpdateHosts.rb
|