Clean segregated file share backends

This commit is contained in:
AlexSSD7 2023-08-31 16:19:03 +01:00
commit 40aa08c86c
6 changed files with 320 additions and 0 deletions

19
share/backend.go Normal file
View file

@ -0,0 +1,19 @@
package share
import "context"
type NewBackendFunc func(uc *UserConfiguration) (Backend, *VMShareOptions, error)
type Backend interface {
Apply(ctx context.Context, sharePWD string, vc *VMShareContext) (string, error)
}
var backends = map[string]NewBackendFunc{
"ftp": NewFTPBackend,
"smb": NewSMBBackend,
}
// Will return nil if no backend is found.
func GetBackend(id string) NewBackendFunc {
return backends[id]
}