Documentation ¶
Overview ¶
Package vfs provides local and remote filesystems support
Index ¶
- func GetSFTPError(fs Fs, err error) error
- func IsDirectory(fs Fs, path string) (bool, error)
- func IsLocalOsFs(fs Fs) bool
- func SetPathPermissions(fs Fs, path string, uid int, gid int)
- func ValidateGCSFsConfig(config *GCSFsConfig, credentialsFilePath string) error
- func ValidateS3FsConfig(config *S3FsConfig) error
- type FileInfo
- type Fs
- type GCSFs
- func (fs GCSFs) CheckRootPath(username string, uid int, gid int) bool
- func (GCSFs) Chmod(name string, mode os.FileMode) error
- func (GCSFs) Chown(name string, uid int, gid int) error
- func (GCSFs) Chtimes(name string, atime, mtime time.Time) error
- func (fs GCSFs) ConnectionID() string
- func (fs GCSFs) Create(name string, flag int) (*os.File, *pipeat.PipeWriterAt, func(), error)
- func (GCSFs) GetAtomicUploadPath(name string) string
- func (fs GCSFs) GetRelativePath(name string) string
- func (GCSFs) IsAtomicUploadSupported() bool
- func (GCSFs) IsNotExist(err error) bool
- func (GCSFs) IsPermission(err error) bool
- func (GCSFs) IsUploadResumeSupported() bool
- func (GCSFs) Join(elem ...string) string
- func (fs GCSFs) Lstat(name string) (os.FileInfo, error)
- func (fs GCSFs) Mkdir(name string) error
- func (fs GCSFs) Name() string
- func (fs GCSFs) Open(name string) (*os.File, *pipeat.PipeReaderAt, func(), error)
- func (fs GCSFs) ReadDir(dirname string) ([]os.FileInfo, error)
- func (fs GCSFs) Remove(name string, isDir bool) error
- func (fs GCSFs) Rename(source, target string) error
- func (fs GCSFs) ResolvePath(sftpPath string) (string, error)
- func (fs GCSFs) ScanRootDirContents() (int, int64, error)
- func (fs GCSFs) Stat(name string) (os.FileInfo, error)
- func (GCSFs) Symlink(source, target string) error
- type GCSFsConfig
- type OsFs
- func (fs OsFs) CheckRootPath(username string, uid int, gid int) bool
- func (OsFs) Chmod(name string, mode os.FileMode) error
- func (OsFs) Chown(name string, uid int, gid int) error
- func (OsFs) Chtimes(name string, atime, mtime time.Time) error
- func (fs OsFs) ConnectionID() string
- func (OsFs) Create(name string, flag int) (*os.File, *pipeat.PipeWriterAt, func(), error)
- func (OsFs) GetAtomicUploadPath(name string) string
- func (fs OsFs) GetRelativePath(name string) string
- func (OsFs) IsAtomicUploadSupported() bool
- func (OsFs) IsNotExist(err error) bool
- func (OsFs) IsPermission(err error) bool
- func (OsFs) IsUploadResumeSupported() bool
- func (OsFs) Join(elem ...string) string
- func (OsFs) Lstat(name string) (os.FileInfo, error)
- func (OsFs) Mkdir(name string) error
- func (fs OsFs) Name() string
- func (OsFs) Open(name string) (*os.File, *pipeat.PipeReaderAt, func(), error)
- func (OsFs) ReadDir(dirname string) ([]os.FileInfo, error)
- func (OsFs) Remove(name string, isDir bool) error
- func (OsFs) Rename(source, target string) error
- func (fs OsFs) ResolvePath(sftpPath string) (string, error)
- func (fs OsFs) ScanRootDirContents() (int, int64, error)
- func (OsFs) Stat(name string) (os.FileInfo, error)
- func (OsFs) Symlink(source, target string) error
- type S3Fs
- func (fs S3Fs) CheckRootPath(username string, uid int, gid int) bool
- func (S3Fs) Chmod(name string, mode os.FileMode) error
- func (S3Fs) Chown(name string, uid int, gid int) error
- func (S3Fs) Chtimes(name string, atime, mtime time.Time) error
- func (fs S3Fs) ConnectionID() string
- func (fs S3Fs) Create(name string, flag int) (*os.File, *pipeat.PipeWriterAt, func(), error)
- func (S3Fs) GetAtomicUploadPath(name string) string
- func (fs S3Fs) GetRelativePath(name string) string
- func (S3Fs) IsAtomicUploadSupported() bool
- func (S3Fs) IsNotExist(err error) bool
- func (S3Fs) IsPermission(err error) bool
- func (S3Fs) IsUploadResumeSupported() bool
- func (S3Fs) Join(elem ...string) string
- func (fs S3Fs) Lstat(name string) (os.FileInfo, error)
- func (fs S3Fs) Mkdir(name string) error
- func (fs S3Fs) Name() string
- func (fs S3Fs) Open(name string) (*os.File, *pipeat.PipeReaderAt, func(), error)
- func (fs S3Fs) ReadDir(dirname string) ([]os.FileInfo, error)
- func (fs S3Fs) Remove(name string, isDir bool) error
- func (fs S3Fs) Rename(source, target string) error
- func (fs S3Fs) ResolvePath(sftpPath string) (string, error)
- func (fs S3Fs) ScanRootDirContents() (int, int64, error)
- func (fs S3Fs) Stat(name string) (os.FileInfo, error)
- func (S3Fs) Symlink(source, target string) error
- type S3FsConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSFTPError ¶
GetSFTPError returns an sftp error from a filesystem error
func IsDirectory ¶
IsDirectory checks if a path exists and is a directory
func IsLocalOsFs ¶
IsLocalOsFs returns true if fs is the local filesystem implementation
func SetPathPermissions ¶
SetPathPermissions calls fs.Chown. It does nothing for local filesystem on windows
func ValidateGCSFsConfig ¶
func ValidateGCSFsConfig(config *GCSFsConfig, credentialsFilePath string) error
ValidateGCSFsConfig returns nil if the specified GCS config is valid, otherwise an error
func ValidateS3FsConfig ¶
func ValidateS3FsConfig(config *S3FsConfig) error
ValidateS3FsConfig returns nil if the specified s3 config is valid, otherwise an error
Types ¶
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo implements os.FileInfo for a file in S3.
func NewFileInfo ¶
NewFileInfo creates file info.
type Fs ¶
type Fs interface { Name() string ConnectionID() string Stat(name string) (os.FileInfo, error) Lstat(name string) (os.FileInfo, error) Open(name string) (*os.File, *pipeat.PipeReaderAt, func(), error) Create(name string, flag int) (*os.File, *pipeat.PipeWriterAt, func(), error) Rename(source, target string) error Remove(name string, isDir bool) error Mkdir(name string) error Symlink(source, target string) error Chown(name string, uid int, gid int) error Chmod(name string, mode os.FileMode) error Chtimes(name string, atime, mtime time.Time) error ReadDir(dirname string) ([]os.FileInfo, error) IsUploadResumeSupported() bool IsAtomicUploadSupported() bool CheckRootPath(username string, uid int, gid int) bool ResolvePath(sftpPath string) (string, error) IsNotExist(err error) bool IsPermission(err error) bool ScanRootDirContents() (int, int64, error) GetAtomicUploadPath(name string) string GetRelativePath(name string) string Join(elem ...string) string }
Fs defines the interface for filesystem backends
func NewGCSFs ¶
func NewGCSFs(connectionID, localTempDir string, config GCSFsConfig) (Fs, error)
NewGCSFs returns an GCSFs object that allows to interact with Google Cloud Storage
type GCSFs ¶
type GCSFs struct {
// contains filtered or unexported fields
}
GCSFs is a Fs implementation for Google Cloud Storage.
func (GCSFs) CheckRootPath ¶
CheckRootPath creates the specified root directory if it does not exists
func (GCSFs) Chtimes ¶
Chtimes changes the access and modification times of the named file. Silently ignored.
func (GCSFs) ConnectionID ¶
ConnectionID returns the SSH connection ID associated to this Fs implementation
func (GCSFs) GetAtomicUploadPath ¶
GetAtomicUploadPath returns the path to use for an atomic upload. S3 uploads are already atomic, we never call this method for S3
func (GCSFs) GetRelativePath ¶
GetRelativePath returns the path for a file relative to the user's home dir. This is the path as seen by SFTP users
func (GCSFs) IsAtomicUploadSupported ¶
IsAtomicUploadSupported returns true if atomic upload is supported. S3 uploads are already atomic, we don't need to upload to a temporary file
func (GCSFs) IsNotExist ¶
IsNotExist returns a boolean indicating whether the error is known to report that a file or directory does not exist
func (GCSFs) IsPermission ¶
IsPermission returns a boolean indicating whether the error is known to report that permission is denied.
func (GCSFs) IsUploadResumeSupported ¶
IsUploadResumeSupported returns true if upload resume is supported. SFTP Resume is not supported on S3
func (GCSFs) ReadDir ¶
ReadDir reads the directory named by dirname and returns a list of directory entries.
func (GCSFs) Rename ¶
Rename renames (moves) source to target. We don't support renaming non empty directories since we should rename all the contents too and this could take long time: think about directories with thousands of files, for each file we should execute a CopyObject call.
func (GCSFs) ResolvePath ¶
ResolvePath returns the matching filesystem path for the specified sftp path
func (GCSFs) ScanRootDirContents ¶
ScanRootDirContents returns the number of files contained in the bucket, and their size
type GCSFsConfig ¶
type GCSFsConfig struct { Bucket string `json:"bucket,omitempty"` // KeyPrefix is similar to a chroot directory for local filesystem. // If specified the SFTP user will only see objects that starts with // this prefix and so you can restrict access to a specific virtual // folder. The prefix, if not empty, must not start with "/" and must // end with "/". // If empty the whole bucket contents will be available KeyPrefix string `json:"key_prefix,omitempty"` CredentialFile string `json:"-"` Credentials string `json:"credentials,omitempty"` StorageClass string `json:"storage_class,omitempty"` }
GCSFsConfig defines the configuration for Google Cloud Storage based filesystem
type OsFs ¶
type OsFs struct {
// contains filtered or unexported fields
}
OsFs is a Fs implementation that uses functions provided by the os package.
func (OsFs) CheckRootPath ¶
CheckRootPath creates the root directory if it does not exists
func (OsFs) ConnectionID ¶
ConnectionID returns the SSH connection ID associated to this Fs implementation
func (OsFs) GetAtomicUploadPath ¶
GetAtomicUploadPath returns the path to use for an atomic upload
func (OsFs) GetRelativePath ¶
GetRelativePath returns the path for a file relative to the user's home dir. This is the path as seen by SFTP users
func (OsFs) IsAtomicUploadSupported ¶
IsAtomicUploadSupported returns true if atomic upload is supported
func (OsFs) IsNotExist ¶
IsNotExist returns a boolean indicating whether the error is known to report that a file or directory does not exist
func (OsFs) IsPermission ¶
IsPermission returns a boolean indicating whether the error is known to report that permission is denied.
func (OsFs) IsUploadResumeSupported ¶
IsUploadResumeSupported returns true if upload resume is supported
func (OsFs) ReadDir ¶
ReadDir reads the directory named by dirname and returns a list of directory entries.
func (OsFs) ResolvePath ¶
ResolvePath returns the matching filesystem path for the specified sftp path
func (OsFs) ScanRootDirContents ¶
ScanRootDirContents returns the number of files contained in a directory and their size
type S3Fs ¶
type S3Fs struct {
// contains filtered or unexported fields
}
S3Fs is a Fs implementation for Amazon S3 compatible object storage.
func (S3Fs) CheckRootPath ¶
CheckRootPath creates the specified root directory if it does not exists
func (S3Fs) Chtimes ¶
Chtimes changes the access and modification times of the named file. Silently ignored.
func (S3Fs) ConnectionID ¶
ConnectionID returns the SSH connection ID associated to this Fs implementation
func (S3Fs) GetAtomicUploadPath ¶
GetAtomicUploadPath returns the path to use for an atomic upload. S3 uploads are already atomic, we never call this method for S3
func (S3Fs) GetRelativePath ¶
GetRelativePath returns the path for a file relative to the user's home dir. This is the path as seen by SFTP users
func (S3Fs) IsAtomicUploadSupported ¶
IsAtomicUploadSupported returns true if atomic upload is supported. S3 uploads are already atomic, we don't need to upload to a temporary file
func (S3Fs) IsNotExist ¶
IsNotExist returns a boolean indicating whether the error is known to report that a file or directory does not exist
func (S3Fs) IsPermission ¶
IsPermission returns a boolean indicating whether the error is known to report that permission is denied.
func (S3Fs) IsUploadResumeSupported ¶
IsUploadResumeSupported returns true if upload resume is supported. SFTP Resume is not supported on S3
func (S3Fs) ReadDir ¶
ReadDir reads the directory named by dirname and returns a list of directory entries.
func (S3Fs) Rename ¶
Rename renames (moves) source to target. We don't support renaming non empty directories since we should rename all the contents too and this could take long time: think about directories with thousands of files, for each file we should execute a CopyObject call. TODO: rename does not work for files bigger than 5GB, implement multipart copy or wait for this pull request to be merged:
func (S3Fs) ResolvePath ¶
ResolvePath returns the matching filesystem path for the specified sftp path
func (S3Fs) ScanRootDirContents ¶
ScanRootDirContents returns the number of files contained in the bucket, and their size
type S3FsConfig ¶
type S3FsConfig struct { Bucket string `json:"bucket,omitempty"` // KeyPrefix is similar to a chroot directory for local filesystem. // If specified the SFTP user will only see objects that starts with // this prefix and so you can restrict access to a specific virtual // folder. The prefix, if not empty, must not start with "/" and must // end with "/". // If empty the whole bucket contents will be available KeyPrefix string `json:"key_prefix,omitempty"` Region string `json:"region,omitempty"` AccessKey string `json:"access_key,omitempty"` AccessSecret string `json:"access_secret,omitempty"` Endpoint string `json:"endpoint,omitempty"` StorageClass string `json:"storage_class,omitempty"` }
S3FsConfig defines the configuration for S3 based filesystem