switch to config file and implement src path filter

This commit is contained in:
ston1th 2022-10-07 22:57:54 +02:00
commit a6b9602821
30 changed files with 11907 additions and 60 deletions

View file

@ -5,12 +5,14 @@ package parse
import (
"cachefs/pkg/provider"
"cachefs/pkg/provider/crypto"
"cachefs/pkg/provider/filter"
"cachefs/pkg/provider/os"
"cachefs/pkg/provider/sftp"
"errors"
"fmt"
neturl "net/url"
"path/filepath"
"regexp"
"k8s.io/klog/v2/klogr"
)
@ -36,7 +38,7 @@ func TryParse(url string) error {
return nil
}
func FS(url string, key []byte, block bool) (provider.FS, error) {
func FS(url string, key []byte, re *regexp.Regexp, block bool) (provider.FS, error) {
u, err := neturl.Parse(url)
if err != nil {
return nil, err
@ -58,6 +60,12 @@ func FS(url string, key []byte, block bool) (provider.FS, error) {
}
if key != nil {
fs, err = crypto.NewFS(fs, key)
if err != nil {
return nil, err
}
}
if re != nil {
fs, err = filter.NewFS(fs, re)
}
return fs, err
}