fs: allow backends to be named using their Name or Prefix #2449
This means that, for example Google Cloud Storage can be known as `:gcs:bucket` on the command line, as well as `:google cloud storage:bucket`.
This commit is contained in:
parent
8656bd2bb0
commit
94950258a4
1 changed files with 4 additions and 3 deletions
7
fs/fs.go
7
fs/fs.go
|
@ -827,16 +827,17 @@ type ObjectPair struct {
|
||||||
Src, Dst Object
|
Src, Dst Object
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find looks for an Info object for the name passed in
|
// Find looks for an RegInfo object for the name passed in. The name
|
||||||
|
// can be either the Name or the Prefix.
|
||||||
//
|
//
|
||||||
// Services are looked up in the config file
|
// Services are looked up in the config file
|
||||||
func Find(name string) (*RegInfo, error) {
|
func Find(name string) (*RegInfo, error) {
|
||||||
for _, item := range Registry {
|
for _, item := range Registry {
|
||||||
if item.Name == name {
|
if item.Name == name || item.Prefix == name {
|
||||||
return item, nil
|
return item, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, errors.Errorf("didn't find filing system for %q", name)
|
return nil, errors.Errorf("didn't find backend called %q", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustFind looks for an Info object for the type name passed in
|
// MustFind looks for an Info object for the type name passed in
|
||||||
|
|
Loading…
Add table
Reference in a new issue