Skip to content

Commit dfd6641

Browse files
committed
[PBM-1195] allow custom endpointUrl for Azure storage (#897)
1 parent 91542eb commit dfd6641

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pbm/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ func (s *StorageConf) Path() string {
115115
path += "/" + s.S3.Prefix
116116
}
117117
case storage.Azure:
118-
path = fmt.Sprintf(azure.BlobURL, s.Azure.Account) + "/" + s.Azure.Container
118+
epURL := s.Azure.EndpointURL
119+
if epURL == "" {
120+
epURL = fmt.Sprintf(azure.BlobURL, s.Azure.Account)
121+
}
122+
path = epURL + "/" + s.Azure.Container
119123
if s.Azure.Prefix != "" {
120124
path += "/" + s.Azure.Prefix
121125
}

pbm/storage/azure/azure.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const (
3434
type Conf struct {
3535
Account string `bson:"account" json:"account,omitempty" yaml:"account,omitempty"`
3636
Container string `bson:"container" json:"container,omitempty" yaml:"container,omitempty"`
37+
EndpointURL string `bson:"endpointUrl" json:"endpointUrl,omitempty" yaml:"endpointUrl,omitempty"`
3738
Prefix string `bson:"prefix" json:"prefix,omitempty" yaml:"prefix,omitempty"`
3839
Credentials Credentials `bson:"credentials" json:"-" yaml:"credentials"`
3940
}
@@ -258,7 +259,11 @@ func (b *Blob) client() (*azblob.Client, error) {
258259
opts.Retry = policy.RetryOptions{
259260
MaxRetries: defaultRetries,
260261
}
261-
return azblob.NewClientWithSharedKeyCredential(fmt.Sprintf(BlobURL, b.opts.Account), cred, opts)
262+
epURL := b.opts.EndpointURL
263+
if epURL == "" {
264+
epURL = fmt.Sprintf(BlobURL, b.opts.Account)
265+
}
266+
return azblob.NewClientWithSharedKeyCredential(epURL, cred, opts)
262267
}
263268

264269
func isNotFound(err error) bool {

0 commit comments

Comments
 (0)