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

Commit 2e1ac14

Browse files
committed
init storage client fixed
1 parent 6c7c7e3 commit 2e1ac14

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

gcore/provider.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,22 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
166166
}))
167167
cdnService := gcdn.NewService(cdnProvider)
168168

169-
stHost, stPath, err := ExtractHostAndPath(storageAPI)
170-
if err != nil {
171-
return nil, diag.FromErr(fmt.Errorf("storage api url: %w", err))
172-
}
173-
174169
config := Config{
175170
Provider: provider,
176171
CDNClient: cdnService,
177-
StorageClient: storageSDK.NewSDK(stHost, stPath,
172+
}
173+
174+
if storageAPI != "" {
175+
stHost, stPath, err := ExtractHostAndPath(storageAPI)
176+
if err != nil {
177+
return nil, diag.FromErr(fmt.Errorf("storage api url: %w", err))
178+
}
179+
config.StorageClient = storageSDK.NewSDK(
180+
stHost,
181+
stPath,
178182
storageSDK.WithBearerAuth(provider.AccessToken),
179-
storageSDK.WithPermanentTokenAuth(func() string { return permanentToken })),
183+
storageSDK.WithPermanentTokenAuth(func() string { return permanentToken }),
184+
)
180185
}
181186

182187
return &config, diags

0 commit comments

Comments
 (0)