Use .key? instead of .has_key?
This commit is contained in:
parent
cee834ddf3
commit
d2874064f4
|
@ -369,7 +369,7 @@ module Vagrant
|
||||||
#
|
#
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
def downloader(url, env, **opts)
|
def downloader(url, env, **opts)
|
||||||
opts[:ui] = true if !opts.has_key?(:ui)
|
opts[:ui] = true if !opts.key?(:ui)
|
||||||
|
|
||||||
temp_path = env[:tmp_path].join("box" + Digest::SHA1.hexdigest(url))
|
temp_path = env[:tmp_path].join("box" + Digest::SHA1.hexdigest(url))
|
||||||
@logger.info("Downloading box: #{url} => #{temp_path}")
|
@logger.info("Downloading box: #{url} => #{temp_path}")
|
||||||
|
@ -409,7 +409,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def download(url, env, **opts)
|
def download(url, env, **opts)
|
||||||
opts[:ui] = true if !opts.has_key?(:ui)
|
opts[:ui] = true if !opts.key?(:ui)
|
||||||
|
|
||||||
d = downloader(url, env, **opts)
|
d = downloader(url, env, **opts)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
if !env.has_key?(:config_validate) || env[:config_validate]
|
if !env.key?(:config_validate) || env[:config_validate]
|
||||||
errors = env[:machine].config.validate(env[:machine])
|
errors = env[:machine].config.validate(env[:machine])
|
||||||
|
|
||||||
if errors && !errors.empty?
|
if errors && !errors.empty?
|
||||||
|
|
|
@ -24,7 +24,7 @@ module Vagrant
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
graceful = true
|
graceful = true
|
||||||
graceful = !env[:force_halt] if env.has_key?(:force_halt)
|
graceful = !env[:force_halt] if env.key?(:force_halt)
|
||||||
|
|
||||||
# By default, we didn't succeed.
|
# By default, we didn't succeed.
|
||||||
env[:result] = false
|
env[:result] = false
|
||||||
|
|
|
@ -129,7 +129,7 @@ module Vagrant
|
||||||
|
|
||||||
# If we have folders with the "default" key, then determine the
|
# If we have folders with the "default" key, then determine the
|
||||||
# most appropriate implementation for this.
|
# most appropriate implementation for this.
|
||||||
if folders.has_key?("") && !folders[""].empty?
|
if folders.key?("") && !folders[""].empty?
|
||||||
default_impl = default_synced_folder_type(machine, plugins)
|
default_impl = default_synced_folder_type(machine, plugins)
|
||||||
if !default_impl
|
if !default_impl
|
||||||
types = plugins.to_hash.keys.map { |t| t.to_s }.sort.join(", ")
|
types = plugins.to_hash.keys.map { |t| t.to_s }.sort.join(", ")
|
||||||
|
|
|
@ -24,13 +24,13 @@ module Vagrant
|
||||||
|
|
||||||
# Tracks whether we were configured to provision
|
# Tracks whether we were configured to provision
|
||||||
config_enabled = true
|
config_enabled = true
|
||||||
config_enabled = env[:provision_enabled] if env.has_key?(:provision_enabled)
|
config_enabled = env[:provision_enabled] if env.key?(:provision_enabled)
|
||||||
|
|
||||||
# Check if we already provisioned, and if so, disable the rest
|
# Check if we already provisioned, and if so, disable the rest
|
||||||
provision_enabled = true
|
provision_enabled = true
|
||||||
|
|
||||||
ignore_sentinel = true
|
ignore_sentinel = true
|
||||||
if env.has_key?(:provision_ignore_sentinel)
|
if env.key?(:provision_ignore_sentinel)
|
||||||
ignore_sentinel = env[:provision_ignore_sentinel]
|
ignore_sentinel = env[:provision_ignore_sentinel]
|
||||||
end
|
end
|
||||||
if ignore_sentinel
|
if ignore_sentinel
|
||||||
|
@ -69,7 +69,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
# Store the value so that other actions can use it
|
# Store the value so that other actions can use it
|
||||||
env[:provision_enabled] = provision_enabled if !env.has_key?(:provision_enabled)
|
env[:provision_enabled] = provision_enabled if !env.key?(:provision_enabled)
|
||||||
|
|
||||||
# Ask the provisioners to modify the configuration if needed
|
# Ask the provisioners to modify the configuration if needed
|
||||||
provisioner_instances(env).each do |p, _|
|
provisioner_instances(env).each do |p, _|
|
||||||
|
|
|
@ -49,7 +49,7 @@ module Vagrant
|
||||||
# Run the action chain in a busy block, marking the environment as
|
# Run the action chain in a busy block, marking the environment as
|
||||||
# interrupted if a SIGINT occurs, and exiting cleanly once the
|
# interrupted if a SIGINT occurs, and exiting cleanly once the
|
||||||
# chain has been run.
|
# chain has been run.
|
||||||
ui = environment[:ui] if environment.has_key?(:ui)
|
ui = environment[:ui] if environment.key?(:ui)
|
||||||
int_callback = lambda do
|
int_callback = lambda do
|
||||||
if environment[:interrupted]
|
if environment[:interrupted]
|
||||||
ui.error I18n.t("vagrant.actions.runner.exit_immediately") if ui
|
ui.error I18n.t("vagrant.actions.runner.exit_immediately") if ui
|
||||||
|
|
|
@ -165,7 +165,7 @@ module Vagrant
|
||||||
@cap_logger.debug("Checking in: #{host_name}")
|
@cap_logger.debug("Checking in: #{host_name}")
|
||||||
caps = @cap_caps[host_name]
|
caps = @cap_caps[host_name]
|
||||||
|
|
||||||
if caps && caps.has_key?(cap_name)
|
if caps && caps.key?(cap_name)
|
||||||
@cap_logger.debug("Found cap: #{cap_name} in #{host_name}")
|
@cap_logger.debug("Found cap: #{cap_name} in #{host_name}")
|
||||||
return caps[cap_name]
|
return caps[cap_name]
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,7 +49,7 @@ module Vagrant
|
||||||
# Gather the procs for every source, since that is what we care about.
|
# Gather the procs for every source, since that is what we care about.
|
||||||
procs = []
|
procs = []
|
||||||
sources.each do |source|
|
sources.each do |source|
|
||||||
if !@proc_cache.has_key?(source)
|
if !@proc_cache.key?(source)
|
||||||
# Load the procs for this source and cache them. This caching
|
# Load the procs for this source and cache them. This caching
|
||||||
# avoids the issue where a file may have side effects when loading
|
# avoids the issue where a file may have side effects when loading
|
||||||
# and loading it multiple times causes unexpected behavior.
|
# and loading it multiple times causes unexpected behavior.
|
||||||
|
@ -92,10 +92,10 @@ module Vagrant
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
order.each do |key|
|
order.each do |key|
|
||||||
next if !@sources.has_key?(key)
|
next if !@sources.key?(key)
|
||||||
|
|
||||||
@sources[key].each do |version, proc|
|
@sources[key].each do |version, proc|
|
||||||
if !@config_cache.has_key?(proc)
|
if !@config_cache.key?(proc)
|
||||||
@logger.debug("Loading from: #{key} (evaluating)")
|
@logger.debug("Loading from: #{key} (evaluating)")
|
||||||
|
|
||||||
# Get the proper version loader for this version and load
|
# Get the proper version loader for this version and load
|
||||||
|
|
|
@ -60,7 +60,7 @@ module Vagrant
|
||||||
new_keys = new_state["keys"]
|
new_keys = new_state["keys"]
|
||||||
keys = {}
|
keys = {}
|
||||||
old_keys.each do |key, old_value|
|
old_keys.each do |key, old_value|
|
||||||
if new_keys.has_key?(key)
|
if new_keys.key?(key)
|
||||||
# We need to do a merge, which we expect to be available
|
# We need to do a merge, which we expect to be available
|
||||||
# on the config class itself.
|
# on the config class itself.
|
||||||
keys[key] = old_value.merge(new_keys[key])
|
keys[key] = old_value.merge(new_keys[key])
|
||||||
|
@ -72,7 +72,7 @@ module Vagrant
|
||||||
|
|
||||||
new_keys.each do |key, new_value|
|
new_keys.each do |key, new_value|
|
||||||
# Add in the keys that the new class has that we haven't merged.
|
# Add in the keys that the new class has that we haven't merged.
|
||||||
if !keys.has_key?(key)
|
if !keys.key?(key)
|
||||||
keys[key] = new_value.dup
|
keys[key] = new_value.dup
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Vagrant
|
||||||
# used for Vagrant and load the proper configuration classes for
|
# used for Vagrant and load the proper configuration classes for
|
||||||
# each.
|
# each.
|
||||||
def method_missing(name, *args)
|
def method_missing(name, *args)
|
||||||
return @keys[name] if @keys.has_key?(name)
|
return @keys[name] if @keys.key?(name)
|
||||||
|
|
||||||
config_klass = @config_map[name.to_sym]
|
config_klass = @config_map[name.to_sym]
|
||||||
if config_klass
|
if config_klass
|
||||||
|
|
|
@ -70,7 +70,7 @@ module Vagrant
|
||||||
new_keys = new_state["keys"]
|
new_keys = new_state["keys"]
|
||||||
keys = {}
|
keys = {}
|
||||||
old_keys.each do |key, old_value|
|
old_keys.each do |key, old_value|
|
||||||
if new_keys.has_key?(key)
|
if new_keys.key?(key)
|
||||||
# We need to do a merge, which we expect to be available
|
# We need to do a merge, which we expect to be available
|
||||||
# on the config class itself.
|
# on the config class itself.
|
||||||
keys[key] = old_value.merge(new_keys[key])
|
keys[key] = old_value.merge(new_keys[key])
|
||||||
|
@ -82,7 +82,7 @@ module Vagrant
|
||||||
|
|
||||||
new_keys.each do |key, new_value|
|
new_keys.each do |key, new_value|
|
||||||
# Add in the keys that the new class has that we haven't merged.
|
# Add in the keys that the new class has that we haven't merged.
|
||||||
if !keys.has_key?(key)
|
if !keys.key?(key)
|
||||||
keys[key] = new_value.dup
|
keys[key] = new_value.dup
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,7 @@ module Vagrant
|
||||||
# used for Vagrant and load the proper configuration classes for
|
# used for Vagrant and load the proper configuration classes for
|
||||||
# each.
|
# each.
|
||||||
def method_missing(name, *args)
|
def method_missing(name, *args)
|
||||||
return @keys[name] if @keys.has_key?(name)
|
return @keys[name] if @keys.key?(name)
|
||||||
|
|
||||||
config_klass = @config_map[name.to_sym]
|
config_klass = @config_map[name.to_sym]
|
||||||
if config_klass
|
if config_klass
|
||||||
|
@ -41,7 +41,7 @@ module Vagrant
|
||||||
# mutate itself.
|
# mutate itself.
|
||||||
def finalize!
|
def finalize!
|
||||||
@config_map.each do |key, klass|
|
@config_map.each do |key, klass|
|
||||||
if !@keys.has_key?(key)
|
if !@keys.key?(key)
|
||||||
@keys[key] = klass.new
|
@keys[key] = klass.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -102,9 +102,9 @@ module Vagrant
|
||||||
# This sets the internal state. This is used by the core to do some
|
# This sets the internal state. This is used by the core to do some
|
||||||
# merging logic and shouldn't be used by the general public.
|
# merging logic and shouldn't be used by the general public.
|
||||||
def __set_internal_state(state)
|
def __set_internal_state(state)
|
||||||
@config_map = state["config_map"] if state.has_key?("config_map")
|
@config_map = state["config_map"] if state.key?("config_map")
|
||||||
@keys = state["keys"] if state.has_key?("keys")
|
@keys = state["keys"] if state.key?("keys")
|
||||||
@missing_key_calls = state["missing_key_calls"] if state.has_key?("missing_key_calls")
|
@missing_key_calls = state["missing_key_calls"] if state.key?("missing_key_calls")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -80,7 +80,7 @@ module Vagrant
|
||||||
}.merge(opts || {})
|
}.merge(opts || {})
|
||||||
|
|
||||||
# Set the default working directory to look for the vagrantfile
|
# Set the default working directory to look for the vagrantfile
|
||||||
opts[:cwd] ||= ENV["VAGRANT_CWD"] if ENV.has_key?("VAGRANT_CWD")
|
opts[:cwd] ||= ENV["VAGRANT_CWD"] if ENV.key?("VAGRANT_CWD")
|
||||||
opts[:cwd] ||= Dir.pwd
|
opts[:cwd] ||= Dir.pwd
|
||||||
opts[:cwd] = Pathname.new(opts[:cwd])
|
opts[:cwd] = Pathname.new(opts[:cwd])
|
||||||
if !opts[:cwd].directory?
|
if !opts[:cwd].directory?
|
||||||
|
@ -94,7 +94,7 @@ module Vagrant
|
||||||
# Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that
|
# Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that
|
||||||
# those continue to work as well, but anything custom will take precedence.
|
# those continue to work as well, but anything custom will take precedence.
|
||||||
opts[:vagrantfile_name] ||= ENV["VAGRANT_VAGRANTFILE"] if \
|
opts[:vagrantfile_name] ||= ENV["VAGRANT_VAGRANTFILE"] if \
|
||||||
ENV.has_key?("VAGRANT_VAGRANTFILE")
|
ENV.key?("VAGRANT_VAGRANTFILE")
|
||||||
opts[:vagrantfile_name] = [opts[:vagrantfile_name]] if \
|
opts[:vagrantfile_name] = [opts[:vagrantfile_name]] if \
|
||||||
opts[:vagrantfile_name] && !opts[:vagrantfile_name].is_a?(Array)
|
opts[:vagrantfile_name] && !opts[:vagrantfile_name].is_a?(Array)
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ module Vagrant
|
||||||
# @return [Symbol] Name of the default provider.
|
# @return [Symbol] Name of the default provider.
|
||||||
def default_provider(**opts)
|
def default_provider(**opts)
|
||||||
opts[:exclude] = Set.new(opts[:exclude]) if opts[:exclude]
|
opts[:exclude] = Set.new(opts[:exclude]) if opts[:exclude]
|
||||||
opts[:force_default] = true if !opts.has_key?(:force_default)
|
opts[:force_default] = true if !opts.key?(:force_default)
|
||||||
|
|
||||||
default = ENV["VAGRANT_DEFAULT_PROVIDER"]
|
default = ENV["VAGRANT_DEFAULT_PROVIDER"]
|
||||||
default = nil if default == ""
|
default = nil if default == ""
|
||||||
|
@ -351,15 +351,15 @@ module Vagrant
|
||||||
|
|
||||||
# Skip providers that can't be defaulted, unless they're in our
|
# Skip providers that can't be defaulted, unless they're in our
|
||||||
# config, in which case someone made our decision for us.
|
# config, in which case someone made our decision for us.
|
||||||
if !config.has_key?(key)
|
if !config.key?(key)
|
||||||
next if popts.has_key?(:defaultable) && !popts[:defaultable]
|
next if popts.key?(:defaultable) && !popts[:defaultable]
|
||||||
end
|
end
|
||||||
|
|
||||||
# The priority is higher if it is in our config. Otherwise, it is
|
# The priority is higher if it is in our config. Otherwise, it is
|
||||||
# the priority it set PLUS the length of the config to make sure it
|
# the priority it set PLUS the length of the config to make sure it
|
||||||
# is never higher than the configuration keys.
|
# is never higher than the configuration keys.
|
||||||
priority = popts[:priority]
|
priority = popts[:priority]
|
||||||
priority = config[key] + max_priority if config.has_key?(key)
|
priority = config[key] + max_priority if config.key?(key)
|
||||||
|
|
||||||
ordered << [priority, key, impl, popts]
|
ordered << [priority, key, impl, popts]
|
||||||
end
|
end
|
||||||
|
@ -596,7 +596,7 @@ module Vagrant
|
||||||
@machines.delete(cache_key)
|
@machines.delete(cache_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @machines.has_key?(cache_key)
|
if @machines.key?(cache_key)
|
||||||
@logger.info("Returning cached machine: #{name} (#{provider})")
|
@logger.info("Returning cached machine: #{name} (#{provider})")
|
||||||
return @machines[cache_key]
|
return @machines[cache_key]
|
||||||
end
|
end
|
||||||
|
|
|
@ -157,7 +157,7 @@ module Vagrant
|
||||||
|
|
||||||
# Determine whether we lock or not
|
# Determine whether we lock or not
|
||||||
lock = true
|
lock = true
|
||||||
lock = opts.delete(:lock) if opts.has_key?(:lock)
|
lock = opts.delete(:lock) if opts.key?(:lock)
|
||||||
|
|
||||||
# Extra env keys are the remaining opts
|
# Extra env keys are the remaining opts
|
||||||
extra_env = opts.dup
|
extra_env = opts.dup
|
||||||
|
|
|
@ -143,7 +143,7 @@ module Vagrant
|
||||||
|
|
||||||
# If we already have a newer version in our list of installed,
|
# If we already have a newer version in our list of installed,
|
||||||
# then ignore it
|
# then ignore it
|
||||||
next if installed_map.has_key?(spec.name) &&
|
next if installed_map.key?(spec.name) &&
|
||||||
installed_map[spec.name].version >= spec.version
|
installed_map[spec.name].version >= spec.version
|
||||||
|
|
||||||
installed_map[spec.name] = spec
|
installed_map[spec.name] = spec
|
||||||
|
|
|
@ -61,7 +61,7 @@ module Vagrant
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def has_plugin?(name)
|
def has_plugin?(name)
|
||||||
@data["installed"].has_key?(name)
|
@data["installed"].key?(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove a plugin that is installed from the state file.
|
# Remove a plugin that is installed from the state file.
|
||||||
|
|
|
@ -88,7 +88,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
# By default, the command is primary
|
# By default, the command is primary
|
||||||
opts[:primary] = true if !opts.has_key?(:primary)
|
opts[:primary] = true if !opts.key?(:primary)
|
||||||
|
|
||||||
# Register the command
|
# Register the command
|
||||||
components.commands.register(name.to_sym) do
|
components.commands.register(name.to_sym) do
|
||||||
|
|
|
@ -22,8 +22,8 @@ module Vagrant
|
||||||
# This will evaluate the block given to `register` and return the
|
# This will evaluate the block given to `register` and return the
|
||||||
# resulting value.
|
# resulting value.
|
||||||
def get(key)
|
def get(key)
|
||||||
return nil if !@items.has_key?(key)
|
return nil if !@items.key?(key)
|
||||||
return @results_cache[key] if @results_cache.has_key?(key)
|
return @results_cache[key] if @results_cache.key?(key)
|
||||||
@results_cache[key] = @items[key].call
|
@results_cache[key] = @items[key].call
|
||||||
end
|
end
|
||||||
alias :[] :get
|
alias :[] :get
|
||||||
|
@ -31,9 +31,10 @@ module Vagrant
|
||||||
# Checks if the given key is registered with the registry.
|
# Checks if the given key is registered with the registry.
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def has_key?(key)
|
def key?(key)
|
||||||
@items.has_key?(key)
|
@items.key?(key)
|
||||||
end
|
end
|
||||||
|
alias_method :has_key?, :key?
|
||||||
|
|
||||||
# Returns an array populated with the keys of this object.
|
# Returns an array populated with the keys of this object.
|
||||||
#
|
#
|
||||||
|
|
|
@ -136,9 +136,9 @@ module Vagrant
|
||||||
|
|
||||||
# Setup the options so that the new line is suppressed
|
# Setup the options so that the new line is suppressed
|
||||||
opts ||= {}
|
opts ||= {}
|
||||||
opts[:echo] = true if !opts.has_key?(:echo)
|
opts[:echo] = true if !opts.key?(:echo)
|
||||||
opts[:new_line] = false if !opts.has_key?(:new_line)
|
opts[:new_line] = false if !opts.key?(:new_line)
|
||||||
opts[:prefix] = false if !opts.has_key?(:prefix)
|
opts[:prefix] = false if !opts.key?(:prefix)
|
||||||
|
|
||||||
# Output the data
|
# Output the data
|
||||||
say(:info, message, opts)
|
say(:info, message, opts)
|
||||||
|
@ -249,7 +249,7 @@ module Vagrant
|
||||||
class_eval <<-CODE
|
class_eval <<-CODE
|
||||||
def #{method}(message, *args, **opts)
|
def #{method}(message, *args, **opts)
|
||||||
super(message)
|
super(message)
|
||||||
if !@ui.opts.has_key?(:bold) && !opts.has_key?(:bold)
|
if !@ui.opts.key?(:bold) && !opts.key?(:bold)
|
||||||
opts[:bold] = #{method.inspect} != :detail && \
|
opts[:bold] = #{method.inspect} != :detail && \
|
||||||
#{method.inspect} != :ask
|
#{method.inspect} != :ask
|
||||||
end
|
end
|
||||||
|
@ -284,7 +284,7 @@ module Vagrant
|
||||||
opts = self.opts.merge(opts)
|
opts = self.opts.merge(opts)
|
||||||
|
|
||||||
prefix = ""
|
prefix = ""
|
||||||
if !opts.has_key?(:prefix) || opts[:prefix]
|
if !opts.key?(:prefix) || opts[:prefix]
|
||||||
prefix = OUTPUT_PREFIX
|
prefix = OUTPUT_PREFIX
|
||||||
prefix = " " * OUTPUT_PREFIX.length if \
|
prefix = " " * OUTPUT_PREFIX.length if \
|
||||||
type == :detail || type == :ask || opts[:prefix_spaces]
|
type == :detail || type == :ask || opts[:prefix_spaces]
|
||||||
|
@ -294,7 +294,7 @@ module Vagrant
|
||||||
return message if prefix.empty?
|
return message if prefix.empty?
|
||||||
|
|
||||||
target = @prefix
|
target = @prefix
|
||||||
target = opts[:target] if opts.has_key?(:target)
|
target = opts[:target] if opts.key?(:target)
|
||||||
|
|
||||||
# Get the lines. The first default is because if the message
|
# Get the lines. The first default is because if the message
|
||||||
# is an empty string, then we want to still use the empty string.
|
# is an empty string, then we want to still use the empty string.
|
||||||
|
|
|
@ -148,7 +148,7 @@ module Vagrant
|
||||||
# output.
|
# output.
|
||||||
def terminal_supports_colors?
|
def terminal_supports_colors?
|
||||||
if windows?
|
if windows?
|
||||||
return true if ENV.has_key?("ANSICON")
|
return true if ENV.key?("ANSICON")
|
||||||
return true if cygwin?
|
return true if cygwin?
|
||||||
return true if ENV["TERM"] == "cygwin"
|
return true if ENV["TERM"] == "cygwin"
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -32,7 +32,7 @@ module VagrantPlugins
|
||||||
:destroy, force_confirm_destroy: options[:force])
|
:destroy, force_confirm_destroy: options[:force])
|
||||||
|
|
||||||
total += 1
|
total += 1
|
||||||
declined += 1 if action_env.has_key?(:force_confirm_destroy_result) &&
|
declined += 1 if action_env.key?(:force_confirm_destroy_result) &&
|
||||||
action_env[:force_confirm_destroy_result] == false
|
action_env[:force_confirm_destroy_result] == false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
installed = Vagrant::Plugin::Manager.instance.installed_plugins
|
installed = Vagrant::Plugin::Manager.instance.installed_plugins
|
||||||
if !installed.has_key?(env[:plugin_name])
|
if !installed.key?(env[:plugin_name])
|
||||||
raise Vagrant::Errors::PluginNotInstalled,
|
raise Vagrant::Errors::PluginNotInstalled,
|
||||||
name: env[:plugin_name]
|
name: env[:plugin_name]
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,8 +60,8 @@ module VagrantPlugins
|
||||||
if names.empty?
|
if names.empty?
|
||||||
autostart = false
|
autostart = false
|
||||||
@env.vagrantfile.machine_names_and_options.each do |n, o|
|
@env.vagrantfile.machine_names_and_options.each do |n, o|
|
||||||
autostart = true if o.has_key?(:autostart)
|
autostart = true if o.key?(:autostart)
|
||||||
o[:autostart] = true if !o.has_key?(:autostart)
|
o[:autostart] = true if !o.key?(:autostart)
|
||||||
names << n.to_s if o[:autostart]
|
names << n.to_s if o[:autostart]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -320,7 +320,7 @@ module VagrantPlugins
|
||||||
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
|
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
|
||||||
|
|
||||||
# Default some options
|
# Default some options
|
||||||
opts[:retries] = 5 if !opts.has_key?(:retries)
|
opts[:retries] = 5 if !opts.key?(:retries)
|
||||||
|
|
||||||
# Build the options we'll use to initiate the connection via Net::SSH
|
# Build the options we'll use to initiate the connection via Net::SSH
|
||||||
common_connect_opts = {
|
common_connect_opts = {
|
||||||
|
|
|
@ -17,7 +17,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_post(machine, opts)
|
def self.rsync_post(machine, opts)
|
||||||
if opts.has_key?(:chown) && !opts[:chown]
|
if opts.key?(:chown) && !opts[:chown]
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_post(machine, opts)
|
def self.rsync_post(machine, opts)
|
||||||
if opts.has_key?(:chown) && !opts[:chown]
|
if opts.key?(:chown) && !opts[:chown]
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_post(machine, opts)
|
def self.rsync_post(machine, opts)
|
||||||
if opts.has_key?(:chown) && !opts[:chown]
|
if opts.key?(:chown) && !opts[:chown]
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
other_defined_vms.each do |key, subvm|
|
other_defined_vms.each do |key, subvm|
|
||||||
if !new_defined_vms.has_key?(key)
|
if !new_defined_vms.key?(key)
|
||||||
new_defined_vms[key] = subvm.clone
|
new_defined_vms[key] = subvm.clone
|
||||||
else
|
else
|
||||||
new_defined_vms[key].config_procs.concat(subvm.config_procs)
|
new_defined_vms[key].config_procs.concat(subvm.config_procs)
|
||||||
|
@ -197,7 +197,7 @@ module VagrantPlugins
|
||||||
options ||= {}
|
options ||= {}
|
||||||
options[:guestpath] = guestpath.to_s.gsub(/\/$/, '')
|
options[:guestpath] = guestpath.to_s.gsub(/\/$/, '')
|
||||||
options[:hostpath] = hostpath
|
options[:hostpath] = hostpath
|
||||||
options[:disabled] = false if !options.has_key?(:disabled)
|
options[:disabled] = false if !options.key?(:disabled)
|
||||||
options = (@__synced_folders[options[:guestpath]] || {}).
|
options = (@__synced_folders[options[:guestpath]] || {}).
|
||||||
merge(options.dup)
|
merge(options.dup)
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ module VagrantPlugins
|
||||||
id = "#{type}-#{id}"
|
id = "#{type}-#{id}"
|
||||||
|
|
||||||
# Merge in the previous settings if we have them.
|
# Merge in the previous settings if we have them.
|
||||||
if @__networks.has_key?(id)
|
if @__networks.key?(id)
|
||||||
options = @__networks[id][1].merge(options)
|
options = @__networks[id][1].merge(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -279,13 +279,13 @@ module VagrantPlugins
|
||||||
|
|
||||||
def provision(name, **options, &block)
|
def provision(name, **options, &block)
|
||||||
type = name
|
type = name
|
||||||
if options.has_key?(:type)
|
if options.key?(:type)
|
||||||
type = options.delete(:type)
|
type = options.delete(:type)
|
||||||
else
|
else
|
||||||
name = nil
|
name = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if options.has_key?(:id)
|
if options.key?(:id)
|
||||||
puts "Setting `id` on a provisioner is deprecated. Please use the"
|
puts "Setting `id` on a provisioner is deprecated. Please use the"
|
||||||
puts "new syntax of `config.vm.provision \"name\", type: \"type\""
|
puts "new syntax of `config.vm.provision \"name\", type: \"type\""
|
||||||
puts "where \"name\" is the replacement for `id`. This will be"
|
puts "where \"name\" is the replacement for `id`. This will be"
|
||||||
|
@ -306,8 +306,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
prov.preserve_order = !!options.delete(:preserve_order) if \
|
prov.preserve_order = !!options.delete(:preserve_order) if \
|
||||||
options.has_key?(:preserve_order)
|
options.key?(:preserve_order)
|
||||||
prov.run = options.delete(:run) if options.has_key?(:run)
|
prov.run = options.delete(:run) if options.key?(:run)
|
||||||
prov.add_config(options, &block)
|
prov.add_config(options, &block)
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,7 @@ module VagrantPlugins
|
||||||
def call(env)
|
def call(env)
|
||||||
return @app.call(env) if !env[:machine].provider.host_vm?
|
return @app.call(env) if !env[:machine].provider.host_vm?
|
||||||
|
|
||||||
if !env.has_key?(:host_machine_sync_folders)
|
if !env.key?(:host_machine_sync_folders)
|
||||||
env[:host_machine_sync_folders] = true
|
env[:host_machine_sync_folders] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Add this synced folder onto the new config if we haven't
|
# Add this synced folder onto the new config if we haven't
|
||||||
# already shared it before.
|
# already shared it before.
|
||||||
if !existing_ids.has_key?(id)
|
if !existing_ids.key?(id)
|
||||||
# A bit of a hack for VirtualBox to mount our
|
# A bit of a hack for VirtualBox to mount our
|
||||||
# folder as transient. This can be removed once
|
# folder as transient. This can be removed once
|
||||||
# the VirtualBox synced folder mechanism is smarter.
|
# the VirtualBox synced folder mechanism is smarter.
|
||||||
|
|
|
@ -24,7 +24,7 @@ module VagrantPlugins
|
||||||
}
|
}
|
||||||
folders = synced_folders(env[:machine], **opts)
|
folders = synced_folders(env[:machine], **opts)
|
||||||
|
|
||||||
if folders.has_key?(:nfs)
|
if folders.key?(:nfs)
|
||||||
@logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP")
|
@logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP")
|
||||||
add_ips_to_env!(env)
|
add_ips_to_env!(env)
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,9 +32,9 @@ module VagrantPlugins
|
||||||
# Verify the name is not taken
|
# Verify the name is not taken
|
||||||
vms = env[:machine].provider.driver.read_vms
|
vms = env[:machine].provider.driver.read_vms
|
||||||
raise Vagrant::Errors::VMNameExists, name: name if \
|
raise Vagrant::Errors::VMNameExists, name: name if \
|
||||||
vms.has_key?(name) && vms[name] != env[:machine].id
|
vms.key?(name) && vms[name] != env[:machine].id
|
||||||
|
|
||||||
if vms.has_key?(name)
|
if vms.key?(name)
|
||||||
@logger.info("Not setting the name because our name is already set.")
|
@logger.info("Not setting the name because our name is already set.")
|
||||||
else
|
else
|
||||||
env[:ui].info(I18n.t(
|
env[:ui].info(I18n.t(
|
||||||
|
|
|
@ -30,8 +30,8 @@ module VagrantPlugins
|
||||||
|
|
||||||
# On Windows, we use the VBOX_INSTALL_PATH environmental
|
# On Windows, we use the VBOX_INSTALL_PATH environmental
|
||||||
# variable to find VBoxManage.
|
# variable to find VBoxManage.
|
||||||
if ENV.has_key?("VBOX_INSTALL_PATH") ||
|
if ENV.key?("VBOX_INSTALL_PATH") ||
|
||||||
ENV.has_key?("VBOX_MSI_INSTALL_PATH")
|
ENV.key?("VBOX_MSI_INSTALL_PATH")
|
||||||
# Get the path.
|
# Get the path.
|
||||||
path = ENV["VBOX_INSTALL_PATH"] || ENV["VBOX_MSI_INSTALL_PATH"]
|
path = ENV["VBOX_INSTALL_PATH"] || ENV["VBOX_MSI_INSTALL_PATH"]
|
||||||
@logger.debug("VBOX_INSTALL_PATH value: #{path}")
|
@logger.debug("VBOX_INSTALL_PATH value: #{path}")
|
||||||
|
|
|
@ -445,7 +445,7 @@ module VagrantPlugins
|
||||||
folder[:name],
|
folder[:name],
|
||||||
"--hostpath",
|
"--hostpath",
|
||||||
folder[:hostpath]]
|
folder[:hostpath]]
|
||||||
args << "--transient" if folder.has_key?(:transient) && folder[:transient]
|
args << "--transient" if folder.key?(:transient) && folder[:transient]
|
||||||
execute("sharedfolder", "add", @uuid, *args)
|
execute("sharedfolder", "add", @uuid, *args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -450,7 +450,7 @@ module VagrantPlugins
|
||||||
folder[:name],
|
folder[:name],
|
||||||
"--hostpath",
|
"--hostpath",
|
||||||
folder[:hostpath]]
|
folder[:hostpath]]
|
||||||
args << "--transient" if folder.has_key?(:transient) && folder[:transient]
|
args << "--transient" if folder.key?(:transient) && folder[:transient]
|
||||||
|
|
||||||
# Enable symlinks on the shared folder
|
# Enable symlinks on the shared folder
|
||||||
execute("setextradata", @uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1")
|
execute("setextradata", @uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1")
|
||||||
|
|
|
@ -481,7 +481,7 @@ module VagrantPlugins
|
||||||
folder[:name],
|
folder[:name],
|
||||||
"--hostpath",
|
"--hostpath",
|
||||||
folder[:hostpath]]
|
folder[:hostpath]]
|
||||||
args << "--transient" if folder.has_key?(:transient) && folder[:transient]
|
args << "--transient" if folder.key?(:transient) && folder[:transient]
|
||||||
|
|
||||||
# Enable symlinks on the shared folder
|
# Enable symlinks on the shared folder
|
||||||
execute("setextradata", @uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1")
|
execute("setextradata", @uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1")
|
||||||
|
|
|
@ -498,7 +498,7 @@ module VagrantPlugins
|
||||||
folder[:name],
|
folder[:name],
|
||||||
"--hostpath",
|
"--hostpath",
|
||||||
folder[:hostpath]]
|
folder[:hostpath]]
|
||||||
args << "--transient" if folder.has_key?(:transient) && folder[:transient]
|
args << "--transient" if folder.key?(:transient) && folder[:transient]
|
||||||
|
|
||||||
# Enable symlinks on the shared folder
|
# Enable symlinks on the shared folder
|
||||||
execute("setextradata", @uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1")
|
execute("setextradata", @uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1")
|
||||||
|
|
|
@ -51,7 +51,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
options ||= {}
|
options ||= {}
|
||||||
@auto_correct = false
|
@auto_correct = false
|
||||||
@auto_correct = options[:auto_correct] if options.has_key?(:auto_correct)
|
@auto_correct = options[:auto_correct] if options.key?(:auto_correct)
|
||||||
@adapter = (options[:adapter] || 1).to_i
|
@adapter = (options[:adapter] || 1).to_i
|
||||||
@guest_ip = options[:guest_ip] || nil
|
@guest_ip = options[:guest_ip] || nil
|
||||||
@host_ip = options[:host_ip] || nil
|
@host_ip = options[:host_ip] || nil
|
||||||
|
|
|
@ -70,8 +70,8 @@ module VagrantPlugins
|
||||||
|
|
||||||
@__containers.each do |name, params|
|
@__containers.each do |name, params|
|
||||||
params[:image] ||= name
|
params[:image] ||= name
|
||||||
params[:auto_assign_name] = true if !params.has_key?(:auto_assign_name)
|
params[:auto_assign_name] = true if !params.key?(:auto_assign_name)
|
||||||
params[:daemonize] = true if !params.has_key?(:daemonize)
|
params[:daemonize] = true if !params.key?(:daemonize)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,7 +64,7 @@ module VagrantPlugins
|
||||||
export_folders = folders.dup
|
export_folders = folders.dup
|
||||||
export_folders.keys.each do |id|
|
export_folders.keys.each do |id|
|
||||||
opts = export_folders[id]
|
opts = export_folders[id]
|
||||||
if opts.has_key?(:nfs_export) && !opts[:nfs_export]
|
if opts.key?(:nfs_export) && !opts[:nfs_export]
|
||||||
export_folders.delete(id)
|
export_folders.delete(id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -117,7 +117,7 @@ module VagrantPlugins
|
||||||
def prepare_folder(machine, opts)
|
def prepare_folder(machine, opts)
|
||||||
opts[:map_uid] = prepare_permission(machine, :uid, opts)
|
opts[:map_uid] = prepare_permission(machine, :uid, opts)
|
||||||
opts[:map_gid] = prepare_permission(machine, :gid, opts)
|
opts[:map_gid] = prepare_permission(machine, :gid, opts)
|
||||||
opts[:nfs_udp] = true if !opts.has_key?(:nfs_udp)
|
opts[:nfs_udp] = true if !opts.key?(:nfs_udp)
|
||||||
opts[:nfs_version] ||= 3
|
opts[:nfs_version] ||= 3
|
||||||
|
|
||||||
# We use a CRC32 to generate a 32-bit checksum so that the
|
# We use a CRC32 to generate a 32-bit checksum so that the
|
||||||
|
@ -128,11 +128,11 @@ module VagrantPlugins
|
||||||
# Prepares the UID/GID settings for a single folder.
|
# Prepares the UID/GID settings for a single folder.
|
||||||
def prepare_permission(machine, perm, opts)
|
def prepare_permission(machine, perm, opts)
|
||||||
key = "map_#{perm}".to_sym
|
key = "map_#{perm}".to_sym
|
||||||
return nil if opts.has_key?(key) && opts[key].nil?
|
return nil if opts.key?(key) && opts[key].nil?
|
||||||
|
|
||||||
# The options on the hash get priority, then the default
|
# The options on the hash get priority, then the default
|
||||||
# values
|
# values
|
||||||
value = opts.has_key?(key) ? opts[key] : machine.config.nfs.send(key)
|
value = opts.key?(key) ? opts[key] : machine.config.nfs.send(key)
|
||||||
return value if value != :auto
|
return value if value != :auto
|
||||||
|
|
||||||
# Get UID/GID from folder if we've made it this far
|
# Get UID/GID from folder if we've made it this far
|
||||||
|
|
|
@ -83,7 +83,7 @@ module VagrantPlugins
|
||||||
folders.each do |id, folder_opts|
|
folders.each do |id, folder_opts|
|
||||||
# If we marked this folder to not auto sync, then
|
# If we marked this folder to not auto sync, then
|
||||||
# don't do it.
|
# don't do it.
|
||||||
next if folder_opts.has_key?(:auto) && !folder_opts[:auto]
|
next if folder_opts.key?(:auto) && !folder_opts[:auto]
|
||||||
|
|
||||||
hostpath = folder_opts[:hostpath]
|
hostpath = folder_opts[:hostpath]
|
||||||
hostpath = File.expand_path(hostpath, machine.env.root_path)
|
hostpath = File.expand_path(hostpath, machine.env.root_path)
|
||||||
|
|
|
@ -87,6 +87,6 @@ describe Vagrant::Action::Warden do
|
||||||
expect { instance.call(data) }.to raise_error(SystemExit)
|
expect { instance.call(data) }.to raise_error(SystemExit)
|
||||||
|
|
||||||
# The recover should not have been called
|
# The recover should not have been called
|
||||||
expect(data.has_key?(:recover)).not_to be
|
expect(data.key?(:recover)).not_to be
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe Vagrant::Util::HashWithIndifferentAccess do
|
||||||
it "allows indifferent key lookup" do
|
it "allows indifferent key lookup" do
|
||||||
instance["foo"] = "bar"
|
instance["foo"] = "bar"
|
||||||
expect(instance.key?(:foo)).to be
|
expect(instance.key?(:foo)).to be
|
||||||
expect(instance.has_key?(:foo)).to be
|
expect(instance.key?(:foo)).to be
|
||||||
expect(instance.include?(:foo)).to be
|
expect(instance.include?(:foo)).to be
|
||||||
expect(instance.member?(:foo)).to be
|
expect(instance.member?(:foo)).to be
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue