Create Hash with type attribute
This commit is contained in:
parent
faad9f2717
commit
2239ee8582
@ -2,6 +2,7 @@ require "json"
|
||||
require "set"
|
||||
|
||||
require 'vagrant/util/scoped_hash_override'
|
||||
require 'vagrant/util/typed_hash'
|
||||
|
||||
module Vagrant
|
||||
module Action
|
||||
@ -36,11 +37,7 @@ module Vagrant
|
||||
|
||||
# Find the proper implementation
|
||||
ordered.each do |_, key, impl|
|
||||
begin
|
||||
return key if impl.new.usable?(machine)
|
||||
rescue
|
||||
# Don't do anything. If an error is raised, the impl is not usable
|
||||
end
|
||||
return key if impl.new.usable?(machine)
|
||||
end
|
||||
|
||||
return nil
|
||||
@ -128,7 +125,7 @@ module Vagrant
|
||||
end
|
||||
|
||||
config_folders = config.synced_folders
|
||||
folders = {}
|
||||
folders = Vagrant::Util::TypedHash.new()
|
||||
|
||||
# Determine all the synced folders as well as the implementation
|
||||
# they're going to use.
|
||||
@ -194,6 +191,12 @@ module Vagrant
|
||||
folders[impl_name] = new_fs
|
||||
end
|
||||
|
||||
|
||||
folders.types = folders.map { |type, folders|
|
||||
impl = plugins[type][0].new()
|
||||
impl._initialize(machine, type)
|
||||
[type, impl]
|
||||
}.to_h
|
||||
return folders
|
||||
end
|
||||
|
||||
|
||||
@ -628,20 +628,6 @@ module Vagrant
|
||||
self.class.synced_folders(self)
|
||||
end
|
||||
|
||||
# Returns the SyncedFolder object associated with this machine.
|
||||
#
|
||||
# @return [List<Class>]
|
||||
def synced_folder_types
|
||||
return @synced_folder_types if defined?(@synced_folder_types)
|
||||
plugins = Vagrant.plugin("2").manager.synced_folders
|
||||
@synced_folder_types = synced_folders.map { |type, folders|
|
||||
impl = plugins[type][0].new()
|
||||
impl._initialize(self, type)
|
||||
[type, impl]
|
||||
}.to_h
|
||||
@synced_folder_types
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Returns the path to the file that stores the UID.
|
||||
|
||||
10
lib/vagrant/util/typed_hash.rb
Normal file
10
lib/vagrant/util/typed_hash.rb
Normal file
@ -0,0 +1,10 @@
|
||||
module Vagrant
|
||||
module Util
|
||||
class TypedHash < Hash
|
||||
|
||||
# Types available in the Hash
|
||||
attr_accessor :types
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -16,7 +16,7 @@ module VagrantPlugins
|
||||
builtin_mount_type = "-cit #{VB_MOUNT_TYPE}"
|
||||
addon_mount_type = "-t #{VB_MOUNT_TYPE}"
|
||||
|
||||
mount_options, mount_uid, mount_gid = machine.synced_folder_types[:virtualbox].capability(:mount_options, name, guestpath, options)
|
||||
mount_options, mount_uid, mount_gid = machine.synced_folders.types[:virtualbox].capability(:mount_options, name, guest_path, options)
|
||||
mount_command = "mount #{addon_mount_type} -o #{mount_options} #{name} #{guest_path}"
|
||||
|
||||
# Create the guest path if it doesn't exist
|
||||
|
||||
@ -22,7 +22,7 @@ module VagrantPlugins
|
||||
end
|
||||
export_folders = fstab_folders.map do |name, data|
|
||||
guest_path = Shellwords.escape(data[:guestpath])
|
||||
mount_options, mount_uid, mount_gid = machine.synced_folder_types[:virtualbox].capability(:mount_options, name, guest_path, data)
|
||||
mount_options, _, _ = machine.synced_folders.types[:virtualbox].capability(:mount_options, name, guest_path, data)
|
||||
mount_options = "#{mount_options},nofail"
|
||||
{
|
||||
name: name,
|
||||
|
||||
@ -727,7 +727,7 @@ module VagrantPlugins
|
||||
|
||||
if @allow_fstab_modification == UNSET_VALUE
|
||||
plugins = Vagrant.plugin("2").manager.synced_folders
|
||||
machine.synced_folder_types.each do |_, inst|
|
||||
machine.synced_folders.types.each do |_, inst|
|
||||
if inst.capability?(:default_fstab_modification)
|
||||
if inst.capability(:default_fstab_modification) == false
|
||||
@allow_fstab_modification = false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user