azureblob: allow emulator account/key override

This commit is contained in:
Roel Arents 2022-11-08 21:24:06 +01:00 committed by GitHub
parent 65528fd009
commit e455940f71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View file

@ -595,7 +595,15 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
) )
switch { switch {
case opt.UseEmulator: case opt.UseEmulator:
credential, err := azblob.NewSharedKeyCredential(emulatorAccount, emulatorAccountKey) var actualEmulatorAccount = emulatorAccount
if opt.Account != "" {
actualEmulatorAccount = opt.Account
}
var actualEmulatorKey = emulatorAccountKey
if opt.Key != "" {
actualEmulatorKey = opt.Key
}
credential, err := azblob.NewSharedKeyCredential(actualEmulatorAccount, actualEmulatorKey)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to parse credentials: %w", err) return nil, fmt.Errorf("failed to parse credentials: %w", err)
} }

View file

@ -164,7 +164,7 @@ Here are the Standard options specific to azureblob (Microsoft Azure Blob Storag
Storage Account Name. Storage Account Name.
Leave blank to use SAS URL or Emulator. Leave blank to use SAS URL.
Properties: Properties:
@ -198,7 +198,7 @@ Properties:
Storage Account Key. Storage Account Key.
Leave blank to use SAS URL or Emulator. Leave blank to use SAS URL.
Properties: Properties:
@ -246,6 +246,8 @@ Uses local storage emulator if provided as 'true'.
Leave blank if using real azure storage endpoint. Leave blank if using real azure storage endpoint.
Provide `account`, `key`, and `endpoint` if desired to override their _azurite_ defaults.
Properties: Properties:
- Config: use_emulator - Config: use_emulator
@ -528,6 +530,6 @@ See [List of backends that do not support rclone about](https://rclone.org/overv
You can run rclone with storage emulator (usually _azurite_). You can run rclone with storage emulator (usually _azurite_).
To do this, just set up a new remote with `rclone config` following instructions described in introduction and set `use_emulator` config as `true`. You do not need to provide default account name neither an account key. To do this, just set up a new remote with `rclone config` following instructions described in introduction and set `use_emulator` config as `true`. You do not need to provide default account name neither an account key. But you can override them in the _account_ and _key_ options. (Prior to v1.61 they were hard coded to _azurite_'s `devstoreaccount1`.)
Also, if you want to access a storage emulator instance running on a different machine, you can override _Endpoint_ parameter in advanced settings, setting it to `http(s)://<host>:<port>/devstoreaccount1` (e.g. `http://10.254.2.5:10000/devstoreaccount1`). Also, if you want to access a storage emulator instance running on a different machine, you can override _Endpoint_ parameter in advanced settings, setting it to `http(s)://<host>:<port>/devstoreaccount1` (e.g. `http://10.254.2.5:10000/devstoreaccount1`).