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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c6b415c941a16c739c8f6b6c331fdd2b559c39e5c6ee3f7955779da3004e8b2
4
- data.tar.gz: 8cc732de6682cca8f91f5a03c99eef3b9bf519dc758736b81f6616bcd2d941c8
3
+ metadata.gz: 28da9dcc8ae93032fce5f1005a560e515d04c52dd7fbd8b59a4fe02a5dc28d9f
4
+ data.tar.gz: 9b52816b56418ef87eeb9d4570832af2b21f4a54e1ff3fff8410f58cf79cb42a
5
5
  SHA512:
6
- metadata.gz: 639e1a983ae8fd9011a02795f8dd7018ca9d16f06f7295d37f88e14c40a2061b346aff70111f2901181ca095d1767d420e092512aeb619203db99730376e1079
7
- data.tar.gz: 7e0f3e55b11a5b2af496cccfcbf595558eb1ca9fdd7c891ff519684c3ea1b3121663c6603cde76ea9de359989e4a341a2e8066455a121f63e99561796f90db52
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 initialize(app, env)
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 initialize(app, env)
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[ip].each do |hostname|
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
- require "vagrant-hostsupdater/Action/UpdateHosts"
2
- require "vagrant-hostsupdater/Action/CacheHosts"
3
- require "vagrant-hostsupdater/Action/RemoveHosts"
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
 
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module HostsUpdater
3
- VERSION = '1.2.1'
3
+ VERSION = '1.2.2'
4
4
  end
5
5
  end
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.1
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: 2020-12-03 00:00:00.000000000 Z
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