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

Simplify branch protect interface #6688

Merged
merged 6 commits into from
Oct 4, 2023

Conversation

johnnyaug
Copy link
Contributor

@johnnyaug johnnyaug commented Oct 3, 2023

Following @nopcoder's comments on #6682.

Resolves #6674.

@johnnyaug johnnyaug added the exclude-changelog PR description should not be included in next release changelog label Oct 3, 2023
pkg/graveler/branch/protection_manager.go Show resolved Hide resolved
Comment on lines 42 to 44
if proto.Size(rulesMsg) == 0 {
return &graveler.BranchProtectionRules{}, nil, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case we have data, so we should return the checksum. Even if the data is an empty slice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

settings, err := m.store.Get(ctx, []byte(graveler.RepoPartition(repository)), []byte(graveler.SettingsPath(key)))
if err != nil {
if errors.Is(err, kv.ErrNotFound) {
err = graveler.ErrNotFound
}
return nil, nil, err
return swag.String(""), err
Copy link
Contributor

Choose a reason for hiding this comment

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

I understood why we would like to return a value in case of an error, specific not found. But I hope that the caller will work based on the error and the convention of the API and not use the checksum value in case of an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done - not returning empty string.

Comment on lines 144 to 154
if errors.Is(err, graveler.ErrNotFound) {
return nil, nil
}
return setting, err
return tmp, err
})
if err != nil {
return nil, err
return err
}
if setting == nil {
return nil, graveler.ErrNotFound
return graveler.ErrNotFound
}
Copy link
Contributor

Choose a reason for hiding this comment

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

About graveler.ErrNotFound: we check for the specific error inside the callback and also have if settings == nil to return the same error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's because it may arrive from the cache, which doesn't return this error.

Copy link
Contributor

@nopcoder nopcoder left a comment

Choose a reason for hiding this comment

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

LGTM!

@johnnyaug johnnyaug enabled auto-merge (squash) October 3, 2023 15:30
@johnnyaug johnnyaug merged commit 88ed1ff into master Oct 4, 2023
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude-changelog PR description should not be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Quickstart is broken when creating sample repo
2 participants