Skip to content

Commit

Permalink
[PBM-1195] allow custom endpointUrl for Azure storage (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
defbin authored Nov 27, 2023
1 parent 66b7af3 commit 40f15c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pbm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ func (s *StorageConf) Path() string {
path += "/" + s.S3.Prefix
}
case storage.Azure:
path = fmt.Sprintf(azure.BlobURL, s.Azure.Account) + "/" + s.Azure.Container
epURL := s.Azure.EndpointURL
if epURL == "" {
epURL = fmt.Sprintf(azure.BlobURL, s.Azure.Account)
}
path = epURL + "/" + s.Azure.Container
if s.Azure.Prefix != "" {
path += "/" + s.Azure.Prefix
}
Expand Down
7 changes: 6 additions & 1 deletion pbm/storage/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
type Conf struct {
Account string `bson:"account" json:"account,omitempty" yaml:"account,omitempty"`
Container string `bson:"container" json:"container,omitempty" yaml:"container,omitempty"`
EndpointURL string `bson:"endpointUrl" json:"endpointUrl,omitempty" yaml:"endpointUrl,omitempty"`
Prefix string `bson:"prefix" json:"prefix,omitempty" yaml:"prefix,omitempty"`
Credentials Credentials `bson:"credentials" json:"-" yaml:"credentials"`
}
Expand Down Expand Up @@ -258,7 +259,11 @@ func (b *Blob) client() (*azblob.Client, error) {
opts.Retry = policy.RetryOptions{
MaxRetries: defaultRetries,
}
return azblob.NewClientWithSharedKeyCredential(fmt.Sprintf(BlobURL, b.opts.Account), cred, opts)
epURL := b.opts.EndpointURL
if epURL == "" {
epURL = fmt.Sprintf(BlobURL, b.opts.Account)
}
return azblob.NewClientWithSharedKeyCredential(epURL, cred, opts)
}

func isNotFound(err error) bool {
Expand Down

0 comments on commit 40f15c8

Please sign in to comment.