Make config-remote-sync patching logic more generic#4400
Conversation
|
Commit: b694b69
18 interesting tests: 9 KNOWN, 5 SKIP, 4 RECOVERED
Top 50 slowest tests (at least 2 minutes):
|
|
|
||
| // normalizeValue converts values to plain Go types suitable for YAML patching | ||
| // by using SDK marshaling which properly handles ForceSendFields and other annotations. | ||
| func normalizeValue(v any) (any, error) { |
There was a problem hiding this comment.
This is moved as is from patch.go
Will check if it's needed and can it be replaced with dyn in following PRs
|
|
||
| type resolvedChanges map[string]*deployplan.ChangeDesc | ||
| // ApplyChangesToYAML generates YAML files for the given field changes. | ||
| func ApplyChangesToYAML(ctx context.Context, b *bundle.Bundle, fieldChanges []FieldChange) ([]FileChange, error) { |
There was a problem hiding this comment.
This was simplified to reduce nesting level, also bundle-specific logic was moved to diff.go and resolve.go
| } | ||
|
|
||
| // ResolveChanges resolves selectors and computes field path candidates for each change. | ||
| func ResolveChanges(ctx context.Context, b *bundle.Bundle, configChanges Changes) ([]FieldChange, error) { |
There was a problem hiding this comment.
All path resolution is handled here now, I will update this to traverse path nodes in following PRs
denik
left a comment
There was a problem hiding this comment.
Could you make PR description more concrete? Which functions/types were moved, which were changed, which replaced by something newer.
Elaborated a bit |
Changes
Split the config-remote-sync command into 3 separate phases. Previously, some DAB-specific logic was embedded in the patcher, now it
Detect (diff.go) - Compare states, handle server-side and CLI defaults. Convert value to the internal struct. Compute which operation type should be applied to the config
Resolve (resolve.go) - Determine file locations and field paths. Replace [task_key=foo] selectors
Patch (patch.go) - Now only handles YAML modifications, doesn't hold any config-specific logic
Changes:
resolve.gopatch.gotoresolve.goWhy
Preparation before the next PR, where I plan to properly handle CLI defaults
Tests