lib/kitchen/driver/vagrant.rb in kitchen-vagrant-0.21.1 vs lib/kitchen/driver/vagrant.rb in kitchen-vagrant-1.0.0
- old
+ new
@@ -43,10 +43,12 @@
default_config :box_check_update, nil
default_config :box_download_insecure, nil
+ default_config :box_download_ca_cert, nil
+
default_config(:box_url) { |driver| driver.default_box_url }
default_config :box_version, nil
default_config :boot_timeout, nil
@@ -79,17 +81,19 @@
default_config :vagrantfiles, []
expand_path_for :vagrantfiles
default_config(:vm_hostname) do |driver|
- driver.windows_os? ? nil : driver.instance.name
+ driver.windows_os? ? nil : "#{driver.instance.name}.vagrantup.com"
end
default_config(:cache_directory) do |driver|
driver.windows_os? ? "/omnibus/cache" : "/tmp/omnibus/cache"
end
+ default_config :cachier, nil
+
no_parallel_for :create, :destroy
# Creates a Vagrant VM instance.
#
# @param state [Hash] mutable instance state
@@ -145,10 +149,11 @@
def finalize_config!(instance)
super
finalize_vm_hostname!
finalize_pre_create_command!
finalize_synced_folders!
+ finalize_ca_cert!
self
end
# Performs whatever tests that may be required to ensure that this driver
# will be able to function in the current environment. This may involve
@@ -249,10 +254,19 @@
debug("------------")
IO.read(vagrantfile).each_line { |l| debug("#{l.chomp}") }
debug("------------")
end
+ # Setup path for CA cert
+ #
+ # @api private
+ def finalize_ca_cert!
+ config[:box_download_ca_cert] = File.expand_path(
+ config[:box_download_ca_cert], config[:kitchen_root]) unless
+ config[:box_download_ca_cert].nil?
+ end
+
# Replaces any `{{vagrant_root}}` tokens in the pre create command.
#
# @api private
def finalize_pre_create_command!
return if config[:pre_create_command].nil?
@@ -271,11 +285,11 @@
File.expand_path(
source.gsub("%{instance_name}", instance.name),
config[:kitchen_root]
),
destination.gsub("%{instance_name}", instance.name),
- options || "nil"
+ options || "nil",
]
end
add_extra_synced_folders!
end
@@ -286,11 +300,11 @@
if cache_directory
FileUtils.mkdir_p(local_kitchen_cache)
config[:synced_folders].push([
local_kitchen_cache,
cache_directory,
- "create: true"
+ "create: true",
])
end
end
# Truncates the length of `:vm_hostname` to 12 characters for
@@ -361,22 +375,22 @@
# rubocop:disable Metrics/CyclomaticComplexity
def run_command(cmd, options = {})
merged = {
:use_sudo => config[:use_sudo],
:log_subject => name,
- :environment => {}
+ :environment => {},
}.merge(options)
# Attempt to extract bundler and associated GEM related values.
# TODO: To this accurately, we'd need to create a test-kitchen
# launch wrapper that serializes the existing environment before
# bundler touches it so that we can go back to it. Since that is
# "A Hard Problem"(TM), we simply blow away all known bundler
# related changes.
env = merged[:environment]
- %w[BUNDLE_BIN_PATH BUNDLE_GEMFILE GEM_HOME GEM_PATH GEM_ROOT RUBYLIB
- RUBYOPT _ORIGINAL_GEM_PATH].each do |var|
+ %w{BUNDLE_BIN_PATH BUNDLE_GEMFILE GEM_HOME GEM_PATH GEM_ROOT RUBYLIB
+ RUBYOPT _ORIGINAL_GEM_PATH}.each do |var|
env[var] = nil
end
# Altering the path seems to break vagrant. When the :environment
# is passed to a windows process with a PATH, Vagrant's batch installer
@@ -454,11 +468,11 @@
# @return [String] full local path to the directory containing the
# instance's Vagrantfile
# @api private
def vagrant_root
@vagrant_root ||= instance.nil? ? nil : File.join(
- config[:kitchen_root], %w[.kitchen kitchen-vagrant],
+ config[:kitchen_root], %w{.kitchen kitchen-vagrant},
"kitchen-#{File.basename(config[:kitchen_root])}-#{instance.name}"
)
end
# @param type [Symbol] either `:ssh` or `:winrm`
@@ -468,10 +482,10 @@
# @api private
def vagrant_config(type)
lines = run_silently("#{config[:vagrant_binary]} #{type}-config").
split("\n").map do |line|
tokens = line.strip.partition(" ")
- [tokens.first, tokens.last.gsub(/"/, "")]
+ [tokens.first, tokens.last.delete('"')]
end
Hash[lines]
end
# @return [String] version of Vagrant