feat: sync Add schemas, data quality checks, example usage - #102
feat: sync Add schemas, data quality checks, example usage#102starburstdata-automation wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThis change adds multiple Terraform data sources and resources for catalog metadata, schemas, tables, columns, role grants, usage examples, evaluations, and data quality schedules. It adds generated schemas and documentation, provider registrations, API client operations, Terraform examples, and acceptance tests. Existing resources now expose and populate computed Terraform import identifiers through their 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 17
🧹 Nitpick comments (5)
internal/provider/catalog_metadatas_data_source.go (1)
133-183: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winDiscarded
types.ListValuediagnostics leaveContacts/Tagsas zero-value (null) lists on error.
model.Contacts, _ = ...swallows element-type mismatches; the model field then stays unset and state writes either drop data or fail later with an opaque error. Propagate diags out ofupdateModelFromResponse(returndiag.Diagnosticsand append inRead).internal/provider/data_quality_schedule_resource.go (1)
46-71: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSilent no-op if the generated attribute isn't a
schema.StringAttribute.If the generator ever emits a different attribute type (or a pointer), these overrides are skipped without any signal and
catalog_id/schema_id/table_idquietly stay optional/computed. Consider panicking or emitting an error diagnostic in theelsebranch so a generator drift fails loudly.internal/provider/data_quality_schedule_resource_test.go (1)
59-261: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win~100 duplicated HCL lines between the two config helpers; only
cron_expressiondiffers.Parameterize the cron expression in a single helper.
♻️ Single parameterized helper
-func testAccDataQualityScheduleResourceConfig(suffix string) string { - return fmt.Sprintf(` +func testAccDataQualityScheduleResourceConfig(suffix string) string { + return testAccDataQualityScheduleResourceConfigWithCron(suffix, "0 0 * * *") +} + +func testAccDataQualityScheduleResourceConfigUpdate(suffix string) string { + return testAccDataQualityScheduleResourceConfigWithCron(suffix, "0 6 * * *") +} + +func testAccDataQualityScheduleResourceConfigWithCron(suffix, cron string) string { + return fmt.Sprintf(` ... - cron_expression = "0 0 * * *" + cron_expression = %[2]q ... -`, suffix) +`, suffix, cron) }internal/provider/evaluation_resource.go (1)
120-154: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win
Updatere-reads withGetEvaluationbut never re-triggers the evaluation.If any configurable attribute changes, the resource reports success while nothing changed server-side. If
data_quality_check_idis the only configurable field, addRequiresReplaceto it and makeUpdateunreachable rather than a silent no-op.internal/provider/resource_row_filter/row_filter_resource_gen.go (1)
30-34: 🎯 Functional Correctness | 🔵 TrivialNew generated
idattributes lackUseStateForUnknown, causing needless plan diffs. All five newly-generatedid(Terraform import identifier) attributes areComputed: truewith noPlanModifiers. Per HashiCorp guidance, computed identifiers that don't change after creation should usestringplanmodifier.UseStateForUnknown(); without it, every update to any other attribute on these resources will showid = ... -> (known after apply)even though the id never actually changes.
internal/provider/resource_row_filter/row_filter_resource_gen.go#L30-L34: addPlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}to theidattribute.internal/provider/resource_mysql_catalog/mysql_catalog_resource_gen.go#L50-L54: same fix forid.internal/provider/resource_service_account/service_account_resource_gen.go#L27-L31: same fix forid.internal/provider/resource_snowflake_catalog/snowflake_catalog_resource_gen.go#L57-L61: same fix forid.internal/provider/resource_role_privilege_grant/role_privilege_grant_resource_gen.go#L66-L70: same fix forid.Since these are
_gen.gofiles, the fix should be applied to theterraform-provider-galaxy-generationtemplate/spec rather than hand-edited here.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 7df5ffef-bcd6-4b56-b4e3-9565fb0aae7f
📒 Files selected for processing (125)
docs/data-sources/catalog_metadatas.mddocs/data-sources/columns.mddocs/data-sources/data_quality_schedules.mddocs/data-sources/evaluations.mddocs/data-sources/rolegrants.mddocs/data-sources/schema.mddocs/data-sources/schemas.mddocs/data-sources/table.mddocs/data-sources/tables.mddocs/data-sources/usage_examples.mddocs/resources/bigquery_catalog.mddocs/resources/cassandra_catalog.mddocs/resources/cluster.mddocs/resources/column_mask.mddocs/resources/cross_account_iam_role.mddocs/resources/data_product.mddocs/resources/data_quality_check.mddocs/resources/data_quality_schedule.mddocs/resources/evaluation.mddocs/resources/gcs_catalog.mddocs/resources/mongodb_catalog.mddocs/resources/mysql_catalog.mddocs/resources/opensearch_catalog.mddocs/resources/policy.mddocs/resources/postgresql_catalog.mddocs/resources/redshift_catalog.mddocs/resources/role.mddocs/resources/role_privilege_grant.mddocs/resources/row_filter.mddocs/resources/s3_catalog.mddocs/resources/service_account.mddocs/resources/snowflake_catalog.mddocs/resources/sqlserver_catalog.mddocs/resources/tag.mddocs/resources/usage_example.mdexamples/catalog_metadatas/main.tfexamples/columns/main.tfexamples/data_quality_schedules/main.tfexamples/evaluations/main.tfexamples/rolegrants/main.tfexamples/schemas/main.tfexamples/tables/main.tfexamples/usage_examples/main.tfinternal/client/client.gointernal/provider/bigquery_catalog_resource.gointernal/provider/cassandra_catalog_resource.gointernal/provider/catalog_metadatas_data_source.gointernal/provider/catalog_metadatas_data_source_test.gointernal/provider/cluster_resource.gointernal/provider/column_mask_resource.gointernal/provider/columns_data_source.gointernal/provider/columns_data_source_test.gointernal/provider/cross_account_iam_role_resource.gointernal/provider/data_product_resource.gointernal/provider/data_quality_check_resource.gointernal/provider/data_quality_schedule_resource.gointernal/provider/data_quality_schedule_resource_test.gointernal/provider/data_quality_schedules_data_source.gointernal/provider/data_quality_schedules_data_source_test.gointernal/provider/datasource_catalog_metadatas/catalog_metadatas_data_source_gen.gointernal/provider/datasource_columns/columns_data_source_gen.gointernal/provider/datasource_data_quality_schedules/data_quality_schedules_data_source_gen.gointernal/provider/datasource_evaluations/evaluations_data_source_gen.gointernal/provider/datasource_role_privilege_grants/role_privilege_grants_data_source_gen.gointernal/provider/datasource_rolegrants/rolegrants_data_source_gen.gointernal/provider/datasource_schema/schema_data_source_gen.gointernal/provider/datasource_schemas/schemas_data_source_gen.gointernal/provider/datasource_table/table_data_source_gen.gointernal/provider/datasource_tables/tables_data_source_gen.gointernal/provider/datasource_usage_examples/usage_examples_data_source_gen.gointernal/provider/evaluation_resource.gointernal/provider/evaluation_resource_test.gointernal/provider/evaluations_data_source.gointernal/provider/evaluations_data_source_test.gointernal/provider/gcs_catalog_resource.gointernal/provider/mongodb_catalog_resource.gointernal/provider/mysql_catalog_resource.gointernal/provider/opensearch_catalog_resource.gointernal/provider/policy_resource.gointernal/provider/postgresql_catalog_resource.gointernal/provider/provider.gointernal/provider/redshift_catalog_resource.gointernal/provider/resource_bigquery_catalog/bigquery_catalog_resource_gen.gointernal/provider/resource_cassandra_catalog/cassandra_catalog_resource_gen.gointernal/provider/resource_cluster/cluster_resource_gen.gointernal/provider/resource_column_mask/column_mask_resource_gen.gointernal/provider/resource_cross_account_iam_role/cross_account_iam_role_resource_gen.gointernal/provider/resource_data_product/data_product_resource_gen.gointernal/provider/resource_data_quality_check/data_quality_check_resource_gen.gointernal/provider/resource_data_quality_schedule/data_quality_schedule_resource_gen.gointernal/provider/resource_evaluation/evaluation_resource_gen.gointernal/provider/resource_gcs_catalog/gcs_catalog_resource_gen.gointernal/provider/resource_mongodb_catalog/mongodb_catalog_resource_gen.gointernal/provider/resource_mysql_catalog/mysql_catalog_resource_gen.gointernal/provider/resource_opensearch_catalog/opensearch_catalog_resource_gen.gointernal/provider/resource_policy/policy_resource_gen.gointernal/provider/resource_postgresql_catalog/postgresql_catalog_resource_gen.gointernal/provider/resource_redshift_catalog/redshift_catalog_resource_gen.gointernal/provider/resource_role/role_resource_gen.gointernal/provider/resource_role_privilege_grant/role_privilege_grant_resource_gen.gointernal/provider/resource_row_filter/row_filter_resource_gen.gointernal/provider/resource_s3_catalog/s3_catalog_resource_gen.gointernal/provider/resource_service_account/service_account_resource_gen.gointernal/provider/resource_snowflake_catalog/snowflake_catalog_resource_gen.gointernal/provider/resource_sqlserver_catalog/sqlserver_catalog_resource_gen.gointernal/provider/resource_tag/tag_resource_gen.gointernal/provider/resource_usage_example/usage_example_resource_gen.gointernal/provider/role_privilege_grant_resource.gointernal/provider/role_resource.gointernal/provider/rolegrants_data_source.gointernal/provider/rolegrants_data_source_test.gointernal/provider/row_filter_resource.gointernal/provider/s3_catalog_resource.gointernal/provider/schemas_data_source.gointernal/provider/schemas_data_source_test.gointernal/provider/service_account_resource.gointernal/provider/snowflake_catalog_resource.gointernal/provider/sqlserver_catalog_resource.gointernal/provider/tables_data_source.gointernal/provider/tables_data_source_test.gointernal/provider/tag_resource.gointernal/provider/usage_example_resource.gointernal/provider/usage_example_resource_test.gointernal/provider/usage_examples_data_source.gointernal/provider/usage_examples_data_source_test.go
| ### Read-Only | ||
|
|
||
| - `data_quality_check_id` (String) Data Quality check ID (read only) | ||
| - `id` (String) Terraform import identifier. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
id is documented as the import identifier, but this doc has no Import section.
Sibling resource docs (bigquery_catalog.md, cluster.md, data_product.md, etc.) all render an ## Import section after Read-Only. Here the file ends right after id, which suggests the import example template (examples/resources/galaxy_data_quality_check/import.sh) is missing upstream in the generation repo. Worth confirming whether import is actually supported for this resource.
#!/bin/bash
fd -H -t f . examples --exec echo {} | rg -n 'data_quality_check|import'
rg -n 'ImportState' internal/provider/data_quality_check_resource.go| - `catalog_id` (String) - A catalog | ||
| - This parameter can be looked up using `name` instead of its Id. Use `name=value` instead of an Id to lookup/search using the `value`. `value` must be encoded ([see RFC](https://www.rfc-editor.org/rfc/rfc3986#section-2.2) including `=`) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Lookup-capable ID descriptions start with a - bullet, producing phantom attribute bullets in generated docs. The shared root cause is the upstream description text for lookup-by-name parameters (- A catalog\n- This parameter can be looked up ...), which tfplugindocs renders as sibling list items alongside real attributes.
docs/resources/data_quality_schedule.md#L20-L21: regenerate after reshaping thecatalog_iddescription so the continuation text is not a top-level bullet (plain lead-in sentence, or indented sub-bullet).internal/provider/datasource_role_privilege_grants/role_privilege_grants_data_source_gen.go#L83-L84: apply the same description reshaping torole_idin the generation repo, since this generated string is what the docs render.
🧰 Tools
🪛 LanguageTool
[grammar] ~21-~21: Ensure spelling is correct
Context: ...d. Use name=value instead of an Id to lookup/search using the value. value must ...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
📍 Affects 2 files
docs/resources/data_quality_schedule.md#L20-L21(this comment)internal/provider/datasource_role_privilege_grants/role_privilege_grants_data_source_gen.go#L83-L84
| # List columns for a specific table in the catalog | ||
| data "galaxy_columns" "example" { | ||
| catalog_id = galaxy_postgresql_catalog.example.catalog_id | ||
| schema_id = "anu_test" | ||
| table_id = "employees" | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Remove the undeclared anu_test.employees fixture dependency.
Both examples create a catalog but assume that a particular schema and table already exist in the connected external database. They fail for normal users unless that hidden fixture has been pre-created.
examples/columns/main.tf#L53-L58: replace the fixed schema/table values with documented required inputs for an existing table.examples/data_quality_schedules/main.tf#L96-L125: use the same configurable existing-table inputs consistently in the check, schedule, list data source, and SQL query.
📍 Affects 2 files
examples/columns/main.tf#L53-L58(this comment)examples/data_quality_schedules/main.tf#L96-L125
| output "schedule_id" { | ||
| value = try(data.galaxy_data_quality_schedules.example.data_quality_schedule_id, "none") | ||
| } | ||
|
|
||
| output "schedule_enabled" { | ||
| value = try(data.galaxy_data_quality_schedules.example.enabled, false) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Read attributes from the multi-item result list.
galaxy_data_quality_schedules is registered as a multi-item data source, so these top-level attributes are not available. This example fails validation instead of reading the created schedule.
Proposed fix
output "schedule_id" {
- value = try(data.galaxy_data_quality_schedules.example.data_quality_schedule_id, "none")
+ value = try(data.galaxy_data_quality_schedules.example.result[0].data_quality_schedule_id, "none")
}
output "schedule_enabled" {
- value = try(data.galaxy_data_quality_schedules.example.enabled, false)
+ value = try(data.galaxy_data_quality_schedules.example.result[0].enabled, false)
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| output "schedule_id" { | |
| value = try(data.galaxy_data_quality_schedules.example.data_quality_schedule_id, "none") | |
| } | |
| output "schedule_enabled" { | |
| value = try(data.galaxy_data_quality_schedules.example.enabled, false) | |
| } | |
| output "schedule_id" { | |
| value = try(data.galaxy_data_quality_schedules.example.result[0].data_quality_schedule_id, "none") | |
| } | |
| output "schedule_enabled" { | |
| value = try(data.galaxy_data_quality_schedules.example.result[0].enabled, false) | |
| } |
| locals { | ||
| test_suffix = var.test_suffix != "" ? var.test_suffix : substr(replace(uuid(), "[^0-9]", ""), 0, 6) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map the Terraform file and inspect relevant lines
git ls-files examples/evaluations/main.tf
wc -l examples/evaluations/main.tf
cat -n examples/evaluations/main.tf | sed -n '1,220p'
# Find all references to test_suffix and uuid/replace in the repo
rg -n --hidden --glob '!**/.git/**' 'test_suffix|uuid\(|replace\(' .Repository: starburstdata/terraform-provider-galaxy
Length of output: 1967
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== examples/evaluations/main.tf =="
cat -n examples/evaluations/main.tf | sed -n '1,220p'
echo
echo "== references to test_suffix/uuid/replace =="
rg -n --hidden --glob '!**/.git/**' 'test_suffix|uuid\(|replace\(' examples .Repository: starburstdata/terraform-provider-galaxy
Length of output: 1967
🌐 Web query:
Terraform replace function regex slash-delimited uuid function non-deterministic random_id resource docs
💡 Result:
In Terraform, the replace function and random_id resource serve distinct purposes. The replace function performs string replacement using either literal strings or regular expressions [1][2]. To use a regular expression, you must wrap the substring argument in forward slashes (e.g., replace(string, "/pattern/", "replacement")) [1][3]. Terraform uses the same regular expression syntax as the regex function [3][4]. Because slash-delimited strings are interpreted as regex, you cannot use a literal slash sequence as a search pattern without it being evaluated as a regex pattern [5]. The random_id resource is used to generate random identifiers and is not strictly non-deterministic in its operation [6][7]. While it uses a cryptographic random number generator to create values, these values are managed by Terraform’s state [6][7]. Once generated, the random value is stored in the Terraform state and remains unchanged across subsequent plan and apply operations unless the resource inputs (such as the keepers map or byte_length) are modified [7]. When inputs change, the resource is recreated, and a new random value is generated [7]. It is frequently used for generating unique identifiers, such as 16-byte values that offer the same uniqueness profile as a type-4 UUID [6][8]. For projects specifically requiring UUID formats, the random provider also offers a dedicated random_uuid resource [9].
Citations:
- 1: https://developer.hashicorp.com/terraform/language/functions/replace
- 2: https://docs.hashicorp.com/terraform/language/functions/replace
- 3: https://build5nines.com/using-terraform-string-replace-function-for-regex-string-replacement/
- 4: https://developer.hashicorp.com/terraform/language/functions/regex
- 5: https://groups.google.com/g/terraform-tool/c/I87q2ovYEbY
- 6: https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id
- 7: https://registry.terraform.io/providers/hashicorp/random/latest/docs
- 8: https://registry.terraform.io/providers/hashicorp/random/3.8.0/docs/resources/id
- 9: https://github.com/terraform-providers/terraform-provider-random
Use a stable fallback suffix. uuid() changes on every run, so this fallback makes generated names unstable. replace(uuid(), "[^0-9]", "") also does not strip non-digits here because the pattern is treated as a literal string, not a regex. Use a stateful random_id value or require test_suffix instead.
| ConfigStateChecks: []statecheck.StateCheck{ | ||
| statecheck.ExpectKnownValue( | ||
| "data.galaxy_data_quality_schedules.test", | ||
| tfjsonpath.New("catalog_id"), | ||
| knownvalue.NotNull(), | ||
| ), | ||
| statecheck.ExpectKnownValue( | ||
| "data.galaxy_data_quality_schedules.test", | ||
| tfjsonpath.New("data_quality_checks"), | ||
| knownvalue.NotNull(), | ||
| ), | ||
| }, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert returned collection contents, not merely non-null values.
knownvalue.NotNull() also passes for empty collections, so these acceptance tests can succeed while the data sources return no records.
internal/provider/data_quality_schedules_data_source_test.go#L30-L41: assert thatdata_quality_checkscontains at least one returned item from the configured catalog/schema/table.internal/provider/tables_data_source_test.go#L25-L31: assert thatresultcontains at least one table fromanu_test.internal/provider/schemas_data_source_test.go#L25-L31: assert thatresultcontains at least one schema.
📍 Affects 3 files
internal/provider/data_quality_schedules_data_source_test.go#L30-L41(this comment)internal/provider/tables_data_source_test.go#L25-L31internal/provider/schemas_data_source_test.go#L25-L31
| Description: "- A catalog\n- This parameter can be looked up using `name` instead of its Id. Use `name=value` instead of an Id to lookup/search using the `value`. `value` must be encoded ([see RFC](https://www.rfc-editor.org/rfc/rfc3986#section-2.2) including `=`)\n", | ||
| MarkdownDescription: "- A catalog\n- This parameter can be looked up using `name` instead of its Id. Use `name=value` instead of an Id to lookup/search using the `value`. `value` must be encoded ([see RFC](https://www.rfc-editor.org/rfc/rfc3986#section-2.2) including `=`)\n", |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Lookup-parameter descriptions start with - , producing a detached bullet on every generated doc page. The shared root cause is the spec description text for the catalog_id/role_id lookup parameters, which begins with a Markdown list marker; tfplugindocs then emits the "This parameter can be looked up using name…" sentence as a separate top-level list item with no attribute association.
internal/provider/datasource_schemas/schemas_data_source_gen.go#L23-L24: fix thecatalog_idDescription/MarkdownDescriptionin the generator source spec (drop the leading-, or indent the second line as a continuation) and regenerate.docs/data-sources/catalog_metadatas.md#L20-L21: regenerate after the spec fix socatalog_idrenders as a single entry.docs/data-sources/columns.md#L20-L21: regenerate after the spec fix.docs/data-sources/data_quality_schedules.md#L20-L21: regenerate after the spec fix.docs/data-sources/rolegrants.md#L20-L21: apply the same spec fix to therole_iddescription and regenerate.docs/data-sources/schemas.md#L20-L21: regenerate after the spec fix.docs/data-sources/tables.md#L20-L21: regenerate after the spec fix.
📍 Affects 7 files
internal/provider/datasource_schemas/schemas_data_source_gen.go#L23-L24(this comment)docs/data-sources/catalog_metadatas.md#L20-L21docs/data-sources/columns.md#L20-L21docs/data-sources/data_quality_schedules.md#L20-L21docs/data-sources/rolegrants.md#L20-L21docs/data-sources/schemas.md#L20-L21docs/data-sources/tables.md#L20-L21
Source: Linters/SAST tools
| resource "galaxy_role" "dq_check_grant" { | ||
| role_name = "evrsrcgrant%[1]s" | ||
| role_description = "Role granting query access to the evaluation resource test catalog" | ||
| grant_to_creating_role = true | ||
| } | ||
|
|
||
| resource "galaxy_role_privilege_grant" "dq_check_grant" { | ||
| role_id = galaxy_role.dq_check_grant.role_id | ||
| entity_id = galaxy_postgresql_catalog.test.catalog_id | ||
| entity_kind = "Column" | ||
| privilege = "Select" | ||
| grant_kind = "Allow" | ||
| grant_option = false | ||
| schema_name = "*" | ||
| table_name = "*" | ||
| column_name = "*" | ||
| } | ||
|
|
||
| resource "galaxy_data_quality_check" "test" { | ||
| name = "evrcheck_%[1]s" | ||
| description = "Data quality check for evaluation resource test" | ||
| catalog_id = galaxy_postgresql_catalog.test.catalog_id | ||
| schema_id = "anu_test" | ||
| table_id = "employees" | ||
| severity = "Low" | ||
| category = "Completeness" | ||
| kind = "SqlQuery" | ||
| cluster_id = galaxy_cluster.test.cluster_id | ||
| query = "select exists(select * from ${galaxy_postgresql_catalog.test.name}.anu_test.employees)" | ||
| depends_on = [galaxy_role_privilege_grant.dq_check_grant] | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Missing UseCluster grant will likely make this config fail with 403 PERMISSION_DENIED.
The schedule test in this same PR documents that galaxy_data_quality_check validates USE_CLUSTER on cluster_id for role_id independently, and adds a dedicated galaxy_role_privilege_grant (entity_kind = "Cluster", privilege = "UseCluster"). This config omits it.
🛠️ Add the cluster grant
+resource "galaxy_role_privilege_grant" "dq_check_use_cluster" {
+ role_id = galaxy_role.dq_check_grant.role_id
+ entity_id = galaxy_cluster.test.cluster_id
+ entity_kind = "Cluster"
+ privilege = "UseCluster"
+ grant_kind = "Allow"
+ grant_option = false
+}
+
resource "galaxy_data_quality_check" "test" {
...
- depends_on = [galaxy_role_privilege_grant.dq_check_grant]
+ depends_on = [galaxy_role_privilege_grant.dq_check_grant, galaxy_role_privilege_grant.dq_check_use_cluster]
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| resource "galaxy_role" "dq_check_grant" { | |
| role_name = "evrsrcgrant%[1]s" | |
| role_description = "Role granting query access to the evaluation resource test catalog" | |
| grant_to_creating_role = true | |
| } | |
| resource "galaxy_role_privilege_grant" "dq_check_grant" { | |
| role_id = galaxy_role.dq_check_grant.role_id | |
| entity_id = galaxy_postgresql_catalog.test.catalog_id | |
| entity_kind = "Column" | |
| privilege = "Select" | |
| grant_kind = "Allow" | |
| grant_option = false | |
| schema_name = "*" | |
| table_name = "*" | |
| column_name = "*" | |
| } | |
| resource "galaxy_data_quality_check" "test" { | |
| name = "evrcheck_%[1]s" | |
| description = "Data quality check for evaluation resource test" | |
| catalog_id = galaxy_postgresql_catalog.test.catalog_id | |
| schema_id = "anu_test" | |
| table_id = "employees" | |
| severity = "Low" | |
| category = "Completeness" | |
| kind = "SqlQuery" | |
| cluster_id = galaxy_cluster.test.cluster_id | |
| query = "select exists(select * from ${galaxy_postgresql_catalog.test.name}.anu_test.employees)" | |
| depends_on = [galaxy_role_privilege_grant.dq_check_grant] | |
| } | |
| resource "galaxy_role" "dq_check_grant" { | |
| role_name = "evrsrcgrant%[1]s" | |
| role_description = "Role granting query access to the evaluation resource test catalog" | |
| grant_to_creating_role = true | |
| } | |
| resource "galaxy_role_privilege_grant" "dq_check_grant" { | |
| role_id = galaxy_role.dq_check_grant.role_id | |
| entity_id = galaxy_postgresql_catalog.test.catalog_id | |
| entity_kind = "Column" | |
| privilege = "Select" | |
| grant_kind = "Allow" | |
| grant_option = false | |
| schema_name = "*" | |
| table_name = "*" | |
| column_name = "*" | |
| } | |
| resource "galaxy_role_privilege_grant" "dq_check_use_cluster" { | |
| role_id = galaxy_role.dq_check_grant.role_id | |
| entity_id = galaxy_cluster.test.cluster_id | |
| entity_kind = "Cluster" | |
| privilege = "UseCluster" | |
| grant_kind = "Allow" | |
| grant_option = false | |
| } | |
| resource "galaxy_data_quality_check" "test" { | |
| name = "evrcheck_%[1]s" | |
| description = "Data quality check for evaluation resource test" | |
| catalog_id = galaxy_postgresql_catalog.test.catalog_id | |
| schema_id = "anu_test" | |
| table_id = "employees" | |
| severity = "Low" | |
| category = "Completeness" | |
| kind = "SqlQuery" | |
| cluster_id = galaxy_cluster.test.cluster_id | |
| query = "select exists(select * from ${galaxy_postgresql_catalog.test.name}.anu_test.employees)" | |
| depends_on = [galaxy_role_privilege_grant.dq_check_grant, galaxy_role_privilege_grant.dq_check_use_cluster] | |
| } |
| func (r *evaluationResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { | ||
| var plan resource_evaluation.EvaluationModel | ||
|
|
||
| resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) | ||
| if resp.Diagnostics.HasError() { | ||
| return | ||
| } | ||
|
|
||
| checkID := plan.DataQualityCheckId.ValueString() | ||
|
|
||
| tflog.Debug(ctx, "Creating evaluation", map[string]interface{}{"data_quality_check_id": checkID}) | ||
| response, err := r.client.CreateEvaluation(ctx, checkID) | ||
| if err != nil { | ||
| resp.Diagnostics.AddError( | ||
| "Error creating evaluation", | ||
| "Could not create evaluation: "+err.Error(), | ||
| ) | ||
| return | ||
| } | ||
|
|
||
| r.updateModelFromResponse(ctx, &plan, response) | ||
|
|
||
| tflog.Debug(ctx, "Created evaluation", map[string]interface{}{"id": plan.Id.ValueString()}) | ||
| resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
id stays unknown if the create response omits dataQualityCheckId, failing the apply.
model.Id is only set inside the if at Line 161. When the POST response doesn't echo dataQualityCheckId, Terraform errors with "provider produced inconsistent result after apply" because a computed attribute remained unknown. Seed from the planned check ID.
🛠️ Fallback to the known check ID
r.updateModelFromResponse(ctx, &plan, response)
+ if plan.Id.IsNull() || plan.Id.IsUnknown() {
+ plan.DataQualityCheckId = types.StringValue(checkID)
+ plan.Id = types.StringValue(checkID)
+ }Also applies to: 160-164
| func (r *usageExampleResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { | ||
| resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Populate the identifiers required by Read during import.
ImportStatePassthroughID sets only id, but Read ignores state.Id and calls GetUsageExample with data_product_id and usage_example_id. Imports therefore cannot be read successfully. Parse a documented composite import ID and set both attributes, then add an import acceptance test.
Automated sync from terraform-provider-galaxy-generation repository.
Source commit: 83149f196d38833d3b1a94303b74bec4e015cbe3
This PR contains the latest generated provider code from the generation repository.