lib/kitchen/driver/vagrant.rb in kitchen-vagrant-1.3.5 vs lib/kitchen/driver/vagrant.rb in kitchen-vagrant-1.3.6
- old
+ new
@@ -296,20 +296,20 @@
#
# @api private
def finalize_pre_create_command!
return if config[:pre_create_command].nil?
- config[:pre_create_command] = config[:pre_create_command].
- gsub("{{vagrant_root}}", vagrant_root)
+ config[:pre_create_command] = config[:pre_create_command]
+ .gsub("{{vagrant_root}}", vagrant_root)
end
# Replaces an `%{instance_name}` tokens in the synced folder items.
#
# @api private
def finalize_synced_folders!
- config[:synced_folders] = config[:synced_folders].
- map do |source, destination, options|
+ config[:synced_folders] = config[:synced_folders]
+ .map do |source, destination, options|
[
File.expand_path(
source.gsub("%{instance_name}", instance.name),
config[:kitchen_root]
),
@@ -394,11 +394,11 @@
# @param options [Hash] options hash
# @see Kitchen::ShellOut.run_command
# @api private
def run(cmd, options = {})
cmd = "echo #{cmd}" if config[:dry_run]
- run_command(cmd, { :cwd => vagrant_root }.merge(options))
+ run_command(cmd, { cwd: vagrant_root }.merge(options))
end
# Delegates to Kitchen::ShellOut.run_command, overriding some default
# options:
#
@@ -413,13 +413,13 @@
# @see https://github.com/test-kitchen/kitchen-vagrant/issues/190
# @see Kitchen::ShellOut#run_command
# rubocop:disable Metrics/CyclomaticComplexity
def run_command(cmd, options = {})
merged = {
- :use_sudo => config[:use_sudo],
- :log_subject => name,
- :environment => {},
+ use_sudo: config[:use_sudo],
+ log_subject: name,
+ 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
@@ -456,21 +456,21 @@
# Runs a local command before `vagrant up` has been called.
#
# @api private
def run_pre_create_command
if config[:pre_create_command]
- run(config[:pre_create_command], :cwd => config[:kitchen_root])
+ run(config[:pre_create_command], cwd: config[:kitchen_root])
end
end
# Runs a local command without streaming the stdout to the logger.
#
# @param cmd [String] command to run locally
# @api private
def run_silently(cmd, options = {})
merged = {
- :live_stream => nil, :quiet => (logger.debug? ? false : true)
+ live_stream: nil, quiet: (logger.debug? ? false : true)
}.merge(options)
run(cmd, merged)
end
# Runs the `vagrant up` command locally.
@@ -522,12 +522,12 @@
# @return [Hash] key/value pairs resulting from parsing a
# `vagrant ssh-config` or `vagrant winrm-config` local command
# invocation
# @api private
def vagrant_config(type)
- lines = run_silently("#{config[:vagrant_binary]} #{type}-config").
- split("\n").map do |line|
+ lines = run_silently("#{config[:vagrant_binary]} #{type}-config")
+ .split("\n").map do |line|
tokens = line.strip.partition(" ")
[tokens.first, tokens.last.delete('"')]
end
Hash[lines]
end
@@ -535,12 +535,12 @@
# @return [String] version of Vagrant
# @raise [UserError] if the `vagrant` command can not be found locally
# @api private
def vagrant_version
self.class.vagrant_version ||= run_silently(
- "#{config[:vagrant_binary]} --version", :cwd => Dir.pwd).
- chomp.split(" ").last
+ "#{config[:vagrant_binary]} --version", cwd: Dir.pwd)
+ .chomp.split(" ").last
rescue Errno::ENOENT
raise UserError, "Vagrant #{MIN_VER} or higher is not installed." \
" Please download a package from #{WEBSITE}."
end
@@ -554,15 +554,17 @@
"(#{vagrant_version}) that cannot support the vagrant-winrm " \
"Vagrant plugin." \
" Please upgrade to version 1.6 or higher from #{WEBSITE}."
end
- if !winrm_plugin_installed?
- raise UserError, "WinRM Transport requires the vagrant-winrm " \
- "Vagrant plugin to properly communicate with this Vagrant VM. " \
- "Please install this plugin with: " \
- "`vagrant plugin install vagrant-winrm' and try again."
+ if Gem::Version.new(vagrant_version) < Gem::Version.new("2.2.0") && !winrm_plugin_installed?
+ raise UserError, "Vagrant version #{vagrant_version} requires the " \
+ "vagrant-winrm plugin to properly communicate with this Vagrant VM " \
+ "over WinRM Transport. Please install this plugin with: " \
+ "`vagrant plugin install vagrant-winrm' and try again." \
+ "Alternatively upgrade to Vagrant >= 2.2.0 which does not " \
+ "require the vagrant-winrm plugin."
end
end
# @return [true,false] whether or not the host is windows
#
@@ -576,11 +578,11 @@
# @api private
def winrm_plugin_installed?
return true if self.class.winrm_plugin_passed
self.class.winrm_plugin_passed = run_silently(
- "#{config[:vagrant_binary]} plugin list", :cwd => Dir.pwd).
- split("\n").find { |line| line =~ /vagrant-winrm\s+/ }
+ "#{config[:vagrant_binary]} plugin list", cwd: Dir.pwd)
+ .split("\n").find { |line| line =~ /vagrant-winrm\s+/ }
end
end
end
end