Class: VagrantPlugins::AVF::SharedDirectories

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_provider_avf/shared_directories.rb

Constant Summary collapse

SYNCED_FOLDER_TYPE =
:avf_virtiofs

Class Method Summary collapse

Class Method Details

.expand_host_path(root_path, host_path) ⇒ Object



25
26
27
28
29
30
# File 'lib/vagrant_provider_avf/shared_directories.rb', line 25

def self.expand_host_path(root_path, host_path)
  expanded_path = File.expand_path(host_path, root_path.to_s)
  return File.realpath(expanded_path) if File.directory?(expanded_path)

  expanded_path
end

.for(machine) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/vagrant_provider_avf/shared_directories.rb', line 6

def self.for(machine)
  machine.config.vm.synced_folders.each_with_object([]) do |(id, data), shared_directories|
    next if data[:disabled]
    next unless supported_type?(data[:type])

    shared_directories << Model::SharedDirectory.new(
      id: id,
      host_path: expand_host_path(machine.env.root_path, data[:hostpath]),
      guest_path: data[:guestpath]
    )
  end
end

.supported_type?(type) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/vagrant_provider_avf/shared_directories.rb', line 19

def self.supported_type?(type)
  return true if type.nil? || type.to_s.empty?

  type.to_sym == SYNCED_FOLDER_TYPE
end