Skip to content

Commit e29d6f2

Browse files
committed
Extracted constants
1 parent 88f0864 commit e29d6f2

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

common/client.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ import (
1919
"gopkg.in/ini.v1"
2020
)
2121

22+
// Default settings
23+
const (
24+
DefaultRateLimit = 1200
25+
DebugTruncateBytes = 96
26+
DefaultTimeoutSeconds = 60
27+
)
28+
2229
// DatabricksClient is the client struct that contains clients for all the services available on Databricks
2330
type DatabricksClient struct {
2431
Host string
@@ -45,7 +52,7 @@ func (c *DatabricksClient) Configure() error {
4552
c.configureHTTPCLient()
4653
c.AzureAuth.databricksClient = c
4754
if c.DebugTruncateBytes == 0 {
48-
c.DebugTruncateBytes = 96
55+
c.DebugTruncateBytes = DebugTruncateBytes
4956
}
5057
return nil
5158
}
@@ -179,10 +186,10 @@ func (c *DatabricksClient) encodeBasicAuth(username, password string) string {
179186

180187
func (c *DatabricksClient) configureHTTPCLient() {
181188
if c.TimeoutSeconds == 0 {
182-
c.TimeoutSeconds = 60
189+
c.TimeoutSeconds = DefaultTimeoutSeconds
183190
}
184191
if c.RateLimit == 0 {
185-
c.RateLimit = 1200
192+
c.RateLimit = DefaultRateLimit
186193
}
187194
c.rateLimiter = rate.NewLimiter(rate.Every(1*time.Minute), c.RateLimit)
188195
// Set up a retryable HTTP Client to handle cases where the service returns

provider/provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func DatabricksProvider() *schema.Provider {
204204
Optional: true,
205205
Type: schema.TypeInt,
206206
Description: "Truncate JSON fields in JSON above this limit. Default is 96. Visible only when TF_LOG=DEBUG is set",
207-
DefaultFunc: schema.EnvDefaultFunc("DATABRICKS_DEBUG_TRUNCATE_BYTES", 96),
207+
DefaultFunc: schema.EnvDefaultFunc("DATABRICKS_DEBUG_TRUNCATE_BYTES", common.DebugTruncateBytes),
208208
},
209209
"debug_headers": {
210210
Optional: true,
@@ -216,7 +216,7 @@ func DatabricksProvider() *schema.Provider {
216216
Optional: true,
217217
Type: schema.TypeInt,
218218
Description: "Maximum number of requests per minute made to Databricks REST API by Terraform.",
219-
DefaultFunc: schema.EnvDefaultFunc("DATABRICKS_RATE_LIMIT", 1200),
219+
DefaultFunc: schema.EnvDefaultFunc("DATABRICKS_RATE_LIMIT", common.DefaultRateLimit),
220220
},
221221
},
222222
ConfigureContextFunc: func(c context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {

0 commit comments

Comments
 (0)