Skip to content

Commit 0c3852b

Browse files
authored
fix: add configurable timeout setting for OneLogin provider (#137)
This pull request introduces a new configuration option for setting a timeout in the OneLogin provider. The addition allows users to specify the timeout for API operations, improving flexibility and control over API interactions. ### Enhancements to OneLogin provider configuration: * [`onelogin/provider.go`](diffhunk://#diff-67f9eb98d74e43b0177e4868b4575c740c8fed94dc98974964d3601c3c609b94R42-R47): Added a new `timeout` configuration option to the provider schema. This option allows users to set a timeout in seconds for API operations, with a default value of 60 seconds. The value can also be sourced from the `ONELOGIN_CLIENT_TIMEOUT` environment variable. * [`onelogin/provider.go`](diffhunk://#diff-67f9eb98d74e43b0177e4868b4575c740c8fed94dc98974964d3601c3c609b94L73-R83): Updated the `configProvider` function to retrieve the `timeout` value from the configuration and pass it to the `client.APIClientConfig`. This replaces the previous hardcoded default timeout.
2 parents 8424c4c + 82363fa commit 0c3852b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

onelogin/provider.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ func Provider() *schema.Provider {
3939
Optional: true,
4040
Default: client.USRegion,
4141
},
42+
"timeout": {
43+
Type: schema.TypeInt,
44+
Optional: true,
45+
DefaultFunc: schema.EnvDefaultFunc("ONELOGIN_CLIENT_TIMEOUT", 60),
46+
Description: "Timeout in seconds for API operations. Defaults to 60 seconds if not specified.",
47+
},
4248
},
4349
DataSourcesMap: map[string]*schema.Resource{
4450
"onelogin_user": dataSourceUser(),
@@ -70,10 +76,11 @@ func configProvider(ctx context.Context, d *schema.ResourceData) (interface{}, d
7076
region := d.Get("region").(string)
7177
url := d.Get("url").(string)
7278

73-
timeout := client.DefaultTimeout
79+
// Get timeout from configuration
80+
timeoutSeconds := d.Get("timeout").(int)
7481

7582
oneloginClient, err := client.NewClient(&client.APIClientConfig{
76-
Timeout: timeout,
83+
Timeout: timeoutSeconds,
7784
ClientID: clientID,
7885
ClientSecret: clientSecret,
7986
Region: region,

0 commit comments

Comments
 (0)