vagrant-docker-networks-manager 1.0.7 → 1.2.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: 8281a2e02280d3ddf164b1a125ac3d28443a0d32addb7363309b7ef08d3ac204
4
- data.tar.gz: aba6e4f4e8f154894042ea9015e6db89c3d0f512f63f6de3d60261bcf8121f02
3
+ metadata.gz: 6d5a48a335e256e279964831b52c2afe001b19e123fe2dd3d7697c3730f7e443
4
+ data.tar.gz: 2446d67c42582a72d99069b77c6217622ea44a543ecf732176eda26b04230040
5
5
  SHA512:
6
- metadata.gz: 197d66d87aa0099955f3ea2dc9d65f2c2d2fca595b6331912c1a6c8f3e519d68270a38cce3af2e2b9f3731bda65d1394cfbe6344526bc37cbbf79a7a59916858
7
- data.tar.gz: 643c60df1fcfa0dbbf8603e230711226b06c3510e614917ba42c0f3a888f0926cab70ec77f486490b581c4cd04b35b6b6085ac3b9f71ca2313e49b6dd19a25a8
6
+ metadata.gz: d09f4737e381492fd6b79067b8683ed788bdfa1e12e03b29106ce233e29ef061e3eda01272365da578a1140190089c8d8e9a1f2dca56c21e1f90d14f4fee8a44
7
+ data.tar.gz: de4e532b638f0da54869a2555e3e27cb0a56e163a87581457c011d1051c3555763358e03cffc60b7b05a18e9c37d90cc1d1f46185941f38dc8edcb3ecd5cc53d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.0](https://github.com/julienpoirou/vagrant-docker-networks-manager/compare/v1.1.0...v1.2.0) (2026-07-05)
4
+
5
+
6
+ ### Fonctionnalités ✨
7
+
8
+ * Improve plugin quality and publish RubyDoc ([25f1767](https://github.com/julienpoirou/vagrant-docker-networks-manager/commit/25f17676c62a19c663664c3dbf4a9b97757d466c))
9
+
10
+
11
+ ### Corrections 🐛
12
+
13
+ * Stub container_network_mode in command specs to unbreak CI ([422491e](https://github.com/julienpoirou/vagrant-docker-networks-manager/commit/422491e699139292a1a2edac976d9fb93314f7c5))
14
+ * Wire the workflow_dispatch tag input and make Publish release-safe ([05a1d46](https://github.com/julienpoirou/vagrant-docker-networks-manager/commit/05a1d46f3c6dd3132e2a64dfde13dcab9a3310ca))
15
+
16
+ ## [1.1.0](https://github.com/julienpoirou/vagrant-docker-networks-manager/compare/v1.0.7...v1.1.0) (2026-03-11)
17
+
18
+
19
+ ### Fonctionnalités ✨
20
+
21
+ * **i18n:** Add connect_container log message in en/fr ([0608f9e](https://github.com/julienpoirou/vagrant-docker-networks-manager/commit/0608f9eead6942a97f738e5343918a5efc6a3c86))
22
+
23
+
24
+ ### Corrections 🐛
25
+
26
+ * **error:** Replace bare rescue with rescue StandardError throughout ([5db1d12](https://github.com/julienpoirou/vagrant-docker-networks-manager/commit/5db1d1268ca63a624f2e2c4fc2c4e1f6cbfb5d29))
27
+
3
28
  ## [1.0.7](https://github.com/julienpoirou/vagrant-docker-networks-manager/compare/v1.0.6...v1.0.7) (2025-08-18)
4
29
 
5
30
 
data/README.md CHANGED
@@ -7,6 +7,7 @@
7
7
  [![License](https://img.shields.io/github/license/julienpoirou/vagrant-docker-networks-manager.svg)](LICENSE.md)
8
8
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196.svg)](https://www.conventionalcommits.org)
9
9
  [![Renovate](https://img.shields.io/badge/Renovate-enabled-brightgreen.svg)](https://renovatebot.com)
10
+ [![Total downloads](https://img.shields.io/gem/dt/vagrant-docker-networks-manager?logo=rubygems&label=downloads)](https://rubygems.org/gems/vagrant-docker-networks-manager)
10
11
 
11
12
  Vagrant plugin to **manage Docker networks** with labeled ownership, safe lifecycle hooks, JSON output, and conflict-aware validation.
12
13
 
@@ -280,10 +281,7 @@ Emojis can be disabled with `--no-emoji`.
280
281
 
281
282
  ## Permissions & OS notes
282
283
 
283
- - **Linux / macOS**: modifying `/etc/hosts` requires privileges. The plugin pipes through `sudo tee -a` when appending, and writes the file when removing. You may be prompted for your password.
284
- - **Windows**: the plugin uses **PowerShell elevation** (`Start-Process -Verb RunAs`) when needed to append or rewrite the hosts file.
285
-
286
- > If your shell is already elevated (root/Admin), no prompts appear.
284
+ This plugin only calls `docker` CLI commands — no elevated privileges are required by the plugin itself. However, the Docker daemon must be reachable by the current user (e.g. the user must be in the `docker` group on Linux, or Docker Desktop must be running on macOS/Windows).
287
285
 
288
286
  ---
289
287
 
@@ -1 +1 @@
1
- 1.0.7
1
+ 1.2.0
@@ -12,15 +12,17 @@ require_relative "version"
12
12
 
13
13
  module VagrantDockerNetworksManager
14
14
  class ActionUp
15
+ # Vagrant middleware entry point that ensures the configured Docker network exists.
15
16
  def initialize(app, _env); @app = app; end
16
17
 
17
18
  def call(env)
18
19
  UiHelpers.setup_i18n!
19
20
  cfg = env[:machine].config.docker_network
20
- set_locale!(cfg)
21
+ UiHelpers.setup_locale_from_config!(cfg)
22
+ ui = env[:ui]
21
23
 
22
24
  unless Util.docker_available?
23
- env[:ui].error("#{UiHelpers.e(:error)} #{I18n.t('errors.docker_unavailable')}")
25
+ UiHelpers.error(ui, "#{UiHelpers.e(:error)} #{I18n.t('vdnm.errors.docker_unavailable')}")
24
26
  return @app.call(env)
25
27
  end
26
28
 
@@ -30,15 +32,15 @@ module VagrantDockerNetworksManager
30
32
  if Util.docker_network_exists?(name)
31
33
  if owned_by_this_machine?(name, mid)
32
34
  write_marker(env, name, cfg)
33
- env[:ui].info("#{UiHelpers.e(:success)} #{I18n.t('messages.network_exists_adopted', name: name)}")
35
+ UiHelpers.say(ui, "#{UiHelpers.e(:success)} #{I18n.t('vdnm.messages.network_exists_adopted', name: name)}")
34
36
  else
35
- env[:ui].info("#{UiHelpers.e(:info)} #{I18n.t('messages.network_exists', name: name)}")
37
+ UiHelpers.say(ui, "#{UiHelpers.e(:info)} #{I18n.t('vdnm.messages.network_exists', name: name)}")
36
38
  end
37
39
  else
38
40
  subnet_label = cfg.network_subnet || "-"
39
41
 
40
42
  if cfg.network_subnet && !VagrantDockerNetworksManager::Util.valid_subnet?(cfg.network_subnet)
41
- env[:ui].error("#{UiHelpers.e(:error)} #{I18n.t('errors.invalid_subnet')}")
43
+ UiHelpers.error(ui, "#{UiHelpers.e(:error)} #{I18n.t('vdnm.errors.invalid_subnet')}")
42
44
  return @app.call(env)
43
45
  end
44
46
 
@@ -47,19 +49,20 @@ module VagrantDockerNetworksManager
47
49
  cfg.network_subnet,
48
50
  ignore_network: name
49
51
  )
50
- env[:ui].error("#{UiHelpers.e(:error)} #{I18n.t('errors.subnet_in_use')}")
52
+ UiHelpers.error(ui, "#{UiHelpers.e(:error)} #{I18n.t('vdnm.errors.subnet_in_use')}")
51
53
  return @app.call(env)
52
54
  end
53
55
 
54
- env[:ui].info("#{UiHelpers.e(:ongoing)} #{I18n.t('log.create_network', name: name, subnet: subnet_label)}")
56
+ UiHelpers.say(ui,
57
+ "#{UiHelpers.e(:ongoing)} #{I18n.t('vdnm.log.create_network', name: name, subnet: subnet_label)}")
55
58
  builder = NetworkBuilder.new(cfg, machine_id: mid)
56
59
  args = builder.build_create_command_args
57
60
  if Util.sh!(*args)
58
61
  write_marker(env, name, cfg)
59
- env[:ui].info("#{UiHelpers.e(:success)} #{I18n.t('log.ok')}")
62
+ UiHelpers.say(ui, "#{UiHelpers.e(:success)} #{I18n.t('vdnm.log.ok')}")
60
63
  else
61
64
  rendered = args.shelljoin
62
- env[:ui].error("#{UiHelpers.e(:error)} #{I18n.t('messages.create_failed', cmd: rendered)}")
65
+ UiHelpers.error(ui, "#{UiHelpers.e(:error)} #{I18n.t('vdnm.messages.create_failed', cmd: rendered)}")
63
66
  end
64
67
  end
65
68
 
@@ -68,15 +71,9 @@ module VagrantDockerNetworksManager
68
71
 
69
72
  private
70
73
 
71
- def set_locale!(cfg)
72
- lang = cfg.locale || ENV["VDNM_LANG"]
73
- return unless lang
74
- UiHelpers.set_locale!(lang)
75
- rescue UiHelpers::UnsupportedLocaleError
76
- UiHelpers.set_locale!("en")
77
- end
78
-
79
74
  def write_marker(env, name, cfg)
75
+ # The marker is a local fallback ownership record; Docker labels remain
76
+ # the cross-process/source-of-truth check when the network still exists.
80
77
  m_id = env[:machine].id
81
78
  dir = env[:machine].data_dir.join("docker-networks")
82
79
  FileUtils.mkdir_p(dir)
@@ -99,7 +96,7 @@ module VagrantDockerNetworksManager
99
96
  }
100
97
  File.write(marker, JSON.pretty_generate(payload))
101
98
  rescue => e
102
- env[:ui].warn("marker write failed for '#{name}': #{e.message}")
99
+ UiHelpers.warn(env[:ui], "marker write failed for '#{name}': #{e.message}")
103
100
  end
104
101
 
105
102
  def owned_by_this_machine?(name, machine_id)
@@ -110,15 +107,17 @@ module VagrantDockerNetworksManager
110
107
  end
111
108
 
112
109
  class ActionDestroy
110
+ # Vagrant middleware entry point that removes owned Docker networks on destroy.
113
111
  def initialize(app, _env); @app = app; end
114
112
 
115
113
  def call(env)
116
114
  UiHelpers.setup_i18n!
117
115
  cfg = env[:machine].config.docker_network
118
- set_locale!(cfg)
116
+ UiHelpers.setup_locale_from_config!(cfg)
117
+ ui = env[:ui]
119
118
 
120
119
  unless Util.docker_available?
121
- env[:ui].error("#{UiHelpers.e(:error)} #{I18n.t('errors.docker_unavailable')}")
120
+ UiHelpers.error(ui, "#{UiHelpers.e(:error)} #{I18n.t('vdnm.errors.docker_unavailable')}")
122
121
  return @app.call(env)
123
122
  end
124
123
 
@@ -131,7 +130,7 @@ module VagrantDockerNetworksManager
131
130
  end
132
131
 
133
132
  if created_by_this_machine?(env, name) || owned_by_this_machine?(name, mid)
134
- env[:ui].info("#{UiHelpers.e(:broom)} #{I18n.t('messages.remove_network', name: name)}")
133
+ UiHelpers.say(ui, "#{UiHelpers.e(:broom)} #{I18n.t('vdnm.messages.remove_network', name: name)}")
135
134
 
136
135
  if Util.docker_network_exists?(name)
137
136
  out, _e, st = Open3.capture3("docker", "network", "inspect", name)
@@ -140,30 +139,30 @@ module VagrantDockerNetworksManager
140
139
  info = JSON.parse(out).first
141
140
  (info["Containers"] || {}).values.each do |c|
142
141
  cn = c["Name"]
143
- env[:ui].info("#{UiHelpers.e(:ongoing)} #{I18n.t('log.disconnect_container', name: cn)}")
142
+ UiHelpers.say(ui, "#{UiHelpers.e(:ongoing)} #{I18n.t('vdnm.log.disconnect_container', name: cn)}")
144
143
  Util.sh!("network", "disconnect", "--force", name, cn)
145
144
  if ENV["VDNM_DESTROY_WITH_CONTAINERS"] == "1"
146
- env[:ui].info("#{UiHelpers.e(:ongoing)} #{I18n.t('log.remove_container', name: cn)}")
145
+ UiHelpers.say(ui, "#{UiHelpers.e(:ongoing)} #{I18n.t('vdnm.log.remove_container', name: cn)}")
147
146
  Util.sh!("rm", "-f", cn)
148
147
  end
149
148
  end
150
149
  rescue => e
151
- env[:ui].warn("failed to parse containers for '#{name}': #{e.message}")
150
+ UiHelpers.warn(ui, "failed to parse containers for '#{name}': #{e.message}")
152
151
  end
153
152
  end
154
153
 
155
154
  if Util.sh!("network", "rm", name)
156
155
  delete_marker(env, name)
157
- env[:ui].info("#{UiHelpers.e(:success)} #{I18n.t('log.ok')}")
156
+ UiHelpers.say(ui, "#{UiHelpers.e(:success)} #{I18n.t('vdnm.log.ok')}")
158
157
  else
159
- env[:ui].warn("#{UiHelpers.e(:warning)} #{I18n.t('errors.remove_failed')}")
158
+ UiHelpers.warn(ui, "#{UiHelpers.e(:warning)} #{I18n.t('vdnm.errors.remove_failed')}")
160
159
  end
161
160
  else
162
161
  delete_marker(env, name)
163
- env[:ui].info("#{UiHelpers.e(:info)} #{I18n.t('messages.nothing_to_do')}")
162
+ UiHelpers.say(ui, "#{UiHelpers.e(:info)} #{I18n.t('vdnm.messages.nothing_to_do')}")
164
163
  end
165
164
  else
166
- env[:ui].info("#{UiHelpers.e(:broom)} #{I18n.t('messages.nothing_to_do')}")
165
+ UiHelpers.say(ui, "#{UiHelpers.e(:broom)} #{I18n.t('vdnm.messages.nothing_to_do')}")
167
166
  end
168
167
 
169
168
  @app.call(env)
@@ -171,19 +170,13 @@ module VagrantDockerNetworksManager
171
170
 
172
171
  private
173
172
 
174
- def set_locale!(cfg)
175
- lang = cfg.locale || ENV["VDNM_LANG"]
176
- return unless lang
177
- UiHelpers.set_locale!(lang)
178
- rescue UiHelpers::UnsupportedLocaleError
179
- UiHelpers.set_locale!("en")
180
- end
181
-
182
173
  def marker_path(env, name)
183
174
  env[:machine].data_dir.join("docker-networks", "#{name}.json")
184
175
  end
185
176
 
186
177
  def created_by_this_machine?(env, name)
178
+ # Trust the marker only for this machine id to avoid removing a network
179
+ # created or adopted by another Vagrant environment.
187
180
  marker = marker_path(env, name)
188
181
  return false unless File.exist?(marker)
189
182
  j = JSON.parse(File.read(marker)) rescue {}