Skip to content

Commit

Permalink
Merge pull request #476 from chef/pipeline/rm-bento
Browse files Browse the repository at this point in the history
Be more aggressive about removing "bento-*" vagrant boxes
  • Loading branch information
Seth Thomas committed Oct 13, 2015
2 parents e5d7e3e + 4897ed2 commit 8e602c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ packer.log
/packer-*/
*.variables.json
/builds/
.kitchen
19 changes: 16 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require 'json'
require 'net/http'
require 'kitchen'
require 'aws-sdk'
require 'mixlib/shellout'

# TODO: private boxes may need to specify a mirror

Expand Down Expand Up @@ -222,11 +223,23 @@ def compute_metadata_files
`ls builds/*.json`.split("\n")
end

def destroy_all_bento
cmd = Mixlib::ShellOut.new("vagrant box list | grep 'bento-'")
cmd.run_command
boxes = cmd.stdout.split("\n")

boxes.each do | box |
b = box.split(" ")
rm_cmd = Mixlib::ShellOut.new("vagrant box remove --force #{b[0]} --provider #{b[1].to_s.gsub(/(,|\()/, '')}")
puts "Removing #{b[0]} for provider #{b[1].to_s.gsub(/(,|\()/, '')}"
rm_cmd.run_command
end
end

def test_box(boxname, providers)
providers.each do |provider, provider_data|

puts "Removing box: #{boxname} provider: #{provider}"
`vagrant box remove #{boxname} --provider #{provider}`
destroy_all_bento

provider = 'vmware_fusion' if provider == 'vmware_desktop'

Expand All @@ -240,7 +253,7 @@ def test_box(boxname, providers)
{"name"=>"vagrant",
"synced_folders"=>[[".", "/vagrant", "disabled: #{share_disabled}"]],
"provider"=>provider,
"box"=>boxname,
"box"=>"bento-#{boxname}",
"box_url"=>"file://#{ENV['PWD']}/builds/#{provider_data['file']}"}}],
"suites"=>[{"name"=>"default", "run_list"=>nil, "attributes"=>{}}]}

Expand Down

0 comments on commit 8e602c5

Please sign in to comment.