# -*- mode: ruby -*-
# vi: set ft=ruby :

# Set target based on cli args. Defaults to empty string.
target = if ENV[PROJECT_NAME + "_PROVIDER"]
           ENV[PROJECT_NAME + "_PROVIDER"]
         elsif read_provider_file()
           read_provider_file()
         else
           'virtualbox'
         end

if (SETTINGS["PROVIDERS"].include? target)
  write_provider_file(target)
  load File.expand_path("vagrant_resources/vagrant/Vagrantfile." + target)
else # Bad arg - we don't have this provider.
  abort("ABORTED - Target not in providers list. Did you have a typo?")
end

hosts = ['debian-8',
         'ubuntu-1604',
        ]

VM_HOST = if ENV["VMHOST"]
          ENV["VMHOST"]
        else
        'debian-8'
        end

unless (hosts.include? VM_HOST)
   abort("ABORTED - VM host not in host list. Did you have a typo?")
end

sizes = ['512mb',
         '1024mb',
         '2048mb',
        ]

VM_SIZE = if ENV["VMSIZE"]
          ENV["VMSIZE"]
        else
        '1024mb'
        end

unless (sizes.include? VM_SIZE)
   abort("ABORTED - VM size not in sizes list. Did you have a typo?")
end

# clean up files on the host after the guest is destroyed
Vagrant.configure("2") do |config|
  config.trigger.after :destroy do
    puts "Vagrant done with destroy."
  end
end
