Sha256: 642279cd4f8bf2387b4ac65a30713a0d4d8ecbb063d3097915543b9eaa83778b

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

module Vagrant
  module LXC
    class SyncedFolder < Vagrant.plugin("2", :synced_folder)
      def usable?(machine)
        # These synced folders only work if the provider is LXC
        machine.provider_name == :lxc
      end

      def prepare(machine, folders, _opts)
        machine.ui.output(I18n.t("vagrant.actions.lxc.share_folders.preparing"))

        folders.each do |id, data|
          host_path  = Pathname.new(File.expand_path(data[:hostpath], machine.env.root_path))
          guest_path = data[:guestpath]

          machine.env.ui.warn(I18n.t("vagrant_lxc.messages.warn_owner")) if data[:owner]
          machine.env.ui.warn(I18n.t("vagrant_lxc.messages.warn_group")) if data[:group]

          if !host_path.directory? && data[:create]
            # Host path doesn't exist, so let's create it.
            @logger.info("Host path doesn't exist, creating: #{host_path}")

            begin
              host_path.mkpath
            rescue Errno::EACCES
              raise Vagrant::Errors::SharedFolderCreateFailed,
                :path => hostpath.to_s
            end
          end

          mount_opts = data[:mount_options]
          machine.provider.driver.share_folder(host_path, guest_path, mount_opts)
          # Guest path specified, so mount the folder to specified point
          machine.ui.detail(I18n.t("vagrant.actions.vm.share_folders.mounting_entry",
                                guestpath:  data[:guestpath],
                                hostpath:   data[:hostpath],
                                guest_path: data[:guestpath]))
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-lxc-1.0.0.alpha.1 lib/vagrant-lxc/synced_folder.rb