Skip to content

Commit

Permalink
Change serviceURL to endpointURL (#1475)
Browse files Browse the repository at this point in the history
  • Loading branch information
guy-har authored Feb 17, 2021
1 parent f2ed086 commit d568689
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions block/azure/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ type Adapter struct {
ctx context.Context
pipeline pipeline.Pipeline
configurations configurations
serviceURL string
endpointURL string
}

type configurations struct {
retryReaderOptions azblob.RetryReaderOptions
}

func NewAdapter(pipeline pipeline.Pipeline, serviceURL string, opts ...func(a *Adapter)) *Adapter {
func NewAdapter(pipeline pipeline.Pipeline, endpointURL string, opts ...func(a *Adapter)) *Adapter {
a := &Adapter{
ctx: context.Background(),
serviceURL: serviceURL,
endpointURL: endpointURL,
pipeline: pipeline,
configurations: configurations{retryReaderOptions: azblob.RetryReaderOptions{MaxRetryRequests: defaultMaxRetryRequests}},
}
Expand All @@ -54,9 +54,9 @@ func NewAdapter(pipeline pipeline.Pipeline, serviceURL string, opts ...func(a *A

func (a *Adapter) WithContext(ctx context.Context) block.Adapter {
return &Adapter{
pipeline: a.pipeline,
serviceURL: a.serviceURL,
ctx: ctx,
pipeline: a.pipeline,
endpointURL: a.endpointURL,
ctx: ctx,
}
}

Expand Down Expand Up @@ -87,7 +87,7 @@ func (a *Adapter) GenerateInventory(ctx context.Context, logger logging.Logger,
}

func (a *Adapter) getContainerURL(containerName string) azblob.ContainerURL {
u, err := url.Parse(fmt.Sprintf("%s/%s", a.serviceURL, containerName))
u, err := url.Parse(fmt.Sprintf("%s/%s", a.endpointURL, containerName))
if err != nil {
panic(err)
}
Expand Down
8 changes: 4 additions & 4 deletions block/factory/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ func buildAzureAdapter(params params.Azure) (*azure.Adapter, error) {
return nil, fmt.Errorf("invalid credentials : %w", err)
}
pipeline := azblob.NewPipeline(credential, azblob.PipelineOptions{Retry: azblob.RetryOptions{TryTimeout: params.TryTimeout}})
serviceURL := params.ServiceURL
endpointURL := params.EndpointURL

if serviceURL == "" {
serviceURL = fmt.Sprintf("https://%s.blob.core.windows.net", accountName)
if endpointURL == "" {
endpointURL = fmt.Sprintf("https://%s.blob.core.windows.net", accountName)
}
return azure.NewAdapter(pipeline, serviceURL), nil
return azure.NewAdapter(pipeline, endpointURL), nil
}
2 changes: 1 addition & 1 deletion block/params/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ type GS struct {
type Azure struct {
StorageAccount string
StorageAccessKey string
ServiceURL string
EndpointURL string
TryTimeout time.Duration
}
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const (
BlockstoreAzureTryTimeoutKey = "blockstore.azure.try_timeout"
BlockstoreAzureStorageAccountKey = "blockstore.azure.storage_account"
BlockstoreAzureStorageAccessKey = "blockstore.azure.storage_access_key"
BlockstoreAzureServiceURL = "blockstore.azure.service_url"
BlockstoreAzureEndpointURLKey = "blockstore.azure.endpoint"
CommittedLocalCacheSizeBytesKey = "committed.local_cache.size_bytes"
CommittedLocalCacheDirKey = "committed.local_cache.dir"
CommittedLocalCacheNumUploadersKey = "committed.local_cache.max_uploaders_per_writer"
Expand Down Expand Up @@ -328,7 +328,7 @@ func (c *Config) GetBlockAdapterAzureParams() (blockparams.Azure, error) {
return blockparams.Azure{
StorageAccount: viper.GetString(BlockstoreAzureStorageAccountKey),
StorageAccessKey: viper.GetString(BlockstoreAzureStorageAccessKey),
ServiceURL: viper.GetString(BlockstoreAzureServiceURL),
EndpointURL: viper.GetString(BlockstoreAzureEndpointURLKey),
TryTimeout: viper.GetDuration(BlockstoreAzureTryTimeoutKey),
}, nil
}
Expand Down

0 comments on commit d568689

Please sign in to comment.