forked from TrueCloudLab/rclone
Use config.FileGet instead of fs.ConfigFileGet
This commit is contained in:
parent
512f4b4487
commit
e5ff375948
4 changed files with 10 additions and 9 deletions
6
backend/cache/cache_internal_test.go
vendored
6
backend/cache/cache_internal_test.go
vendored
|
@ -1396,7 +1396,7 @@ func (r *run) newCacheFs(t *testing.T, remote, id string, needRemote, purge bool
|
||||||
config.FileSet(remote, "type", "cache")
|
config.FileSet(remote, "type", "cache")
|
||||||
config.FileSet(remote, "remote", localRemote+":/var/tmp/"+localRemote)
|
config.FileSet(remote, "remote", localRemote+":/var/tmp/"+localRemote)
|
||||||
} else {
|
} else {
|
||||||
remoteType := fs.ConfigFileGet(remote, "type", "")
|
remoteType := config.FileGet(remote, "type", "")
|
||||||
if remoteType == "" {
|
if remoteType == "" {
|
||||||
t.Skipf("skipped due to invalid remote type for %v", remote)
|
t.Skipf("skipped due to invalid remote type for %v", remote)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -1407,14 +1407,14 @@ func (r *run) newCacheFs(t *testing.T, remote, id string, needRemote, purge bool
|
||||||
config.FileSet(remote, "password", cryptPassword1)
|
config.FileSet(remote, "password", cryptPassword1)
|
||||||
config.FileSet(remote, "password2", cryptPassword2)
|
config.FileSet(remote, "password2", cryptPassword2)
|
||||||
}
|
}
|
||||||
remoteRemote := fs.ConfigFileGet(remote, "remote", "")
|
remoteRemote := config.FileGet(remote, "remote", "")
|
||||||
if remoteRemote == "" {
|
if remoteRemote == "" {
|
||||||
t.Skipf("skipped due to invalid remote wrapper for %v", remote)
|
t.Skipf("skipped due to invalid remote wrapper for %v", remote)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
remoteRemoteParts := strings.Split(remoteRemote, ":")
|
remoteRemoteParts := strings.Split(remoteRemote, ":")
|
||||||
remoteWrapping := remoteRemoteParts[0]
|
remoteWrapping := remoteRemoteParts[0]
|
||||||
remoteType := fs.ConfigFileGet(remoteWrapping, "type", "")
|
remoteType := config.FileGet(remoteWrapping, "type", "")
|
||||||
if remoteType != "cache" {
|
if remoteType != "cache" {
|
||||||
t.Skipf("skipped due to invalid remote type for %v: '%v'", remoteWrapping, remoteType)
|
t.Skipf("skipped due to invalid remote type for %v: '%v'", remoteWrapping, remoteType)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
"github.com/ncw/rclone/fs"
|
||||||
|
"github.com/ncw/rclone/fs/config"
|
||||||
"github.com/ncw/rclone/fs/config/flags"
|
"github.com/ncw/rclone/fs/config/flags"
|
||||||
"github.com/ncw/rclone/fs/config/obscure"
|
"github.com/ncw/rclone/fs/config/obscure"
|
||||||
"github.com/ncw/rclone/fs/fshttp"
|
"github.com/ncw/rclone/fs/fshttp"
|
||||||
|
@ -144,8 +145,8 @@ func (f *Fs) readMetaDataForPath(remote string) (info *mega.Node, err error) {
|
||||||
|
|
||||||
// NewFs constructs an Fs from the path, container:path
|
// NewFs constructs an Fs from the path, container:path
|
||||||
func NewFs(name, root string) (fs.Fs, error) {
|
func NewFs(name, root string) (fs.Fs, error) {
|
||||||
user := fs.ConfigFileGet(name, "user")
|
user := config.FileGet(name, "user")
|
||||||
pass := fs.ConfigFileGet(name, "pass")
|
pass := config.FileGet(name, "pass")
|
||||||
if pass != "" {
|
if pass != "" {
|
||||||
var err error
|
var err error
|
||||||
pass, err = obscure.Reveal(pass)
|
pass, err = obscure.Reveal(pass)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
"github.com/ncw/rclone/fs"
|
||||||
|
"github.com/ncw/rclone/fs/config"
|
||||||
"github.com/ncw/rclone/fs/config/obscure"
|
"github.com/ncw/rclone/fs/config/obscure"
|
||||||
"github.com/ncw/rclone/fs/fserrors"
|
"github.com/ncw/rclone/fs/fserrors"
|
||||||
"github.com/ncw/rclone/fs/fshttp"
|
"github.com/ncw/rclone/fs/fshttp"
|
||||||
|
@ -111,11 +112,11 @@ func (f *Fs) DirCacheFlush() {
|
||||||
// NewFs contstructs an Fs from the path, bucket:path
|
// NewFs contstructs an Fs from the path, bucket:path
|
||||||
func NewFs(name, root string) (fs.Fs, error) {
|
func NewFs(name, root string) (fs.Fs, error) {
|
||||||
root = parsePath(root)
|
root = parsePath(root)
|
||||||
username := fs.ConfigFileGet(name, "username")
|
username := config.FileGet(name, "username")
|
||||||
if username == "" {
|
if username == "" {
|
||||||
return nil, errors.New("username not found")
|
return nil, errors.New("username not found")
|
||||||
}
|
}
|
||||||
password, err := obscure.Reveal(fs.ConfigFileGet(name, "password"))
|
password, err := obscure.Reveal(config.FileGet(name, "password"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("password coudl not revealed")
|
return nil, errors.New("password coudl not revealed")
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/ncw/rclone/cmd"
|
"github.com/ncw/rclone/cmd"
|
||||||
"github.com/ncw/rclone/fs"
|
|
||||||
"github.com/ncw/rclone/fs/config"
|
"github.com/ncw/rclone/fs/config"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -40,7 +39,7 @@ When uses with the -l flag it lists the types too.
|
||||||
}
|
}
|
||||||
for _, remote := range remotes {
|
for _, remote := range remotes {
|
||||||
if listLong {
|
if listLong {
|
||||||
remoteType := fs.ConfigFileGet(remote, "type", "UNKNOWN")
|
remoteType := config.FileGet(remote, "type", "UNKNOWN")
|
||||||
fmt.Printf("%-*s %s\n", maxlen+1, remote+":", remoteType)
|
fmt.Printf("%-*s %s\n", maxlen+1, remote+":", remoteType)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s:\n", remote)
|
fmt.Printf("%s:\n", remote)
|
||||||
|
|
Loading…
Reference in a new issue