vagrant-goodhosts 1.1.7 → 1.1.9

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: 11b15f6a61eabd376e377893f51af05f0d0541b6bb3d51b7b67b86bc52ccad74
4
- data.tar.gz: 5cd6d720a97f94cccfa9ee3f36c7ab8a1d8cdeba3a8d8940f37097cf51ae6a68
3
+ metadata.gz: ef42ed7a5e7aceee9728b236457f28a23a9d041e7380733ceccaa375d1bb3336
4
+ data.tar.gz: 05d903561e67e846b6392f5c460edef92122c89404a15db654fb27c4071d1ded
5
5
  SHA512:
6
- metadata.gz: 79a5fa927822987c6b710baa941d20dccb61854099f83d0c7168f891355e439c04a85fd385984644bd3ca57b0e6f02378ce00a03ea1d7ac5bfa6d20ca6d6a4d7
7
- data.tar.gz: 5f9ab9f0e54a82e05516890f81ebd0042fb67a09322bb8528d4f2d6483b56fc05582814fc2bf5a61616668d9488c68b1e59c2411802f9d5366e2824390a3812a
6
+ metadata.gz: caae13a327c9677e1db6cb2b25c41a285eb63af9a62a21f6f9caeb5257986ebbaaf4cca436b7470879091586aa81b430a4edd49201eb97befae0eafeac3377ca
7
+ data.tar.gz: 2ab4ef0e085dba2d3b25fb9e09e576863e9cce00e6f2488b2772ea143b91421d1b22937aa2185c8b6fe37a969d3b3d435090119acbd9e47d821498160566a31a
data/README.md CHANGED
@@ -6,6 +6,8 @@ On **up**, **resume** and **reload** commands, it tries to add the hosts if they
6
6
 
7
7
  On **halt**, **destroy**, and **suspend**, those entries will be removed again. By setting the `config.goodhosts.remove_on_suspend = false`, **suspend** and **halt** will not remove them.
8
8
 
9
+ Supports: VirtualBox, Hyperv, Docker and Tart.
10
+
9
11
  ## Installation
10
12
 
