Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
init storage client fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
0ndi committed Jun 11, 2021
1 parent 6c7c7e3 commit 2e1ac14
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions gcore/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,22 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
}))
cdnService := gcdn.NewService(cdnProvider)

stHost, stPath, err := ExtractHostAndPath(storageAPI)
if err != nil {
return nil, diag.FromErr(fmt.Errorf("storage api url: %w", err))
}

config := Config{
Provider: provider,
CDNClient: cdnService,
StorageClient: storageSDK.NewSDK(stHost, stPath,
}

if storageAPI != "" {
stHost, stPath, err := ExtractHostAndPath(storageAPI)
if err != nil {
return nil, diag.FromErr(fmt.Errorf("storage api url: %w", err))
}
config.StorageClient = storageSDK.NewSDK(
stHost,
stPath,
storageSDK.WithBearerAuth(provider.AccessToken),
storageSDK.WithPermanentTokenAuth(func() string { return permanentToken })),
storageSDK.WithPermanentTokenAuth(func() string { return permanentToken }),
)
}

return &config, diags
Expand Down

0 comments on commit 2e1ac14

Please sign in to comment.