Skip to content

feat: sync add UseStateForUnknown to computed ID/timestamp fields provider-wide - #96

Merged
bradyburke merged 1 commit into
mainfrom
auto-sync-2026-07-09-00934ba
Jul 10, 2026
Merged

feat: sync add UseStateForUnknown to computed ID/timestamp fields provider-wide#96
bradyburke merged 1 commit into
mainfrom
auto-sync-2026-07-09-00934ba

Conversation

@starburstdata-automation

Copy link
Copy Markdown
Collaborator

Automated sync from terraform-provider-galaxy-generation repository.

Source commit: 00934baee3ceaa163bdde028a6efd5f4e3f6ab57

This PR contains the latest generated provider code from the generation repository.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Resource schemas across catalog, access-control, masking, filtering, service-account, cluster, and tag resources now apply Terraform UseStateForUnknown() string plan modifiers. Catalog identifiers and API-assigned fields retain prior state when planned values are unknown during updates. Several resources now post-process their generated base schemas before assigning them to the response.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the provider-wide UseStateForUnknown schema updates to computed ID and timestamp fields.
Description check ✅ Passed The description is related to the changeset and correctly states that this is an automated sync from the generation repository.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
internal/provider/bigquery_catalog_resource.go (1)

55-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting a helper for the repeated UseStateForUnknown pattern.

The same ~10-line block (type-assert → set PlanModifiers → write back) is duplicated across 11+ catalog resource files and several non-catalog resources. A small helper would reduce maintenance burden and prevent divergence.

♻️ Proposed helper extraction
// applyUseStateForUnknown adds a UseStateForUnknown plan modifier to a string attribute
// in the schema. No-op if the attribute is missing or not a StringAttribute.
func applyUseStateForUnknown(s *schema.Schema, attrName string) {
	if attr, ok := s.Attributes[attrName].(schema.StringAttribute); ok {
		attr.PlanModifiers = append(attr.PlanModifiers, stringplanmodifier.UseStateForUnknown())
		s.Attributes[attrName] = attr
	}
}

Then each call site simplifies to:

-	// catalog_id is assigned at creation and never changes. Without UseStateForUnknown, any update
-	// to the catalog causes Terraform to mark catalog_id as "known after apply", which propagates to
-	// downstream resources referencing it (e.g. galaxy_role_privilege_grant.entity_id) and forces
-	// unnecessary destroy/recreate cycles.
-	if attr, ok := s.Attributes["catalog_id"].(schema.StringAttribute); ok {
-		attr.PlanModifiers = []planmodifier.String{
-			stringplanmodifier.UseStateForUnknown(),
-		}
-		s.Attributes["catalog_id"] = attr
-	}
+	// catalog_id is assigned at creation and never changes. UseStateForUnknown prevents
+	// "known after apply" propagation to downstream resources (e.g. galaxy_role_privilege_grant.entity_id).
+	applyUseStateForUnknown(&s, "catalog_id")
internal/provider/gcs_catalog_resource.go (1)

57-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Repeated attach-modifier boilerplate across ~20 files.

The if attr, ok := s.Attributes[...].(schema.StringAttribute); ok { ... } block is duplicated verbatim in every catalog and non-catalog resource file in this PR stack. Since this repo is synced from terraform-provider-galaxy-generation, a shared helper (e.g. applyUseStateForUnknown(attrs map[string]schema.Attribute, name string)) would reduce duplication, but should be introduced upstream in the generator to survive the next sync rather than patched only here.

internal/provider/mysql_catalog_resource.go (1)

57-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting a shared helper for the UseStateForUnknown plan modifier block.

This identical 10-line block is duplicated across 11+ catalog resource files. If the plan modifier logic ever needs to change (e.g., adding a second modifier or adjusting the attribute name), every file must be updated independently. A small helper function would centralize the logic and reduce the risk of drift.

♻️ Proposed helper extraction
// applyUseStateForUnknown sets the UseStateForUnknown plan modifier on a string
// attribute in a generated schema so Terraform retains the prior state value
// during updates instead of marking it "known after apply".
func applyUseStateForUnknown(s schema.Schema, attrName string) {
	if attr, ok := s.Attributes[attrName].(schema.StringAttribute); ok {
		attr.PlanModifiers = []planmodifier.String{
			stringplanmodifier.UseStateForUnknown(),
		}
		s.Attributes[attrName] = attr
	}
}

Then each Schema() method simplifies to:

-	// catalog_id is assigned at creation and never changes. Without UseStateForUnknown, any update
-	// to the catalog causes Terraform to mark catalog_id as "known after apply", which propagates to
-	// downstream resources referencing it (e.g. galaxy_role_privilege_grant.entity_id) and forces
-	// unnecessary destroy/recreate cycles.
-	if attr, ok := s.Attributes["catalog_id"].(schema.StringAttribute); ok {
-		attr.PlanModifiers = []planmodifier.String{
-			stringplanmodifier.UseStateForUnknown(),
-		}
-		s.Attributes["catalog_id"] = attr
-	}
+	// catalog_id is assigned at creation and never changes.
+	applyUseStateForUnknown(s, "catalog_id")

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: de6d571d-bf49-4e9a-8d8b-160491d21e94

📥 Commits

Reviewing files that changed from the base of the PR and between 86b1864 and b861b33.

📒 Files selected for processing (20)
  • internal/provider/bigquery_catalog_resource.go
  • internal/provider/cassandra_catalog_resource.go
  • internal/provider/cluster_resource.go
  • internal/provider/column_mask_resource.go
  • internal/provider/data_product_resource.go
  • internal/provider/gcs_catalog_resource.go
  • internal/provider/mongodb_catalog_resource.go
  • internal/provider/mysql_catalog_resource.go
  • internal/provider/opensearch_catalog_resource.go
  • internal/provider/policy_resource.go
  • internal/provider/postgresql_catalog_resource.go
  • internal/provider/redshift_catalog_resource.go
  • internal/provider/role_resource.go
  • internal/provider/row_filter_resource.go
  • internal/provider/s3_catalog_resource.go
  • internal/provider/service_account_password_resource.go
  • internal/provider/service_account_resource.go
  • internal/provider/snowflake_catalog_resource.go
  • internal/provider/sqlserver_catalog_resource.go
  • internal/provider/tag_resource.go

Comment thread internal/provider/service_account_password_resource.go
@bradyburke
bradyburke merged commit f8c67d4 into main Jul 10, 2026
2 checks passed
@bradyburke
bradyburke deleted the auto-sync-2026-07-09-00934ba branch July 10, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants