fix(schema): resolve configuration drift in device group, alert rule, escalation chain#132
Open
ryanmat wants to merge 2 commits into
Open
Conversation
… escalation chain - Add DiffSuppressFunc to NameAndValue value field to handle LM API masking sensitive properties as "**********" (fixes logicmonitor#85, logicmonitor#124) - Add Computed: true to device group extra field so API-returned cloud account data does not cause perpetual deletion plans (fixes logicmonitor#57) - Add Computed: true to custom_properties in device_group, device, collector, and collector_group resource schemas so server-injected properties do not cause ordering drift (fixes logicmonitor#53, logicmonitor#115) - Normalize nil escalating_chain to empty map in alert rule state to prevent null vs empty map drift on every plan (fixes logicmonitor#92) - Add bounds check on escalation chain stages to prevent index out-of-bounds panic when Stages slice is empty
- Test DiffSuppressFunc on NameAndValue value field with 6 cases: masked old value, non-masked values, empty values, reverse mask - Test device group extra field has Computed: true - Test custom_properties has Computed: true across all 4 resource schemas - Test escalating_chain nil normalization to empty map in alert rule - Test chain stages bounds check with empty, nil, and populated stages - Test chain SubResourceData handles nil input gracefully
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DiffSuppressFunctoNameAndValuevalue field to handle LM API masking sensitive properties as**********— eliminates perpetual diff on password/token propertiesComputed: trueto device groupextrafield so API-returned cloud account data does not cause perpetual deletion plansComputed: truetocustom_propertiesindevice_group,device,collector, andcollector_groupresource schemas so server-injected properties do not cause ordering driftescalating_chainto empty map in alert rule state to prevent null vs empty map drift on every planFixes #53, #57, #85, #92, #115, #124
Files Changed
logicmonitor/schemata/name_and_value_schema.go— DiffSuppressFunc on value fieldlogicmonitor/schemata/device_group_schema.go— Computed on extra + custom_propertieslogicmonitor/schemata/device_schema.go— Computed on custom_propertieslogicmonitor/schemata/collector_schema.go— Computed on custom_propertieslogicmonitor/schemata/collector_group_schema.go— Computed on custom_propertieslogicmonitor/schemata/alert_rule_schema.go— nil guard on escalating_chainlogicmonitor/schemata/chain_schema.go— bounds check on Stageslogicmonitor/schemata/drift_fixes_test.go— unit tests (10 tests, 17 cases)Testing
go test ./logicmonitor/schemata/ -v(all 17 cases pass)lmryanmatuszewski) using Terraform 1.14.8 with dev_overridesterraform import+terraform plan= 0 changes (extra block and custom_properties clean)terraform import+terraform plan= 0 changes (escalating_chain nil drift resolved)"no_changes"confirmed via structured JSON outputCross-cutting root cause
The provider is auto-generated by go-swagger. The generated schema code lacks:
DiffSuppressFuncfor masked/sensitive valuesComputed: trueon server-managed fieldsThese are common patterns in hand-maintained Terraform providers that the generator does not produce.