11
13
  ```shell
@@ -140,4 +142,4 @@ vagrant plugin install vagrant-goodhosts-*.gem
140
142
 
141
143
  ## Test the plugin
142
144
 
143
- You need to run a Vagrant machine with the minimum settings specified in the [Usage](https://github.com/goodhosts/vagrant#usage) section, it is enough a turn on and off and in the meantime if the hosts file in your machine is written in the right way.
145
+ You need to run a Vagrant machine with the minimum settings specified in the [Usage](https://github.com/goodhosts/vagrant#usage) section, it is enough a turn on and off and in the meantime if the hosts file in your machine is written in the right way.
@@ -1,7 +1,6 @@
1
1
  # The core of the plugin
2
2
  require "rbconfig"
3
3
  require "open3"
4
- require "resolv"
5
4
  require "os"
6
5
 
7
6
  module VagrantPlugins
@@ -31,6 +30,14 @@ module VagrantPlugins
31
30
  @ui.info "[vagrant-goodhosts] Read guest IP #{ip} from Hyper-V provider"
32
31
  ips.push(ip) unless ip.nil? or ips.include? ip
33
32
  end
33
+ if @machine.provider_name == :tart
34
+ ssh_info = @machine.ssh_info
35
+ unless ssh_info.nil?
36
+ ip = @machine.ssh_info[:host]
37
+ @ui.info "[vagrant-goodhosts] Read guest IP #{ip} from Tart provider"
38
+ ips.push(ip) unless ip.nil? or ips.include? ip
39
+ end
40
+ end
34
41
  return ips
35
42
  end
36
43
 
@@ -90,22 +97,35 @@ module VagrantPlugins
90
97
  return true
91
98
  end
92
99
 
100
+ # Check if a specific IP/hostname mapping exists in the hosts file
101
+ # Uses the CLI check command instead of DNS resolution
102
+ def hosts_entry_exists?(ip_address, hostname)
103
+ cli = get_cli
104
+ # Use check command - no sudo needed for read-only operation
105
+ if cli.include? ".exe"
106
+ # Windows: direct command execution
107
+ _stdout, _stderr, status = Open3.capture3("\"#{cli}\" check \"#{ip_address}\" \"#{hostname}\"")
108
+ else
109
+ # Unix/macOS: no sudo needed for check
110
+ _stdout, _stderr, status = Open3.capture3("'#{cli}' check '#{ip_address}' '#{hostname}'")
111
+ end
112
+ return status.success?
113
+ rescue StandardError => e
114
+ @ui.warn "[vagrant-goodhosts] Error checking host entry: #{e.message}"
115
+ return false
116
+ end
117
+
93
118
  def check_hostnames_to_add(ip_address, hostnames)
94
119
  hostnames_to_add = Array.new
95
- hostnames = hostnames.split
96
- # check which hostnames actually need adding
97
- hostnames.each do |hostname|
98
- begin
99
- address = Resolv.getaddress(hostname)
100
- if address != ip_address
101
- hostnames_to_add.append(hostname)
102
- end
103
- rescue StandardError => _e
120
+ hostnames_arr = hostnames.split
121
+
122
+ # Check each hostname using the CLI check command
123
+ hostnames_arr.each do |hostname|
124
+ unless hosts_entry_exists?(ip_address, hostname)
104
125
  hostnames_to_add.append(hostname)
105
126
  end
106
- rescue StandardError => _e
107
- hostnames_to_add.append(hostname)
108
127
  end
128
+
109
129
  return hostnames_to_add.join(' ')
110
130
  end
111
131
 
Binary file
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module GoodHosts
3
- VERSION = '1.1.7'
3
+ VERSION = '1.1.9'
4
4
  end
5
5
  end
data/package.sh CHANGED
@@ -5,11 +5,11 @@ cd ./lib/vagrant-goodhosts/bundle
5
5
  # Download
6
6
  curl -s https://api.github.com/repos/goodhosts/cli/releases/latest | jq --raw-output '.assets[] | .browser_download_url' | xargs wget -i
7
7
  # Extract
8
- tar -zxvf goodhosts-1.1.2-darwin-amd64.tar.gz goodhosts && mv goodhosts cli_amd64_osx
9
- tar -zxvf goodhosts-1.1.2-darwin-arm64.tar.gz goodhosts && mv goodhosts cli_arm64_osx
10
- tar -zxvf goodhosts-1.1.2-linux-amd64.tar.gz goodhosts && mv goodhosts cli_amd64_linux
11
- tar -zxvf goodhosts-1.1.2-linux-arm64.tar.gz goodhosts && mv goodhosts cli_arm64_linux
12
- tar -zxvf goodhosts-1.1.2-windows-amd64.tar.gz goodhosts.exe && mv goodhosts.exe cli.exe
8
+ tar -zxvf goodhosts-1.1.3-darwin-amd64.tar.gz goodhosts && mv goodhosts cli_amd64_osx
9
+ tar -zxvf goodhosts-1.1.3-darwin-arm64.tar.gz goodhosts && mv goodhosts cli_arm64_osx
10
+ tar -zxvf goodhosts-1.1.3-linux-amd64.tar.gz goodhosts && mv goodhosts cli_amd64_linux
11
+ tar -zxvf goodhosts-1.1.3-linux-arm64.tar.gz goodhosts && mv goodhosts cli_arm64_linux
12
+ tar -zxvf goodhosts-1.1.3-windows-amd64.tar.gz goodhosts.exe && mv goodhosts.exe cli.exe
13
13
  rm -f ./*.tar.gz
14
14
  rm -f ./*.txt
15
15
  # Generate
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-goodhosts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniele Scasciafratte
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-01-26 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -85,7 +84,6 @@ homepage: https://github.com/goodhosts/vagrant
85
84
  licenses:
86
85
  - MIT
87
86
  metadata: {}
88
- post_install_message:
89
87
  rdoc_options: []
90
88
  require_paths:
91
89
  - lib
@@ -100,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
98
  - !ruby/object:Gem::Version
101
99
  version: '0'
102
100
  requirements: []
103
- rubygems_version: 3.4.20
104
- signing_key:
101
+ rubygems_version: 3.6.7
105
102
  specification_version: 4
106
103
  summary: Enables Vagrant to update hosts file on the host machine with goodhosts
107
104
  test_files: []