-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Make seq indent configurable and add retain seq indent functionality #4043
Merged
k8s-ci-robot
merged 7 commits into
kubernetes-sigs:master
from
phanimarupaka:PreserveIndentation
Jul 13, 2021
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ed38b5f
Make seq indent configurable and add retain seq indent functionality
phanimarupaka 6dbc74b
Suggested changes
phanimarupaka f81201b
Add options, keep seqindent annotation equivalent to index annotation
phanimarupaka c07ffa5
Update comments, tests, not expose indent option
phanimarupaka 89b12cf
Change annotation name, error if conflicting options
phanimarupaka 74e8678
First sequence indent wins
phanimarupaka 29be7fa
Suggested changes
phanimarupaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Would it make sense to name this for the effect rather than the mechanism? E.g. something like
PreserveSequenceIndentStyle
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.
There's also an awkward conflict between this option (however named) and
OmitReaderAnnotations
. If we can do it cheaply enough, wdyt about treating it like any other reader annotation, and adding a "preserve indent style" option on the writer to make use of it where available?Related to this, I see that the writer already has a
Style
option, which I'm guessing might also interact with this new feature. E.g. if theStyle
is set to the json-likeFlowStyle
where sequence indent style doesn't apply, I'm guessingStyle
wins. We should document/test this.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.
It is not cheap to identify the indentation in byteio_reader. Hence made it opt-in. Except for that, this annotation is identical to
index
annotation and follows the same life cycle.That is a good point. Few options clash here.
Both
OmitReaderAnnotations
andStyle
win overPreserveSequenceIndentStyle
. I will document and test this behavior.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.
I started off with this but @droot thinks otherwise. I was on the fence. But the more I think, I think it is better to go with the mechanism rather than annotation(@droot WDYT). In that case, should we error out if conflicting options are set ? For e.g.
OmitReaderAnnotations
andPreserveSequenceIndentStyle
are set ?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.
Yes,
PreserveSequenceIndentStyle
makes sense at theReaderWriter
level orPackageReaderWriter
level because they do reading and writing so can encapsulate the preserving behavior. So +1 to that.The same name may not make sense at the
Reader
level because reader can't ensure that behavior, so mechanism fits better there.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.
Re:
OmitReaderAnnotations
. If we were starting today, would have definitely made the preserveIdentStyle as the default behavior and treating it like ReaderAnnotation. But at this point, to reduce the blast radius (and the cost involved), making this additive makes sense. There is an alternative path here, where we introduce this as an opt-in now (keeping it consistent with ReaderAnnotation) and eventually make it the default behavior.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.
ByteReader is also exposed. We may change the logic even at bytereader as well. So it is better to be consistent.