diff --git a/common/client.go b/common/client.go index d639be448a..3db30f0a50 100644 --- a/common/client.go +++ b/common/client.go @@ -19,6 +19,13 @@ import ( "gopkg.in/ini.v1" ) +// Default settings +const ( + DefaultRateLimit = 1200 + DebugTruncateBytes = 96 + DefaultTimeoutSeconds = 60 +) + // DatabricksClient is the client struct that contains clients for all the services available on Databricks type DatabricksClient struct { Host string @@ -45,7 +52,7 @@ func (c *DatabricksClient) Configure() error { c.configureHTTPCLient() c.AzureAuth.databricksClient = c if c.DebugTruncateBytes == 0 { - c.DebugTruncateBytes = 96 + c.DebugTruncateBytes = DebugTruncateBytes } return nil } @@ -179,10 +186,10 @@ func (c *DatabricksClient) encodeBasicAuth(username, password string) string { func (c *DatabricksClient) configureHTTPCLient() { if c.TimeoutSeconds == 0 { - c.TimeoutSeconds = 60 + c.TimeoutSeconds = DefaultTimeoutSeconds } if c.RateLimit == 0 { - c.RateLimit = 1200 + c.RateLimit = DefaultRateLimit } c.rateLimiter = rate.NewLimiter(rate.Every(1*time.Minute), c.RateLimit) // Set up a retryable HTTP Client to handle cases where the service returns diff --git a/provider/provider.go b/provider/provider.go index 6c5547dadd..db7acfda65 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -204,7 +204,7 @@ func DatabricksProvider() *schema.Provider { Optional: true, Type: schema.TypeInt, Description: "Truncate JSON fields in JSON above this limit. Default is 96. Visible only when TF_LOG=DEBUG is set", - DefaultFunc: schema.EnvDefaultFunc("DATABRICKS_DEBUG_TRUNCATE_BYTES", 96), + DefaultFunc: schema.EnvDefaultFunc("DATABRICKS_DEBUG_TRUNCATE_BYTES", common.DebugTruncateBytes), }, "debug_headers": { Optional: true, @@ -216,7 +216,7 @@ func DatabricksProvider() *schema.Provider { Optional: true, Type: schema.TypeInt, Description: "Maximum number of requests per minute made to Databricks REST API by Terraform.", - DefaultFunc: schema.EnvDefaultFunc("DATABRICKS_RATE_LIMIT", 1200), + DefaultFunc: schema.EnvDefaultFunc("DATABRICKS_RATE_LIMIT", common.DefaultRateLimit), }, }, ConfigureContextFunc: func(c context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {