kitchen-vagrant 1.6.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea05c234c21fba360397e3555d800f354cd9a6997ab16c2ffaceaaaa46c0b52a
4
- data.tar.gz: d1cb7e7e751b379c04274bb5df10d699d62b42fa39b5d58e97baa37546d9f7a1
3
+ metadata.gz: c8ffff4597560fe5c80e680f81e3b0f7cf64389c7cb9d3142fb88e5fe1e23996
4
+ data.tar.gz: 39a1151b4a7a2009ee22e7071f534244e140b6065535cd861daa5ed243081a5d
5
5
  SHA512:
6
- metadata.gz: 54f09922713934463de54ec0dfffbc38068730b021b20f1103d2a024c7969c61349d1b422abadd34b347c7193c55df2842d5b5ebf111119fa9ffe162de92769d
7
- data.tar.gz: 11f919e37cacab6ab7c7d880f6d1834d21b21ecf8a317ed0c1c1adbd16791e6bdd5cab2c65461f32ad59468df92937066ff5bf967e26b8733ada11d4161bce72
6
+ metadata.gz: 8ff409ccb93f5e33ef1077636c640efd72d45af0ce18227902b82012608b2af5a724e7ccec0010f3d8c2b0b0b6fd67364b613a56e8ff761f72c0e4ce660dd901
7
+ data.tar.gz: 519c45a62165f08d5caf1bb57cbd5d7a653cf0329c78309bca700cacc9a3fd654122fa24979c85dc87f5f9fae0e2794785739438c85f6d1289ac780ce3bd6166
@@ -15,9 +15,9 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "mixlib/shellout"
19
- require "fileutils"
20
- require "json"
18
+ require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
19
+ require "fileutils" unless defined?(FileUtils)
20
+ require "json" unless defined?(JSON)
21
21
 
22
22
  module Kitchen
23
23
  module Driver
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,13 +15,13 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "erb"
20
- require "fileutils"
18
+ require "erb" unless defined?(Erb)
19
+ require "fileutils" unless defined?(FileUtils)
21
20
  require "rubygems/version"
22
21
 
23
22
  require "kitchen"
24
- require "kitchen/driver/vagrant_version"
25
- require "kitchen/driver/helpers"
23
+ require_relative "vagrant_version"
24
+ require_relative "helpers"
26
25
 
27
26
  module Kitchen
28
27
 
@@ -45,6 +44,10 @@ module Kitchen
45
44
 
46
45
  default_config :box_check_update, nil
47
46
 
47
+ default_config :box_auto_update, nil
48
+
49
+ default_config :box_auto_prune, nil
50
+
48
51
  default_config :box_download_insecure, nil
49
52
 
50
53
  default_config :box_download_ca_cert, nil
@@ -109,6 +112,8 @@ module Kitchen
109
112
  def create(state)
110
113
  create_vagrantfile
111
114
  run_pre_create_command
115
+ run_box_auto_update
116
+ run_box_auto_prune
112
117
  run_vagrant_up
113
118
  update_state(state)
114
119
  instance.transport.connection(state).wait_until_ready
@@ -172,6 +177,8 @@ module Kitchen
172
177
  def finalize_config!(instance)
173
178
  super
174
179
  finalize_vm_hostname!
180
+ finalize_box_auto_update!
181
+ finalize_box_auto_prune!
175
182
  finalize_pre_create_command!
176
183
  finalize_synced_folders!
177
184
  finalize_ca_cert!
@@ -238,7 +245,7 @@ module Kitchen
238
245
  # box
239
246
  # @api private
240
247
  def bento_box?(name)
241
- name =~ /^(centos|debian|fedora|freebsd|opensuse|ubuntu|oracle|hardenedbsd|amazonlinux)-/
248
+ name =~ /^(centos|debian|fedora|freebsd|opensuse|ubuntu|oracle|hardenedbsd|amazonlinux|almalinux)-/
242
249
  end
243
250
 
244
251
  # Returns whether or not the we expect the box to work with shared folders
@@ -247,9 +254,9 @@ module Kitchen
247
254
  # shared folders
248
255
  # @api private
249
256
  def safe_share?(box)
250
- return false if config[:provider] =~ /(hyperv|libvirt)/
257
+ return false if /(hyperv|libvirt)/.match?(config[:provider])
251
258
 
