Skip to content

Commit

Permalink
fix(warehouse|bigquery): read operation - inconsistent data collector…
Browse files Browse the repository at this point in the history
… uuid
  • Loading branch information
ndopj committed Oct 4, 2023
1 parent 393bfd7 commit 2c238ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions monte_carlo/client/monte_carlo_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ type GetWarehouse struct {
Uuid string `json:"uuid"`
Type string `json:"type"`
} `json:"connections"`
DataCollector struct {
Uuid string `json:"uuid"`
} `json:"dataCollector"`
} `json:"getWarehouse"`
}

Expand Down
14 changes: 14 additions & 0 deletions monte_carlo/resources/bigquery_warehouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,20 @@ func (r *BigQueryWarehouseResource) Read(ctx context.Context, req resource.ReadR
return
}

readDataCollectorUuid := getResult.GetWarehouse.DataCollector.Uuid
confDataCollectorUuid := data.DataCollectorUuid.ValueString()
if readDataCollectorUuid != confDataCollectorUuid {
resp.Diagnostics.AddError(
fmt.Sprintf("Obtained BigQuery warehouse with [uuid: %s] but its Data Collector UUID does not match with "+
"configured value [obtained: %s, configured: %s]. BigQuery warehouse might have been moved to other "+
"Data Collector externally", data.Uuid.ValueString(), readDataCollectorUuid, confDataCollectorUuid),
"Since its not possible for this provider to update Data Collector of BigQuery warehouse, this resource "+
"cannot continue to function properly. It is recommended to change Data Collector UUID for this "+
"resource directly in the Terraform configuration",
)
return
}

readConnectionUuid := types.StringNull()
readServiceAccountKey := types.StringNull()
for _, connection := range getResult.GetWarehouse.Connections {
Expand Down

0 comments on commit 2c238ff

Please sign in to comment.