vagrant-docker-hosts-manager 0.3.0 → 0.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: 66272a00d09743fc1c067456c1680ac75768ca3d3c9534f1ad01eac5bf3b139e
4
- data.tar.gz: 24452535a62c76a094e86d77398697647207528e9cea5315b53b8031822ebfb5
3
+ metadata.gz: 31f682b4ed927a7e7b03a58a3a3c4aeac560d675c224f93b61c494cc497b2f90
4
+ data.tar.gz: 3b15c7c10d4321adfa3f6c80397bdad0d4efc14308ad5aebad4f93d55af57013
5
5
  SHA512:
6
- metadata.gz: 2ba755242cce735714503633ef65d425e9368fc0871bf85a268da447b32c3d7032610db4994707de04cf64df79ff94ab587815ddeb11ad3e3571664b7680b200
7
- data.tar.gz: d2e14700ece77c25e67c59b5a0c033f3daec0b86cea3227ff0438052163b9c577e39e8bb482ec0ef3e8f5e34a3a44471143dff13a45656f9884454f7bcc3f2d7
6
+ metadata.gz: '00967530b6cdc6a5833a77150ee3e440cc3d1b391e725ea612af204a0d555415ee74548ca9905bb53c54ed0bd85dee15caa258564395a04d3bbba312b572ca81'
7
+ data.tar.gz: 921722221561694c4f658a15e24354ed5e462378cae8162074aa98157e06d4e0d84e3acda9355cf667034646c4b222ee63fbafb8b349c2522c142d41ebe07798
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.0](https://github.com/julienpoirou/vagrant-docker-hosts-manager/compare/v0.3.0...v0.4.0) (2026-06-30)
4
+
5
+
6
+ ### Fonctionnalités ✨
7
+
8
+ * Improve plugin quality and publish RubyDoc ([47bd507](https://github.com/julienpoirou/vagrant-docker-hosts-manager/commit/47bd5076a2eb0cb9dbf9796ac8fe7ce58f3663dc))
9
+
10
+
11
+ ### Corrections 🐛
12
+
13
+ * Honor VDHM_HOSTS_PATH override on posix, not only windows ([f674f95](https://github.com/julienpoirou/vagrant-docker-hosts-manager/commit/f674f95ccbb70242e6f5e3923c4e606e0d7f8221))
14
+ * Track new util/action modules and specs to fix CI load error ([460fae3](https://github.com/julienpoirou/vagrant-docker-hosts-manager/commit/460fae3ebac8ab4dcfa1069610f7f28f1620d8ac))
15
+
3
16
  ## [0.3.0](https://github.com/julienpoirou/vagrant-docker-hosts-manager/compare/v0.2.0...v0.3.0) (2026-03-11)
4
17
 
5
18
 
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VagrantDockerHostsManager
4
+ module Action
5
+ class Apply
6
+ def initialize(app, _env) = (@app = app)
7
+
8
+ def call(env)
9
+ Util::I18n.setup!(env)
10
+ cfg = env[:machine].config.docker_hosts
11
+ ENV['VDHM_VERBOSE'] = '1' if cfg.respond_to?(:verbose) && cfg.verbose
12
+ mid = env[:machine].id || 'unknown'
13
+ dry = Util::I18n.env_flag('VDHM_DRY_RUN')
14
+ ui = env[:ui]
15
+ hoster = Util::HostsFile.new(env, owner_id: mid)
16
+
17
+ entries = compute_entries(env, cfg, ui)
18
+ if entries.empty?
19
+ UiHelpers.say(ui, ::I18n.t('vdhm.messages.no_entries'))
20
+ return
21
+ end
22
+
23
+ if dry
24
+ Util::Json.emit(action: 'apply', status: 'dry-run', data: { owner: mid, entries: entries })
25
+ return
26
+ end
27
+
28
+ hoster.apply(entries)
29
+ Util::Json.emit(action: 'apply', status: 'success', data: { owner: mid, entries: entries })
30
+ rescue StandardError => e
31
+ Util::Json.emit(action: 'apply', status: 'error', error: e.message, backtrace: e.backtrace&.first(3))
32
+ UiHelpers.error(ui, "VDHM: #{e.message}")
33
+ ensure
34
+ @app.call(env)
35
+ end
36
+
37
+ private
38
+
39
+ def compute_entries(_env, cfg, ui)
40
+ entries = {}
41
+
42
+ cfg.domains.each do |domain, ip|
43
+ next if domain.to_s.strip.empty?
44
+
45
+ if ip.nil? || ip.to_s.strip.empty?
46
+ UiHelpers.warn(ui, ::I18n.t('vdhm.messages.missing_ip_for', domain: domain))
47
+ next
48
+ end
49
+ entries[domain] = ip
50
+ end
51
+
52
+ if cfg.domain && !cfg.domain.strip.empty?
53
+ ip = cfg.ip || begin
54
+ Util::Docker.ip_for_container(cfg.container_name) if cfg.container_name && !cfg.container_name.strip.empty?
55
+ end
56
+ if ip && !ip.strip.empty?
57
+ UiHelpers.say(ui, ::I18n.t('vdhm.messages.detected_ip', domain: cfg.domain, ip: ip))
58
+ entries[cfg.domain] = ip
59
+ else
60
+ UiHelpers.warn(ui, ::I18n.t('vdhm.messages.no_ip_found', domain: cfg.domain, container: cfg.container_name))
61
+ end
62
+ end
63
+
64
+ entries
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VagrantDockerHostsManager
4
+ module Action
5
+ class Cleanup
6
+ def initialize(app, _env) = (@app = app)
7
+
8
+ def call(env)
9
+ Util::I18n.setup!(env)
10
+ cfg = env[:machine].config.docker_hosts
11
+ ENV['VDHM_VERBOSE'] = '1' if cfg.respond_to?(:verbose) && cfg.verbose
12
+ mid = env[:machine].id || 'unknown'
13
+ dry = Util::I18n.env_flag('VDHM_DRY_RUN')
14
+ purge = Util::I18n.env_flag('VDHM_PURGE_ON_DESTROY')
15
+ ui = env[:ui]
16
+ hoster = Util::HostsFile.new(env, owner_id: mid)
17
+
18
+ if dry
19
+ Util::Json.emit(action: 'cleanup', status: 'dry-run', data: { owner: mid, mode: purge ? 'all' : 'owner' })
20
+ return
21
+ end
22
+
23
+ removed = purge ? hoster.remove_all_managed! : hoster.remove!
24
+ Util::Json.emit(action: 'cleanup', status: 'success',
25
+ data: { owner: mid, removed: removed, mode: purge ? 'all' : 'owner' })
26
+ rescue StandardError => e
27
+ Util::Json.emit(action: 'cleanup', status: 'error', error: e.message)
28
+ UiHelpers.error(ui, "VDHM: #{e.message}")
29
+ ensure
30
+ @app.call(env)
31
+ end
32
+ end
33
+ end
34
+ end