Skip to content

direct: auto-generate RemapState copiers from resource types - #6777

Draft
denik wants to merge 6 commits into
mainfrom
denik/remapstate-identity-comment
Draft

denik wants to merge 6 commits into
mainfrom
denik/remapstate-identity-comment

Conversation

@denik

@denik denik commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Many resources' RemapState is a mechanical copy: it moves same-named fields from the remote type into the state type and filters ForceSendFields. This replaces those with a copier compiled once from the (remote, state) type pair at package init and wired into the adapter when a resource has no custom RemapState.

buildCopiers is driven off SupportedResources, so every auto-copied resource is validated at load — anything the copier can't copy losslessly (kind-changing conversions, mismatched struct shapes) fails there, not as silent drift at deploy time. Deletes 12 redundant RemapState methods; resources with genuine remap logic keep theirs.

Behavior is unchanged: a test fully populates each remote and asserts the copier reproduces the old hand-written output before deletion.

This pull request and its description were written by Isaac.

…s state type

Co-authored-by: Isaac <no-reply@databricks.com>
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 9ed6196

Run: 35716286879

Env ✅​pass 🙈​skip Time
✅​ aws linux 276 15 4:13
✅​ aws windows 278 13 5:42
✅​ azure linux 275 15 4:31
✅​ azure windows 277 13 3:38
✅​ gcp linux 276 15 4:25
✅​ gcp windows 278 13 5:38
Top 3 slowest tests (at least 2 minutes):
duration env testname
5:39 aws windows TestAccept
5:36 gcp windows TestAccept
3:36 azure windows TestAccept

@denik denik closed this Sep 22, 2026
Resources whose state type is a plain subset of the remote type had a
hand-written RemapState that mechanically copied same-named fields and
filtered ForceSendFields. Replace those with a copier compiled once from
the (remote, state) type pair at package init and wired into the adapter
when a resource has no custom RemapState.

buildCopiers is driven off SupportedResources, so every auto-copied
resource is validated at load: anything the copier cannot copy losslessly
(kind-changing conversions, mismatched struct shapes) fails there rather
than as silent drift at deploy time. Deletes 12 redundant RemapState
methods; resources with genuine logic keep theirs.

Co-authored-by: Isaac <no-reply@databricks.com>
@denik denik changed the title dresources: document why RemapState is skipped when types match direct: auto-generate RemapState copiers from resource types Sep 22, 2026
Co-authored-by: Isaac <no-reply@databricks.com>
@denik denik reopened this Sep 22, 2026
denik and others added 3 commits September 22, 2026 11:48
Co-authored-by: Isaac <no-reply@databricks.com>
Drop the duplicate reflection filler in favor of the existing fillNonZero,
populating ForceSendFields with a small dedicated helper. Field-per-line
table in TestSafeConvert; shorten the README section.

Co-authored-by: Isaac <no-reply@databricks.com>
Move the reflection copier (compile-time type check, field/JSON-name copy,
ForceSendFields filtering, lossless conversions) out of dresources into a
reusable package beside structwalk/structdiff/structaccess. The direct engine
wiring (buildCopiers, driven off SupportedResources) stays in dresources and
now calls structcopy.Compile.

Co-authored-by: Isaac <no-reply@databricks.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants