Skip to content

Commit

Permalink
cap: add sshfs_get_absolute_path guest capability
Browse files Browse the repository at this point in the history
  • Loading branch information
dustymabe committed Nov 12, 2016
1 parent b0c5bd8 commit a4abb8a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/vagrant-sshfs/cap/guest/linux/sshfs_get_absolute_path.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module VagrantPlugins
module GuestLinux
module Cap
class SSHFSGetAbsolutePath
def self.sshfs_get_absolute_path(machine, path)
abs_path = ""
machine.communicate.execute("readlink -f #{path}") do |type, data|
if type == :stdout
abs_path = data
end
end

if ! abs_path
# If no real absolute path was detected then error out
error_class = VagrantPlugins::SyncedFolderSSHFS::Errors::SSHFSGetAbsolutePathFailed
raise error_class, path: path
end

# Chomp the string so that any trailing newlines are killed
return abs_path.chomp
end
end
end
end
end
4 changes: 4 additions & 0 deletions lib/vagrant-sshfs/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class SSHFSNotInstalledInGuest < SSHFSError
class SSHFSExeNotAvailable < SSHFSError
error_key(:exe_not_in_host)
end

class SSHFSGetAbsolutePathFailed < SSHFSError
error_key(:get_absolute_path_failed)
end
end
end
end
5 changes: 5 additions & 0 deletions lib/vagrant-sshfs/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class Plugin < Vagrant.plugin("2")
VagrantPlugins::GuestLinux::Cap::MountSSHFS
end

guest_capability("linux", "sshfs_get_absolute_path") do
require_relative "cap/guest/linux/sshfs_get_absolute_path"
VagrantPlugins::GuestLinux::Cap::SSHFSGetAbsolutePath
end

guest_capability("redhat", "sshfs_installed") do
require_relative "cap/guest/redhat/sshfs_client"
VagrantPlugins::GuestRedHat::Cap::SSHFSClient
Expand Down
2 changes: 2 additions & 0 deletions locales/synced_folder_sshfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ en:
try again.
sshfs_not_in_guest: |-
The necessary SSHFS software is not installed in the guest.
get_absolute_path_failed: |-
Could not get the absolute path of the folder within the guest '%{path}'
install_failed_arch: |-
The install of the sshfs client software failed. On Arch this is most likely
because the package lists are not up to date [1] and partial upgrades are not
Expand Down

0 comments on commit a4abb8a

Please sign in to comment.