-
Notifications
You must be signed in to change notification settings - Fork 37
fix schema whitespace drift #176
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
Conversation
|
@freeznet:Thanks for your contribution. For this PR, do we need to update docs? |
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.
Pull request overview
This PR fixes issue #175 by implementing JSON normalization for schema data to prevent Terraform from detecting drift when only whitespace formatting differs between the configuration and stored state. The solution adds a DiffSuppressFunc that normalizes JSON schemas before comparison and updates the Read function to store normalized schema data in state.
Key Changes:
- Added JSON normalization logic that canonicalizes JSON strings while preserving non-JSON schemas
- Implemented
DiffSuppressFuncfor theschema_datafield to suppress whitespace-only differences - Added comprehensive test coverage for the whitespace drift scenario
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pulsar/resource_pulsar_schema.go | Adds normalizeSchemaData function for JSON canonicalization, implements DiffSuppressFunc for schema_data field, and updates Read function to normalize retrieved schema data |
| pulsar/resource_pulsar_schema_test.go | Adds TestPulsarSchemaWhitespaceDiff test with compact and pretty-printed JSON configurations to verify whitespace drift is properly suppressed |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
(If this PR fixes a github issue, please add
Fixes #<xyz>.)Fixes #175
(or if this PR is one task of a github issue, please add
Master Issue: #<xyz>to link to the master issue.)Master Issue: #
Motivation
Explain here the context, and why you're making that change. What is the problem you're trying to solve.
Modifications
Describe the modifications you've done.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Documentation
Check the box below.
Need to update docs?
doc-required(If you need help on updating docs, create a doc issue)
no-need-doc(Please explain why)
doc(If this PR contains doc changes)