mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
Swift storageUrl overloading fixes #167
This commit is contained in:
parent
08a8f7174a
commit
c2e8f06bfa
@ -56,6 +56,8 @@ Choose a number from below, or type in your own value
|
||||
auth> 1
|
||||
Tenant name - optional
|
||||
tenant>
|
||||
Storage URL - optional
|
||||
storage_url>
|
||||
Remote config
|
||||
--------------------
|
||||
[remote]
|
||||
@ -63,6 +65,7 @@ user = user_name
|
||||
key = password_or_api_key
|
||||
auth = https://auth.api.rackspacecloud.com/v1.0
|
||||
tenant =
|
||||
storage_url =
|
||||
--------------------
|
||||
y) Yes this is OK
|
||||
e) Edit this remote
|
||||
|
30
swift/auth.go
Normal file
30
swift/auth.go
Normal file
@ -0,0 +1,30 @@
|
||||
package swift
|
||||
|
||||
import "github.com/ncw/swift"
|
||||
|
||||
// auth is an authenticator for swift
|
||||
type auth struct {
|
||||
swift.Authenticator
|
||||
storageURL string
|
||||
}
|
||||
|
||||
// newAuth creates a swift authenticator wrapper to override the
|
||||
// StorageUrl method.
|
||||
func newAuth(Authenticator swift.Authenticator, storageURL string) *auth {
|
||||
return &auth{
|
||||
Authenticator: Authenticator,
|
||||
storageURL: storageURL,
|
||||
}
|
||||
}
|
||||
|
||||
// The public storage URL - set Internal to true to read
|
||||
// internal/service net URL
|
||||
func (a *auth) StorageUrl(Internal bool) string {
|
||||
if a.storageURL != "" {
|
||||
return a.storageURL
|
||||
}
|
||||
return a.Authenticator.StorageUrl(Internal)
|
||||
}
|
||||
|
||||
// Check the interfaces are satisfied
|
||||
var _ swift.Authenticator = (*auth)(nil)
|
@ -66,6 +66,9 @@ func init() {
|
||||
}, {
|
||||
Name: "region",
|
||||
Help: "Region name - optional",
|
||||
}, {
|
||||
Name: "storage_url",
|
||||
Help: "Storage URL - optional",
|
||||
},
|
||||
},
|
||||
})
|
||||
@ -176,6 +179,12 @@ func NewFsWithConnection(name, root string, c *swift.Connection) (fs.Fs, error)
|
||||
segmentsContainer: container + "_segments",
|
||||
root: directory,
|
||||
}
|
||||
// StorageURL overloading
|
||||
storageURL := fs.ConfigFile.MustValue(name, "storage_url")
|
||||
if storageURL != "" {
|
||||
f.c.StorageUrl = storageURL
|
||||
f.c.Auth = newAuth(f.c.Auth, storageURL)
|
||||
}
|
||||
if f.root != "" {
|
||||
f.root += "/"
|
||||
// Check to see if the object exists - ignoring directory markers
|
||||
|
Loading…
Reference in New Issue
Block a user