Skip to content

Commit eab72bb

Browse files
authored
Fixed incorrect diff for num_clusters and min_num_clusters for stopped 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.
1 parent ce7847a commit eab72bb

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

sql/resource_sql_endpoint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ type SQLEndpoint struct {
2525
Name string `json:"name"`
2626
ClusterSize string `json:"cluster_size"`
2727
AutoStopMinutes int `json:"auto_stop_mins" tf:"optional,default:120"`
28-
MinNumClusters int `json:"min_num_clusters,omitempty" tf:"default:1,suppress_diff"`
28+
MinNumClusters int `json:"min_num_clusters,omitempty" tf:"suppress_diff"`
2929
MaxNumClusters int `json:"max_num_clusters,omitempty" tf:"default:1"`
30-
NumClusters int `json:"num_clusters,omitempty" tf:"default:1,suppress_diff"`
30+
NumClusters int `json:"num_clusters,omitempty" tf:"suppress_diff"`
3131
EnablePhoton bool `json:"enable_photon" tf:"optional,default:true"`
3232
EnableServerlessCompute bool `json:"enable_serverless_compute,omitempty" tf:"suppress_diff"`
3333
InstanceProfileARN string `json:"instance_profile_arn,omitempty"`

sql/resource_sql_endpoint_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ func TestResourceSQLEndpointCreate(t *testing.T) {
7777
ClusterSize: "Small",
7878
MaxNumClusters: 1,
7979
AutoStopMinutes: 120,
80-
MinNumClusters: 1,
81-
NumClusters: 1,
8280
EnablePhoton: true,
8381
SpotInstancePolicy: "COST_OPTIMIZED",
8482
},
@@ -97,6 +95,7 @@ func TestResourceSQLEndpointCreate(t *testing.T) {
9795
State: "RUNNING",
9896
Tags: &Tags{},
9997
MaxNumClusters: 1,
98+
NumClusters: 1,
10099
},
101100
},
102101
dataSourceListHTTPFixture,
@@ -124,8 +123,6 @@ func TestResourceSQLEndpointCreateNoAutoTermination(t *testing.T) {
124123
ClusterSize: "Small",
125124
MaxNumClusters: 1,
126125
AutoStopMinutes: 0,
127-
MinNumClusters: 1,
128-
NumClusters: 1,
129126
EnablePhoton: true,
130127
SpotInstancePolicy: "COST_OPTIMIZED",
131128
},
@@ -144,6 +141,7 @@ func TestResourceSQLEndpointCreateNoAutoTermination(t *testing.T) {
144141
State: "RUNNING",
145142
Tags: &Tags{},
146143
MaxNumClusters: 1,
144+
NumClusters: 1,
147145
},
148146
},
149147
dataSourceListHTTPFixture,
@@ -224,8 +222,6 @@ func TestResourceSQLEndpointUpdate(t *testing.T) {
224222
ClusterSize: "Small",
225223
AutoStopMinutes: 120,
226224
MaxNumClusters: 1,
227-
MinNumClusters: 1,
228-
NumClusters: 1,
229225
EnablePhoton: true,
230226
SpotInstancePolicy: "COST_OPTIMIZED",
231227
},
@@ -239,6 +235,7 @@ func TestResourceSQLEndpointUpdate(t *testing.T) {
239235
ClusterSize: "Small",
240236
ID: "abc",
241237
State: "RUNNING",
238+
NumClusters: 1,
242239
},
243240
},
244241
dataSourceListHTTPFixture,

0 commit comments

Comments
 (0)