-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added databricks_sql_warehouses
, databricks_sql_warehouse
, and databricks_cluster
data resources
#1460
Conversation
For cluster and warehouse it would be nice to search by name |
clusters/clusters_api.go
Outdated
DefaultTags map[string]string `json:"default_tags,omitempty" tf:"computed"` | ||
ClusterLogStatus *LogSyncStatus `json:"cluster_log_status,omitempty" tf:"computed"` | ||
TerminationReason *TerminationReason `json:"termination_reason,omitempty" tf:"computed"` | ||
DataSecurityMode string `json:"data_security_mode,omitempty" tf:"computed"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create new type for cluster data resource and probably just expose cluster info as a field. this is the least intrusive change.
clusters/data_cluster.go
Outdated
) | ||
|
||
func DataSourceCluster() *schema.Resource { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove blank line
for_each = data.databricks_sql.warehouses.ids | ||
id = each.value | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run terrafmt on that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is formatted (I think)
return err | ||
} | ||
endpointsAPI := NewSQLEndpointsAPI(ctx, c) | ||
data.DataSourceID, err = endpointsAPI.ResolveDataSourceID(data.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to resolve a data resource if we have DataSourceID
already? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataSourceID comes from a different API
func DataSourceWarehouses() *schema.Resource { | ||
type warehousesData struct { | ||
WarehouseNameContains string `json:"warehouse_name_contains,omitempty"` | ||
Ids []string `json:"ids,omitempty" tf:"computed,slice_set"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also expose name-to-id mapping?..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the best way to represent that? a map[string]string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
@alexott I would use the warehouses/clusters data sources to search by name, and then use for_each to get attributes for individual compute based on the ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can merge it if you'll create two follow-up issues:
- adding integration tests for all these data resources
- adding name-to-id mapping for warehouses
- adding lookup of cluster by name
Codecov Report
@@ Coverage Diff @@
## master #1460 +/- ##
==========================================
- Coverage 90.12% 90.11% -0.02%
==========================================
Files 126 129 +3
Lines 10216 10274 +58
==========================================
+ Hits 9207 9258 +51
- Misses 642 648 +6
- Partials 367 368 +1
|
databricks_sql_warehouses
, databricks_sql_warehouse
, and databricks_cluster
data resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…atabricks_cluster` data resources (databricks#1460) Follow-ups: databricks#1480 and databricks#1481
Add 3 new data sources:
databricks_sql_warehouses
(list all warehouses in a workspace, with a name filter),databricks_sql_warehouse
anddatabricks_cluster
(list attributes based on single id)Close #1270, close #1456