Skip to content

Commit

Permalink
Skip common error clarity for alternative accounts console deployments (
Browse files Browse the repository at this point in the history
#735)

Provider with `development_mode = true` configuration won't be trying to explain a common error of using AccountAPI on non-accounts hosts. Intended for internal Databricks use only.
  • Loading branch information
nfx committed Jul 21, 2021
1 parent 9da8187 commit ef04352
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type DatabricksClient struct {
AccountID string
AzureAuth AzureAuth
InsecureSkipVerify bool
DevelopmentMode bool
HTTPTimeoutSeconds int
DebugTruncateBytes int
DebugHeaders bool
Expand Down
3 changes: 3 additions & 0 deletions common/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func (c *DatabricksClient) parseUnknownError(
}

func (c *DatabricksClient) commonErrorClarity(resp *http.Response) *APIError {
if c.DevelopmentMode {
return nil
}
isAccountsAPI := strings.HasPrefix(resp.Request.URL.Path, "/api/2.0/accounts")
isAccountsClient := strings.Contains(c.Host, accountsHost)
isTesting := strings.HasPrefix(resp.Request.URL.Host, "127.0.0.1")
Expand Down
10 changes: 10 additions & 0 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ func DatabricksProvider() *schema.Provider {
Optional: true,
Default: false,
},
"development_mode": {
Type: schema.TypeBool,
Description: "Turn off certain error checks. Reserved for internal use only.",
DefaultFunc: schema.EnvDefaultFunc("DATABRICKS_DEV", false),
Optional: true,
Default: false,
},
"debug_truncate_bytes": {
Optional: true,
Type: schema.TypeInt,
Expand Down Expand Up @@ -340,6 +347,9 @@ func configureDatabricksClient(ctx context.Context, d *schema.ResourceData) (int
if v, ok := d.GetOk("skip_verify"); ok {
pc.InsecureSkipVerify = v.(bool)
}
if v, ok := d.GetOk("development_mode"); ok {
pc.DevelopmentMode = v.(bool)
}
if v, ok := d.GetOk("debug_truncate_bytes"); ok {
pc.DebugTruncateBytes = v.(int)
}
Expand Down

0 comments on commit ef04352

Please sign in to comment.