vagrant-goodhosts 1.0.17 → 1.1.0beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/default.yml +15 -0
- data/.rubocop.yml +68 -0
- data/Gemfile +2 -0
- data/lib/vagrant-goodhosts/Action/BaseAction.rb +3 -2
- data/lib/vagrant-goodhosts/Action/RemoveHosts.rb +3 -4
- data/lib/vagrant-goodhosts/Action/UpdateHosts.rb +4 -5
- data/lib/vagrant-goodhosts/GoodHosts.rb +141 -99
- data/lib/vagrant-goodhosts/config.rb +10 -9
- data/lib/vagrant-goodhosts/plugin.rb +5 -0
- data/lib/vagrant-goodhosts/version.rb +1 -1
- data/lib/vagrant-goodhosts.rb +3 -1
- data/vagrant-goodhosts.gemspec +3 -2
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58cfe3e3e7669fb2b8bf147db6786a38f6b94b8d4164460852872a007d2df40c
|
4
|
+
data.tar.gz: c5131a3c95e03d98a182092138ad55b1df1ae9cbe66ef7ad2800a2e3721b0d97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6d3be03ecd50f179a01380ccda77aaddeddc943d324179e750777222c1b974c50186492d9753bdc8c3ae47da032363fcde0862a045c4fa741fe3335d8c26077
|
7
|
+
data.tar.gz: 4fd89f66e460df2accaf9ceae0ed8736b257dfde7e3b1f19cb8a65877e62f87d14d88421c4a98141a371b4aaf0170843555a4bd07e96976c6b60f2923d088925
|
@@ -0,0 +1,15 @@
|
|
1
|
+
name: Linters
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v1
|
10
|
+
- name: RuboCop Linter
|
11
|
+
uses: andrewmcodes/rubocop-linter-action@v3.3.0
|
12
|
+
with:
|
13
|
+
exit_on_failure: true
|
14
|
+
env:
|
15
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- 'Gemfile'
|
4
|
+
- 'Rakefile'
|
5
|
+
- 'lib/vagrant-goodhosts/config.rb'
|
6
|
+
|
7
|
+
Naming/FileName:
|
8
|
+
Enabled: false
|
9
|
+
Naming/AccessorMethodName:
|
10
|
+
Enabled: false
|
11
|
+
Metrics/MethodLength:
|
12
|
+
Enabled: false
|
13
|
+
Metrics/PerceivedComplexity:
|
14
|
+
Enabled: false
|
15
|
+
Metrics/ModuleLength:
|
16
|
+
Enabled: false
|
17
|
+
Metrics/CyclomaticComplexity:
|
18
|
+
Enabled: false
|
19
|
+
Metrics/AbcSize:
|
20
|
+
Enabled: false
|
21
|
+
Style/FrozenStringLiteralComment:
|
22
|
+
Enabled: false
|
23
|
+
Style/RaiseArgs:
|
24
|
+
Enabled: false
|
25
|
+
Layout/LineLength:
|
26
|
+
Enabled: false
|
27
|
+
Style/StringLiterals:
|
28
|
+
Enabled: false
|
29
|
+
Style/ExpandPathArguments:
|
30
|
+
Enabled: false
|
31
|
+
Style/RedundantReturn:
|
32
|
+
Enabled: false
|
33
|
+
Style/SymbolArray:
|
34
|
+
Enabled: false
|
35
|
+
Style/ClassVars:
|
36
|
+
Enabled: false
|
37
|
+
Style/YodaCondition:
|
38
|
+
Enabled: false
|
39
|
+
Style/MethodCallWithoutArgsParentheses:
|
40
|
+
Enabled: false
|
41
|
+
Style/NumericPredicate:
|
42
|
+
Enabled: false
|
43
|
+
Style/ParallelAssignment:
|
44
|
+
Enabled: false
|
45
|
+
Style/Not:
|
46
|
+
Enabled: false
|
47
|
+
Style/EmptyLiteral:
|
48
|
+
Enabled: false
|
49
|
+
Style/IfUnlessModifier:
|
50
|
+
Enabled: false
|
51
|
+
Style/MutableConstant:
|
52
|
+
Enabled: false
|
53
|
+
Style/SymbolLiteral:
|
54
|
+
Enabled: false
|
55
|
+
Style/AccessorGrouping:
|
56
|
+
Enabled: false
|
57
|
+
Style/Next:
|
58
|
+
Enabled: false
|
59
|
+
Style/MultipleComparison:
|
60
|
+
Enabled: false
|
61
|
+
Style/FormatStringToken:
|
62
|
+
Enabled: false
|
63
|
+
Style/SoleNestedConditional:
|
64
|
+
Enabled: false
|
65
|
+
Style/GuardClause:
|
66
|
+
Enabled: false
|
67
|
+
Gemspec/RequiredRubyVersion:
|
68
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# Action to extend for the plugin needs, detects if it was already executed etc
|
1
2
|
module VagrantPlugins
|
2
3
|
module GoodHosts
|
3
4
|
module Action
|
5
|
+
# Extend it!
|
4
6
|
class BaseAction
|
5
7
|
include GoodHosts
|
6
8
|
|
@@ -35,10 +37,9 @@ module VagrantPlugins
|
|
35
37
|
@app.call(env)
|
36
38
|
end
|
37
39
|
|
38
|
-
def run(
|
40
|
+
def run(_env)
|
39
41
|
raise NotImplementedError.new("Must be implemented!")
|
40
42
|
end
|
41
|
-
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# Run when is removing the hosts
|
1
2
|
module VagrantPlugins
|
2
3
|
module GoodHosts
|
3
4
|
module Action
|
5
|
+
# Remove hosts
|
4
6
|
class RemoveHosts < BaseAction
|
5
|
-
|
6
7
|
def run(env)
|
7
8
|
machine_action = env[:machine_action]
|
8
9
|
|
@@ -12,11 +13,9 @@ module VagrantPlugins
|
|
12
13
|
if ([:halt, :suspend].include? machine_action) && (false == @machine.config.goodhosts.remove_on_suspend)
|
13
14
|
@ui.info "[vagrant-goodhosts] Removing hosts on suspend disabled"
|
14
15
|
else
|
15
|
-
|
16
|
-
removeHostEntries
|
16
|
+
remove_host_entries
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
@@ -1,13 +1,12 @@
|
|
1
|
+
# Run when is adding hosts
|
1
2
|
module VagrantPlugins
|
2
3
|
module GoodHosts
|
3
4
|
module Action
|
5
|
+
# Update hosts
|
4
6
|
class UpdateHosts < BaseAction
|
5
|
-
|
6
|
-
|
7
|
-
@ui.info "[vagrant-goodhosts] Checking for host entries"
|
8
|
-
addHostEntries()
|
7
|
+
def run(_env)
|
8
|
+
add_host_entries()
|
9
9
|
end
|
10
|
-
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -1,26 +1,30 @@
|
|
1
|
+
# The core of the plugin
|
1
2
|
require "rbconfig"
|
2
3
|
require "open3"
|
4
|
+
require "resolv"
|
5
|
+
require "os"
|
3
6
|
|
4
7
|
module VagrantPlugins
|
5
8
|
module GoodHosts
|
9
|
+
# Plugin module
|
6
10
|
module GoodHosts
|
7
|
-
def
|
11
|
+
def get_ips
|
8
12
|
ips = []
|
9
13
|
|
10
|
-
if @machine.config.vm.networks.
|
11
|
-
|
12
|
-
|
14
|
+
if @machine.config.vm.networks.empty?
|
15
|
+
@ui.error("[vagrant-goodhosts] No networks are available yet for this virtual machine to add IP/hosts for")
|
16
|
+
return ips
|
13
17
|
end
|
14
|
-
|
18
|
+
|
15
19
|
@machine.config.vm.networks.each do |network|
|
16
20
|
key, options = network[0], network[1]
|
17
|
-
ip = options[:ip] if (key == :private_network || key == :public_network) && options[:goodhosts] != "skip"
|
18
|
-
ips.push(ip) if ip
|
19
21
|
if options[:goodhosts] == "skip"
|
20
22
|
@ui.info '[vagrant-goodhosts] Skipped adding host entries (config.vm.network goodhosts: "skip" is set)'
|
21
23
|
end
|
24
|
+
ip = options[:ip] if (key == :private_network || key == :public_network) && options[:goodhosts] != "skip"
|
25
|
+
ips.push(ip) if ip
|
22
26
|
|
23
|
-
@machine.config.vm.provider :hyperv do
|
27
|
+
@machine.config.vm.provider :hyperv do
|
24
28
|
timeout = @machine.provider_config.ip_address_timeout
|
25
29
|
@ui.output("[vagrant-goodhosts] Waiting for the guest machine to report its IP address ( this might take some time, have patience )...")
|
26
30
|
@ui.detail("Timeout: #{timeout} seconds")
|
@@ -29,44 +33,39 @@ module VagrantPlugins
|
|
29
33
|
vmm_server_address: @machine.provider_config.vmm_server_address,
|
30
34
|
proxy_server_address: @machine.provider_config.proxy_server_address,
|
31
35
|
timeout: timeout,
|
32
|
-
machine: @machine
|
36
|
+
machine: @machine
|
33
37
|
}
|
34
38
|
network = @machine.provider.driver.read_guest_ip(options)
|
35
39
|
if network["ip"]
|
36
40
|
ips.push(network["ip"]) unless ips.include? network["ip"]
|
37
41
|
end
|
38
42
|
end
|
39
|
-
|
40
|
-
|
41
43
|
end
|
42
44
|
return ips
|
43
45
|
end
|
44
46
|
|
45
|
-
# https://stackoverflow.com/a/13586108/1902215
|
46
47
|
def get_os_binary
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
|
57
|
-
end)
|
48
|
+
if OS.windows?
|
49
|
+
return 'cli.exe'
|
50
|
+
elsif OS.mac?
|
51
|
+
return 'cli_osx'
|
52
|
+
elsif OS.linux?
|
53
|
+
return 'cli'
|
54
|
+
else
|
55
|
+
raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
|
56
|
+
end
|
58
57
|
end
|
59
58
|
|
60
59
|
def get_cli
|
61
60
|
binary = get_os_binary
|
62
|
-
path = File.expand_path(File.dirname(File.dirname(__FILE__)))
|
61
|
+
path = format('%s%s', File.expand_path(File.dirname(File.dirname(__FILE__))), "/vagrant-goodhosts/bundle/")
|
63
62
|
path = "#{path}#{binary}"
|
64
63
|
|
65
64
|
return path
|
66
65
|
end
|
67
66
|
|
68
67
|
# Get a hash of hostnames indexed by ip, e.g. { 'ip1': ['host1'], 'ip2': ['host2', 'host3'] }
|
69
|
-
def
|
68
|
+
def get_hostnames(ips)
|
70
69
|
hostnames = Hash.new { |h, k| h[k] = [] }
|
71
70
|
|
72
71
|
case @machine.config.goodhosts.aliases
|
@@ -84,126 +83,169 @@ module VagrantPlugins
|
|
84
83
|
|
85
84
|
return hostnames
|
86
85
|
end
|
87
|
-
|
88
|
-
def
|
86
|
+
|
87
|
+
def disable_clean(ip_address)
|
89
88
|
unless ip_address.nil?
|
90
89
|
return @machine.config.goodhosts.disable_clean
|
91
90
|
end
|
91
|
+
|
92
92
|
return true
|
93
93
|
end
|
94
94
|
|
95
|
-
def
|
96
|
-
|
97
|
-
|
95
|
+
def check_hostnames_to_add(ip_address, hostnames)
|
96
|
+
hostnames_to_add = Array.new
|
97
|
+
hostnames = hostnames.split
|
98
|
+
# check which hostnames actually need adding
|
99
|
+
hostnames.each do |hostname|
|
100
|
+
address = Resolv.getaddress(hostname)
|
101
|
+
if address != ip_address
|
102
|
+
hostnames_to_add.append(hostname)
|
103
|
+
end
|
104
|
+
rescue StandardError => _e
|
105
|
+
hostnames_to_add.append(hostname)
|
106
|
+
end
|
107
|
+
return hostnames_to_add
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_goodhost_entries(ip_address, hostnames)
|
98
111
|
cli = get_cli
|
99
|
-
|
100
|
-
|
101
|
-
|
112
|
+
if cli.include? ".exe"
|
113
|
+
clean = get_clean_parameter_by_system(ip_address, true)
|
114
|
+
command = "Start-Process '#{cli}' -ArgumentList \"add\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs"
|
115
|
+
stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", command)
|
116
|
+
else
|
117
|
+
clean = get_clean_parameter_by_system(ip_address, false)
|
118
|
+
command = "sudo '#{cli}' add #{clean} #{ip_address} #{hostnames}"
|
119
|
+
stdin, stdout, stderr, wait_thr = Open3.popen3(command)
|
120
|
+
end
|
121
|
+
return stdin, stdout, stderr, wait_thr, command
|
122
|
+
end
|
123
|
+
|
124
|
+
def add_host_entries
|
125
|
+
error = false
|
126
|
+
error_text = ''
|
127
|
+
command = ''
|
128
|
+
hostnames_by_ips = generate_hostnames_by_ips
|
129
|
+
|
130
|
+
return if hostnames_by_ips.none?
|
131
|
+
|
132
|
+
@ui.info "[vagrant-goodhosts] Checking for host entries"
|
102
133
|
|
103
134
|
hostnames_by_ips.each do |ip_address, hostnames|
|
104
135
|
if ip_address.nil?
|
105
136
|
@ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
|
106
137
|
next
|
107
138
|
end
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
clean = "--clean"
|
116
|
-
if disableClean(ip_address)
|
117
|
-
clean = ''
|
118
|
-
end
|
119
|
-
stdin, stdout, stderr, wait_thr = Open3.popen3("sudo '#{cli}' add #{clean} #{ip_address} #{hostnames}")
|
120
|
-
end
|
121
|
-
if !wait_thr.value.success?
|
139
|
+
|
140
|
+
# filter out the hosts we've already added
|
141
|
+
hosts_to_add = check_hostnames_to_add(ip_address, hostnames)
|
142
|
+
next if hosts_to_add.none?
|
143
|
+
|
144
|
+
_stdin, _stdout, stderr, wait_thr, command = add_goodhost_entries(ip_address, hosts_to_add)
|
145
|
+
unless wait_thr.value.success?
|
122
146
|
error = true
|
123
|
-
|
147
|
+
error_text = stderr.read.strip
|
124
148
|
end
|
125
149
|
end
|
126
|
-
|
150
|
+
print_readme(error, error_text, command)
|
127
151
|
end
|
128
152
|
|
129
|
-
def
|
130
|
-
error = false
|
131
|
-
errorText = ""
|
153
|
+
def remove_goodhost_entries(ip_address, hostnames)
|
132
154
|
cli = get_cli
|
133
|
-
|
155
|
+
if cli.include? ".exe"
|
156
|
+
clean = get_clean_parameter_by_system(ip_address, true)
|
157
|
+
command = "Start-Process '#{cli}' -ArgumentList \"remove\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs"
|
158
|
+
stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", command)
|
159
|
+
else
|
160
|
+
clean = get_clean_parameter_by_system(ip_address, false)
|
161
|
+
command = "sudo '#{cli}' remove #{clean} #{ip_address} #{hostnames}"
|
162
|
+
stdin, stdout, stderr, wait_thr = Open3.popen3(command)
|
163
|
+
end
|
164
|
+
return stdin, stdout, stderr, wait_thr, command
|
165
|
+
end
|
166
|
+
|
167
|
+
def remove_host_entries
|
168
|
+
error = false
|
169
|
+
error_text = ''
|
170
|
+
command = ''
|
171
|
+
hostnames_by_ips = generate_hostnames_by_ips
|
172
|
+
|
173
|
+
return if hostnames_by_ips.none?
|
134
174
|
|
135
|
-
|
175
|
+
@ui.info "[vagrant-goodhosts] Removing hosts"
|
136
176
|
|
137
177
|
hostnames_by_ips.each do |ip_address, hostnames|
|
138
178
|
if ip_address.nil?
|
139
179
|
@ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
|
140
180
|
next
|
141
181
|
end
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
clean = ''
|
146
|
-
end
|
147
|
-
stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"remove\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
|
148
|
-
else
|
149
|
-
clean = "\"--clean\","
|
150
|
-
if disableClean(ip_address)
|
151
|
-
clean = ''
|
152
|
-
end
|
153
|
-
stdin, stdout, stderr, wait_thr = Open3.popen3("sudo '#{cli}' remove #{clean} #{ip_address} #{hostnames}")
|
154
|
-
end
|
155
|
-
if !wait_thr.value.success?
|
182
|
+
|
183
|
+
_stdin, _stdout, stderr, wait_thr, command = remove_goodhost_entries(ip_address, hostnames)
|
184
|
+
unless wait_thr.value.success?
|
156
185
|
error = true
|
157
|
-
|
186
|
+
error_text = stderr.read.strip
|
158
187
|
end
|
159
188
|
end
|
160
|
-
|
189
|
+
print_readme(error, error_text, command)
|
190
|
+
end
|
191
|
+
|
192
|
+
def get_clean_parameter_by_system(ip_address, is_win)
|
193
|
+
clean = "--clean"
|
194
|
+
if is_win
|
195
|
+
clean = "\"--clean\","
|
196
|
+
end
|
197
|
+
|
198
|
+
if disable_clean(ip_address)
|
199
|
+
clean = ''
|
200
|
+
end
|
201
|
+
return clean
|
202
|
+
end
|
203
|
+
|
204
|
+
def print_readme(error, error_text, command)
|
205
|
+
unless error
|
206
|
+
return false
|
207
|
+
end
|
208
|
+
|
209
|
+
cli = get_cli
|
210
|
+
@ui.error "[vagrant-goodhosts] Issue executing goodhosts CLI: #{error_text}"
|
211
|
+
@ui.error "[vagrant-goodhosts] Command: #{command}"
|
212
|
+
@ui.error "[vagrant-goodhosts] Cli path: #{cli}"
|
213
|
+
if cli.include? ".exe"
|
214
|
+
@ui.error "[vagrant-goodhosts] Check the readme at https://github.com/goodhosts/vagrant#windows-uac-prompt"
|
215
|
+
exit
|
216
|
+
else
|
217
|
+
@ui.error "[vagrant-goodhosts] Check the readme at https://github.com/goodhosts/vagrant#passwordless-sudo"
|
218
|
+
end
|
161
219
|
end
|
162
220
|
|
163
|
-
def
|
164
|
-
if
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
@ui.error "[vagrant-goodhosts] Check the readme at https://github.com/goodhosts/vagrant#windows-uac-prompt"
|
170
|
-
exit
|
171
|
-
else
|
172
|
-
@ui.error "[vagrant-goodhosts] Check the readme at https://github.com/goodhosts/vagrant#passwordless-sudo"
|
221
|
+
def append_hostsnames_by_ips(hostnames_by_ips, hostnames, ip_address, ip_index)
|
222
|
+
if hostnames[ip_index].count() > 0
|
223
|
+
hostnames[ip_index].each do |hostname|
|
224
|
+
unless ip_address.nil?
|
225
|
+
@ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
|
226
|
+
end
|
173
227
|
end
|
228
|
+
hostnames_by_ips = { ip_address => hostnames[ip_index].join(" ") }
|
174
229
|
end
|
230
|
+
return hostnames_by_ips
|
175
231
|
end
|
176
232
|
|
177
|
-
def
|
233
|
+
def generate_hostnames_by_ips
|
178
234
|
hostnames_by_ips = []
|
179
|
-
ips =
|
235
|
+
ips = get_ips
|
180
236
|
if ips.count() < 1
|
181
237
|
@ui.error("[vagrant-goodhosts] No ip address found for this virtual machine")
|
182
238
|
return hostnames_by_ips
|
183
239
|
end
|
184
|
-
hostnames =
|
240
|
+
hostnames = get_hostnames(ips)
|
185
241
|
if ips.count() > 1
|
186
242
|
ips.each do |ip|
|
187
243
|
ip_address = ip
|
188
|
-
|
189
|
-
hostnames[ip].each do |hostname|
|
190
|
-
if !ip_address.nil?
|
191
|
-
@ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
|
192
|
-
end
|
193
|
-
end
|
194
|
-
hostnames_by_ips = { ip_address => hostnames[ip].join(" ") }
|
195
|
-
end
|
244
|
+
hostnames_by_ips = append_hostsnames_by_ips(hostnames_by_ips, hostnames, ip_address, ip)
|
196
245
|
end
|
197
246
|
else
|
198
247
|
ip_address = ips[0]
|
199
|
-
|
200
|
-
hostnames[ip_address].each do |hostname|
|
201
|
-
if !ip_address.nil?
|
202
|
-
@ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
|
203
|
-
end
|
204
|
-
end
|
205
|
-
hostnames_by_ips = { ip_address => hostnames[ip_address].join(" ") }
|
206
|
-
end
|
248
|
+
hostnames_by_ips = append_hostsnames_by_ips(hostnames_by_ips, hostnames, ip_address, ip_address)
|
207
249
|
end
|
208
250
|
|
209
251
|
return hostnames_by_ips
|
@@ -2,16 +2,17 @@ require "vagrant"
|
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
4
|
module GoodHosts
|
5
|
+
# Vagrant plugin definition
|
5
6
|
class Config < Vagrant.plugin("2", :config)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
attr_accessor :aliases
|
8
|
+
attr_accessor :id
|
9
|
+
attr_accessor :remove_on_suspend
|
10
|
+
attr_accessor :disable_clean
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@remove_on_suspend = true
|
14
|
+
@disable_clean = true
|
15
|
+
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -5,6 +5,7 @@ require_relative "Action/RemoveHosts"
|
|
5
5
|
|
6
6
|
module VagrantPlugins
|
7
7
|
module GoodHosts
|
8
|
+
# Various Vagrant hooks
|
8
9
|
class Plugin < Vagrant.plugin('2')
|
9
10
|
name 'GoodHosts'
|
10
11
|
description <<-DESC
|
@@ -21,6 +22,10 @@ module VagrantPlugins
|
|
21
22
|
hook.append(Action::UpdateHosts)
|
22
23
|
end
|
23
24
|
|
25
|
+
action_hook(:goodhosts, :machine_action_boot) do |hook|
|
26
|
+
hook.append(Action::UpdateHosts)
|
27
|
+
end
|
28
|
+
|
24
29
|
action_hook(:goodhosts, :machine_action_provision) do |hook|
|
25
30
|
hook.before(Vagrant::Action::Builtin::Provision, Action::UpdateHosts)
|
26
31
|
end
|
data/lib/vagrant-goodhosts.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# Root file of the plugin
|
1
2
|
require "vagrant-goodhosts/version"
|
2
3
|
require "vagrant-goodhosts/plugin"
|
3
4
|
|
5
|
+
# Extend Vagrant Plugins
|
4
6
|
module VagrantPlugins
|
7
|
+
# Load our plugin
|
5
8
|
module GoodHosts
|
6
9
|
def self.source_root
|
7
10
|
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
8
11
|
end
|
9
12
|
end
|
10
13
|
end
|
11
|
-
|
data/vagrant-goodhosts.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'vagrant-goodhosts/version'
|
@@ -14,7 +13,7 @@ Gem::Specification.new do |s|
|
|
14
13
|
s.homepage = 'https://github.com/goodhosts/vagrant'
|
15
14
|
s.license = 'MIT'
|
16
15
|
|
17
|
-
s.files = `git ls-files`.split(
|
16
|
+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
18
17
|
s.files += Dir.glob("lib/vagrant-goodhosts/bundle/*")
|
19
18
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
19
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
@@ -22,4 +21,6 @@ Gem::Specification.new do |s|
|
|
22
21
|
|
23
22
|
s.add_development_dependency 'bundler', '~> 1.3'
|
24
23
|
s.add_development_dependency 'rake'
|
24
|
+
|
25
|
+
s.add_runtime_dependency "os"
|
25
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-goodhosts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniele Scasciafratte
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: os
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Enables Vagrant to update hosts file on the host machine with goodhosts
|
42
56
|
email:
|
43
57
|
- mte90net@gmail.com
|
@@ -45,7 +59,9 @@ executables: []
|
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
62
|
+
- ".github/workflows/default.yml"
|
48
63
|
- ".gitignore"
|
64
|
+
- ".rubocop.yml"
|
49
65
|
- Gemfile
|
50
66
|
- LICENSE.txt
|
51
67
|
- README.md
|
@@ -67,7 +83,7 @@ homepage: https://github.com/goodhosts/vagrant
|
|
67
83
|
licenses:
|
68
84
|
- MIT
|
69
85
|
metadata: {}
|
70
|
-
post_install_message:
|
86
|
+
post_install_message:
|
71
87
|
rdoc_options: []
|
72
88
|
require_paths:
|
73
89
|
- lib
|
@@ -78,12 +94,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
94
|
version: '0'
|
79
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
96
|
requirements:
|
81
|
-
- - "
|
97
|
+
- - ">"
|
82
98
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
99
|
+
version: 1.3.1
|
84
100
|
requirements: []
|
85
|
-
rubygems_version: 3.2.
|
86
|
-
signing_key:
|
101
|
+
rubygems_version: 3.2.27
|
102
|
+
signing_key:
|
87
103
|
specification_version: 4
|
88
104
|
summary: Enables Vagrant to update hosts file on the host machine with goodhosts
|
89
105
|
test_files: []
|