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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de8ac4109c074a13324c748ae6bd3ca29b8d2cf2a874c73c7690c3702146b71c
4
- data.tar.gz: 2e95acea00c30c123dac5734ec6f0c65031eac978b31a0acdc42608fc924ab91
3
+ metadata.gz: cf3391d6244305c873b8834efcf5b5e5c893e7baa370e5104d28902b96e76597
4
+ data.tar.gz: 86a47931ca6969f238aad159bdcae64b580e7997cc77536643d5e082364813ef
5
5
  SHA512:
6
- metadata.gz: 162f3f085c82cd4743112a976b3226983d0c864a1b76de99cf005e0650d48812ddb93f6a2e27ded14cd925aed753db8da4fb10061436d23d7065c9e3ad3dd0a6
7
- data.tar.gz: 97c94753ddecd27568111abfbd2497aa33e24c4fa1afc3c22032a5256ea3478dd23c4c1f8550bf6811b48e65fdc1dfc21d15ac5b60747059b0b1de17d51a7a69
6
+ metadata.gz: 907a8beaa9333e35530a92248e07f82dda257e82cecd7c118f07ea79de50766422b722bb1f18d2766d592ad6fc115ff98e6ecc8f77a46e5e9a83e43b8a06e422
7
+ data.tar.gz: ed97599fa8b29267a0798dc6a6a9b9fdaf29d90ccf28b98524ee9eee21598fa4598b8f104e07854e48830f07c3ab65bc4d3fda488304f3c37bd69b6a3e99f96c
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
- gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v2.2.19'
4
+ gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant.git', :tag => 'v2.2.19'
5
5
  end
6
6
 
7
7
  group :plugins do
data/README.md CHANGED
@@ -117,6 +117,10 @@ vagrant plugin install vagrant-hostsupdater-*.gem
117
117
 
118
118
  ## Versions
119
119
 
120
+ ### 1.4.0
121
+
122
+ * Avoid duplicated hosts update entries
123
+
120
124
  ### 1.3.0
121
125
 
122
126
  * Fix issue with Vagrant versions > 2.2.7
@@ -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 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,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 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
- if machine_action != :destroy || !@machine.id
16
- if machine_action != :suspend || false != @machine.config.virtualhostsupdater.remove_on_suspend
17
- if machine_action != :halt || false != @machine.config.virtualhostsupdater.remove_on_suspend
18
- @ui.info "[vagrant-virtual-hostsupdater] Removing hosts"
19
- removeHostEntries
20
- else
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
 
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VirtualHostsUpdater
3
- VERSION = '1.3.0'
3
+ VERSION = '1.4.0'
4
4
  end
5
5
  end
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.3.0
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-03-22 00:00:00.000000000 Z
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.32
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