-
Notifications
You must be signed in to change notification settings - Fork 136
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
Update Left-side overlay positions #341
Conversation
- need to build in a way to test line positions `template_test.go` - run this test with `./hack/test-unit.sh -run TestYAMLTemplate TestYAMLTemplate.filetest=filetests/ytt-library/overlay/replace-key-position`
Co-authored-by: Garrett Cheadle <[email protected]>
- extract stringifying evaluated template into separate function
7035b29
to
1b39c55
Compare
Signed-off-by: Garrett Cheadle <[email protected]>
Signed-off-by: Garrett Cheadle <[email protected]>
We've found that in general, starlark structs have unknown positions. The unknown position now surfaces (using Starlark struct example:
cc: @cari-lynn |
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.
Reviewed together.
Notes:
- in
template_test.go
look tearing off an interface for theAsBytes()
function;interface{}
means we can't commit to a given interface. - explore where the "Single Point Of Truth" could be for setting a value of a target node, given a replacing node.
- Change return and parameter type to a more strict interface Signed-off-by: Steven Locke <[email protected]>
Addressed @jtigger 's comments above. We created a Node interface method to set the position. We did not update references to where we are setting the position directly (ie: map.Position) and did not make the field private since we noticed there is not a consistent pattern for other fields currently. Happy to hear opinions if you have any regarding it. |
pkg/yamltemplate/filetests/ytt-library/overlay/array-output-position.yml
Outdated
Show resolved
Hide resolved
- Preserving the Type and Metas fields on merge overlay operations is intentional in the anticipation that we may need them later for type checking - We did not change logic to preserve fields on overlay replace operations, but anticipate we may need to preserve some fields later on. Signed-off-by: John Ryan <[email protected]>
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.
Reviewed synchronously.
In terms of "Single Point of Truth" — thanks for looking into this. Seems fine to let this ride for a bit as we watch the schema feature settling in. The comments left there I think will help future readers understand the current intent and what might change that implementation.
This work is to update the position (file name and line number) of left side node when a document is overlayed. It is needed to report right side schema error messages, and also shows up when using the
--output pos
flag.