252
- box =~ %r{^bento/(centos|debian|fedora|opensuse|ubuntu|oracle|amazonlinux)-}
259
+ box =~ %r{^bento/(centos|debian|fedora|opensuse|ubuntu|oracle|amazonlinux|almalinux)-}
253
260
  end
254
261
 
255
262
  # Return true if we found the criteria to enable the cache_directory
@@ -299,6 +306,20 @@ module Kitchen
299
306
  end
300
307
  end
301
308
 
309
+ # Create vagrant command to update box to the latest version
310
+ def finalize_box_auto_update!
311
+ return if config[:box_auto_update].nil?
312
+
313
+ config[:box_auto_update] = "vagrant box update #{"--insecure " if config[:box_download_insecure]}--box #{config[:box]}"
314
+ end
315
+
316
+ # Create vagrant command to remove older versions of the box
317
+ def finalize_box_auto_prune!
318
+ return if config[:box_auto_prune].nil?
319
+
320
+ config[:box_auto_prune] = "vagrant box prune --keep-active-boxes --name #{config[:box]}"
321
+ end
322
+
302
323
  # Replaces any `{{vagrant_root}}` tokens in the pre create command.
303
324
  #
304
325
  # @api private
@@ -461,6 +482,26 @@ module Kitchen
461
482
  end
462
483
  # rubocop:enable Metrics/CyclomaticComplexity
463
484
 
485
+ # Tell vagrant to update vagrant box to latest version
486
+ def run_box_auto_update
487
+ if config[:box_auto_update]
488
+ begin
489
+ run(config[:box_auto_update])
490
+ rescue Kitchen::ShellOut::ShellCommandFailed => e
491
+ # If the box has never been downloaded, the update command will fail with this message.
492
+ # Just ignore it and move on. Re-raise all other errors.
493
+ raise e unless e.message.match?(/The box '.*' does not exist/m)
494
+ end
495
+ end
496
+ end
497
+
498
+ # Tell vagrant to remove older vagrant boxes
499
+ def run_box_auto_prune
500
+ if config[:box_auto_prune]
501
+ run(config[:box_auto_prune])
502
+ end
503
+ end
504
+
464
505
  # Runs a local command before `vagrant up` has been called.
465
506
  #
466
507
  # @api private
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -21,6 +20,6 @@ module Kitchen
21
20
  module Driver
22
21
 
23
22
  # Version string for Vagrant Kitchen driver
24
- VAGRANT_VERSION = "1.6.0".freeze
23
+ VAGRANT_VERSION = "1.8.0".freeze
25
24
  end
26
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-vagrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-06 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -30,76 +30,6 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '3'
33
- - !ruby/object:Gem::Dependency
34
- name: countloc
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '0.4'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '0.4'
47
- - !ruby/object:Gem::Dependency
48
- name: rake
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- - !ruby/object:Gem::Dependency
62
- name: rspec
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '3.2'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '3.2'
75
- - !ruby/object:Gem::Dependency
76
- name: simplecov
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '0.9'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '0.9'
89
- - !ruby/object:Gem::Dependency
90
- name: chefstyle
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
33
  description: Kitchen::Driver::Vagrant - A Vagrant Driver for Test Kitchen.
104
34
  email:
105
35
  - fnichol@nichol.ca
@@ -117,7 +47,7 @@ homepage: https://github.com/test-kitchen/kitchen-vagrant/
117
47
  licenses:
118
48
  - Apache-2.0
119
49
  metadata: {}
120
- post_install_message:
50
+ post_install_message:
121
51
  rdoc_options: []
122
52
  require_paths:
123
53
  - lib
@@ -125,15 +55,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
55
  requirements:
126
56
  - - ">="
127
57
  - !ruby/object:Gem::Version
128
- version: '2.3'
58
+ version: '2.5'
129
59
  required_rubygems_version: !ruby/object:Gem::Requirement
130
60
  requirements:
131
61
  - - ">="
132
62
  - !ruby/object:Gem::Version
133
63
  version: '0'
134
64
  requirements: []
135
- rubygems_version: 3.0.3
136
- signing_key:
65
+ rubygems_version: 3.1.4
66
+ signing_key:
137
67
  specification_version: 4
138
68
  summary: Kitchen::Driver::Vagrant - A Vagrant Driver for Test Kitchen.
139
69
  test_files: []