mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-25 00:50:31 +00:00
FilesystemProvider: added .Name() which reverses vfs.GetProviderByName(), and added .ShortInfo(); using .ShortInfo() in User.GetInfoString()
This commit is contained in:
parent
0ff010cc94
commit
b48e01155c
2 changed files with 40 additions and 11 deletions
|
@ -1005,17 +1005,8 @@ func (u *User) GetInfoString() string {
|
|||
t := utils.GetTimeFromMsecSinceEpoch(u.LastLogin)
|
||||
result += fmt.Sprintf("Last login: %v ", t.Format("2006-01-02 15:04")) // YYYY-MM-DD HH:MM
|
||||
}
|
||||
switch u.FsConfig.Provider {
|
||||
case vfs.S3FilesystemProvider:
|
||||
result += "Storage: S3 "
|
||||
case vfs.GCSFilesystemProvider:
|
||||
result += "Storage: GCS "
|
||||
case vfs.AzureBlobFilesystemProvider:
|
||||
result += "Storage: AzBlob "
|
||||
case vfs.CryptedFilesystemProvider:
|
||||
result += "Storage: Encrypted "
|
||||
case vfs.SFTPFilesystemProvider:
|
||||
result += "Storage: SFTP "
|
||||
if u.FsConfig.Provider != vfs.LocalFilesystemProvider {
|
||||
result += fmt.Sprintf("Storage: %s ", u.FsConfig.Provider.ShortInfo())
|
||||
}
|
||||
if len(u.PublicKeys) > 0 {
|
||||
result += fmt.Sprintf("Public keys: %v ", len(u.PublicKeys))
|
||||
|
|
|
@ -43,6 +43,44 @@ func GetProviderByName(name string) FilesystemProvider {
|
|||
return LocalFilesystemProvider
|
||||
}
|
||||
|
||||
// Name returns the Provider's unique name
|
||||
func (p FilesystemProvider) Name() string {
|
||||
switch p {
|
||||
case LocalFilesystemProvider:
|
||||
return "osfs"
|
||||
case S3FilesystemProvider:
|
||||
return "s3fs"
|
||||
case GCSFilesystemProvider:
|
||||
return "gcsfs"
|
||||
case AzureBlobFilesystemProvider:
|
||||
return "azblobfs"
|
||||
case CryptedFilesystemProvider:
|
||||
return "cryptfs"
|
||||
case SFTPFilesystemProvider:
|
||||
return "sftpfs"
|
||||
}
|
||||
return "" // let's not claim to be
|
||||
}
|
||||
|
||||
// ShortInfo returns a human readable, short description for the given FilesystemProvider
|
||||
func (p FilesystemProvider) ShortInfo() string {
|
||||
switch p {
|
||||
case LocalFilesystemProvider:
|
||||
return "Local"
|
||||
case S3FilesystemProvider:
|
||||
return "S3"
|
||||
case GCSFilesystemProvider:
|
||||
return "GCS"
|
||||
case AzureBlobFilesystemProvider:
|
||||
return "AzBlob"
|
||||
case CryptedFilesystemProvider:
|
||||
return "Encrypted"
|
||||
case SFTPFilesystemProvider:
|
||||
return "SFTP"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ValidatorHelper implements methods we need for Filesystem.ValidateConfig.
|
||||
// It is implemented by vfs.Folder and dataprovider.User
|
||||
type ValidatorHelper interface {
|
||||
|
|
Loading…
Reference in a new issue