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

Accept both perm and perms in acl objects #349

Merged
merged 2 commits into from
Jul 14, 2024

Conversation

maharjanraj
Copy link
Contributor

Accept both perm and perms while creating an acl object

Description

Accept both perm and perms in acl objects while setting acl for a zookeeper node

Motivation and Context

get_acl returns acl objects with perms key, while set_acl accepts only perm key, these need to be consistent, so updated the code to take both, so there is no any breaking change and it's consistent.

How Has This Been Tested?

Added an integration test: tests/integration/getAndSetAcltest.js

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

src/node-zk.cpp Outdated
@@ -999,7 +999,9 @@ class ZooKeeper: public Nan::ObjectWrap {

Nan::Utf8String _scheme (toString(toLocalVal(obj, LOCAL_STRING("scheme"))));
Nan::Utf8String _auth (toString(toLocalVal(obj, LOCAL_STRING("auth"))));
uint32_t _perms = toUint(toLocalVal(obj, LOCAL_STRING("perm")));
// check if perm or perms exists, later can be changed to accept just 'perms' on next major release
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like to handle the "perm" and "perms" in the JavaScript code, instead of in the C++ AddOn code. Would you consider changing it into something similar to the Work in progress here? master...DavidVujic:node-zookeeper:acl-perm-variations

Copy link
Contributor Author

@maharjanraj maharjanraj Jul 11, 2024

Choose a reason for hiding this comment

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

@DavidVujic Yes, I can do that.
My idea was to make it consistent on the addon level, not just JavaScript. Since it's inconsistent at the addon level I did a fix there. The next major release can be made perms consistent on every level, and can be easily achieved later by removing just the property check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DavidVujic should we prioritize perms over perm if both are given for consistency?

Copy link
Collaborator

@DavidVujic DavidVujic Jul 12, 2024

Choose a reason for hiding this comment

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

Good question! With the mapping of the acl code I think it will be dependent on the order of the keys. I think that is ok and good enough.

@DavidVujic
Copy link
Collaborator

This is great! Thank you for this Pull Request @maharjanraj I also had started with this, with an approach very similar to yours. 😄

@maharjanraj
Copy link
Contributor Author

@DavidVujic I have updated the Pull Request. Please review.

Copy link
Collaborator

@DavidVujic DavidVujic left a comment

Choose a reason for hiding this comment

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

Great work ⭐

@DavidVujic
Copy link
Collaborator

I'll merge and publish a new version as soon as possible (within a couple of days at most). Huge thank you for this contribution @maharjanraj 👏

@DavidVujic DavidVujic merged commit 0f7f14f into yfinkelstein:master Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants