Skip to content
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

bbolt page supports --all and --value-format=redacted formats. #359

Merged
merged 2 commits into from
Dec 22, 2022

Conversation

ptabor
Copy link
Contributor

@ptabor ptabor commented Dec 18, 2022

bbolt page supports --all and --value-format=redacted formats.

--all - prints all pages (only skips pages that were considered successful overflow pages)
--value-format=redacted just prints a length of the value, to reduce length and protect privacy.

The auto & redacted formats are supported in all tools that accept '--format'.

@ptabor
Copy link
Contributor Author

ptabor commented Dec 18, 2022

The first commit is just extraction of the command to a file (the main.go is already huge),
The second commit contains the business changes.

@ptabor ptabor requested a review from ahrtr December 21, 2022 10:37
@ptabor
Copy link
Contributor Author

ptabor commented Dec 21, 2022

This commit has not-mechanical changes: bdf7b8f

--all
prints all pages (only skips pages that were considered successful overflow pages)
--value-format=`+FORMAT_MODES+` (default: auto)
just prints a length of the value, to reduce length and protect privacy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that --value-format is only used to format the leaf page?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as on other pages we have usually 'keys'.

It makes sense - especially in etcd case to keep keys as hex.

Expanded the comment (it was clearly wrong).

func (p *page) Type() string {
if (p.flags & branchPageFlag) != 0 {
// For now all flags are exclusive,so let's be strict with expectations.
if p.flags == branchPageFlag {
return "branch"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking why not to define const? We can get all const defined in a common package, so as to be shared by both boltDB and CMDs. Of course, in a separate PR.

type PageType string
const (
    BranchPage PageType = "branch"
    ...
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. The extraction of shared library starts here: #361

@ahrtr
Copy link
Member

ahrtr commented Dec 22, 2022

Overall looks good to me.

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with only a minor comment #359 (comment). The description for --value-format isn't clear to me. I'd leave you to update the usage.

--all - prints all pages (only skips pages that were considered successful overflow pages)
--value-format=redacted just prints a length of the value, to reduce length and protect privacy.

The auto & redacted formats are supported in all tools that accept '--format'.

Signed-off-by: Piotr Tabor <ptab@google.com>
@ptabor
Copy link
Contributor Author

ptabor commented Dec 22, 2022

Thank you for review.

@ptabor ptabor merged commit 109f510 into etcd-io:master Dec 22, 2022
@ahrtr ahrtr added this to the 1.3.7 milestone Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants