Skip to content

Commit

Permalink
Fixed incorrect diff for num_clusters and min_num_clusters for st…
Browse files Browse the repository at this point in the history
…opped `databricks_sql_endpoint` (#1927)

Correctly suppress diff for `num_clusters` on warehouses that are not running, in case `num_clusters` is not specified.

Note for contributors: `tf:"suppress_diff"` and `tf:"default"` don't work well together.
  • Loading branch information
nfx committed Jan 16, 2023
1 parent ce7847a commit eab72bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions sql/resource_sql_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ type SQLEndpoint struct {
Name string `json:"name"`
ClusterSize string `json:"cluster_size"`
AutoStopMinutes int `json:"auto_stop_mins" tf:"optional,default:120"`
MinNumClusters int `json:"min_num_clusters,omitempty" tf:"default:1,suppress_diff"`
MinNumClusters int `json:"min_num_clusters,omitempty" tf:"suppress_diff"`
MaxNumClusters int `json:"max_num_clusters,omitempty" tf:"default:1"`
NumClusters int `json:"num_clusters,omitempty" tf:"default:1,suppress_diff"`
NumClusters int `json:"num_clusters,omitempty" tf:"suppress_diff"`
EnablePhoton bool `json:"enable_photon" tf:"optional,default:true"`
EnableServerlessCompute bool `json:"enable_serverless_compute,omitempty" tf:"suppress_diff"`
InstanceProfileARN string `json:"instance_profile_arn,omitempty"`
Expand Down
9 changes: 3 additions & 6 deletions sql/resource_sql_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ func TestResourceSQLEndpointCreate(t *testing.T) {
ClusterSize: "Small",
MaxNumClusters: 1,
AutoStopMinutes: 120,
MinNumClusters: 1,
NumClusters: 1,
EnablePhoton: true,
SpotInstancePolicy: "COST_OPTIMIZED",
},
Expand All @@ -97,6 +95,7 @@ func TestResourceSQLEndpointCreate(t *testing.T) {
State: "RUNNING",
Tags: &Tags{},
MaxNumClusters: 1,
NumClusters: 1,
},
},
dataSourceListHTTPFixture,
Expand Down Expand Up @@ -124,8 +123,6 @@ func TestResourceSQLEndpointCreateNoAutoTermination(t *testing.T) {
ClusterSize: "Small",
MaxNumClusters: 1,
AutoStopMinutes: 0,
MinNumClusters: 1,
NumClusters: 1,
EnablePhoton: true,
SpotInstancePolicy: "COST_OPTIMIZED",
},
Expand All @@ -144,6 +141,7 @@ func TestResourceSQLEndpointCreateNoAutoTermination(t *testing.T) {
State: "RUNNING",
Tags: &Tags{},
MaxNumClusters: 1,
NumClusters: 1,
},
},
dataSourceListHTTPFixture,
Expand Down Expand Up @@ -224,8 +222,6 @@ func TestResourceSQLEndpointUpdate(t *testing.T) {
ClusterSize: "Small",
AutoStopMinutes: 120,
MaxNumClusters: 1,
MinNumClusters: 1,
NumClusters: 1,
EnablePhoton: true,
SpotInstancePolicy: "COST_OPTIMIZED",
},
Expand All @@ -239,6 +235,7 @@ func TestResourceSQLEndpointUpdate(t *testing.T) {
ClusterSize: "Small",
ID: "abc",
State: "RUNNING",
NumClusters: 1,
},
},
dataSourceListHTTPFixture,
Expand Down

0 comments on commit eab72bb

Please sign in to comment.