Skip to content

Commit

Permalink
add vagrant architecture support
Browse files Browse the repository at this point in the history
Signed-off-by: Corey Hemminger <[email protected]>
  • Loading branch information
Stromweld committed Feb 5, 2024
1 parent ad99627 commit 680fd61
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/kitchen/driver/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class Vagrant < Kitchen::Driver::Base

default_config :box_version, nil

default_config :box_arch, nil

default_config :boot_timeout, nil

default_config :customize, {}
Expand Down Expand Up @@ -125,7 +127,7 @@ def create(state)
# @return [String,nil] the Vagrant box for this Instance
def default_box
if bento_box?(instance.platform.name)
"bento/#{instance.platform.name}#{"-arm64" if RbConfig::CONFIG["host_cpu"].eql?("arm64")}"
"bento/#{instance.platform.name}"
else
instance.platform.name
end
Expand Down Expand Up @@ -225,7 +227,7 @@ def cache_directory
protected

WEBSITE = "https://www.vagrantup.com/downloads.html".freeze
MIN_VER = "1.1.0".freeze
MIN_VER = "2.4.0".freeze

class << self

Expand Down Expand Up @@ -313,14 +315,21 @@ def finalize_ca_cert!
def finalize_box_auto_update!
return if config[:box_auto_update].nil?

config[:box_auto_update] = "vagrant box update #{"--insecure " if config[:box_download_insecure]}--box #{config[:box]} --provider #{config[:provider]}"
cmd = "#{config[:vagrant_binary]} box update --box #{config[:box]}"
cmd += " --architecture #{config[:box_arch]}" if config[:box_arch]
cmd += " --provider #{config[:provider]}" if config[:provider]
cmd += " --insecure" if config[:box_download_insecure]
config[:box_auto_update] = cmd
end

# Create vagrant command to remove older versions of the box
def finalize_box_auto_prune!
return if config[:box_auto_prune].nil?

config[:box_auto_prune] = "vagrant box prune --force --keep-active-boxes --name #{config[:box]} --provider #{config[:provider]}"
cmd = "#{config[:vagrant_binary]} box prune --force --keep-active-boxes --name #{config[:box]}"
cmd += " --architecture #{config[:box_arch]}" if config[:box_arch]
cmd += " --provider #{config[:provider]}" if config[:provider]
config[:box_auto_prune] = cmd
end

# Replaces any `{{vagrant_root}}` tokens in the pre create command.
Expand Down
4 changes: 4 additions & 0 deletions templates/Vagrantfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Vagrant.configure("2") do |c|
c.vm.box_version = "<%= config[:box_version] %>"
<% end %>
<% if config[:box_arch] %>
c.vm.box_architecture = "<%= config[:box_arch] %>"
<% end %>
<% if !config[:box_check_update].nil? %>
c.vm.box_check_update = <%= config[:box_check_update] %>
<% end %>
Expand Down

0 comments on commit 680fd61

Please sign in to comment.