Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support setting extra data for VirtualBox #493

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,26 @@ def run_command(_cmd, options = {})
end
RUBY
end

it "adds lines for multiple setextradata in :customize and quotes only string values" do
config[:customize] = {
setextradata: {
"VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC": 0,
"VBoxInternal/Devices/efi/0/Config/DmiSystemVersion": "1.0"
},
}
cmd

expect(vagrantfile).to match(Regexp.new(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99-.*"
p.customize ["modifyvm", :id, "--audio", "none"]
p.customize ["setextradata", :id, "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC", 0]
p.customize ["setextradata", :id, "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion", "1.0"]
end
RUBY
end

end

context "for parallels provider" do
Expand Down
5 changes: 5 additions & 0 deletions templates/Vagrantfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ Vagrant.configure("2") do |c|
ids << "\"#{id}\""
end %>
p.customize ["modifyvm", :id, "--cpuidset", <%= ids.join(', ') %>]
<% elsif key == :setextradata %>
<% value.each do | data_key, data_value | %>
<% data_value = "\"#{data_value}\"" if data_value.is_a? String %>
p.customize ["setextradata", :id, "<%= data_key %>", <%= data_value %>]
<% end %>
<% else %>
p.customize ["modifyvm", :id, "--<%= key %>", "<%= value %>"]
<% end %>
Expand Down