-
Notifications
You must be signed in to change notification settings - Fork 19
types: Add MarshalBinary and UnmarshalBinary methods to EntityUID #126
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
Conversation
…h tests Signed-off-by: Ryan Harris <[email protected]>
6b5228b to
6772b71
Compare
Signed-off-by: Ryan Harris <[email protected]>
Signed-off-by: Ryan Harris <[email protected]>
1c60eb1 to
4ddef61
Compare
Signed-off-by: Ryan Harris <[email protected]>
Signed-off-by: Ryan Harris <[email protected]>
philhassey
left a comment
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.
LGTM @patjakdev can you give it a quick second look?
Signed-off-by: Ryan Harris <[email protected]>
patjakdev
left a comment
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.
Thank you!
|
|
||
| // UnmarshalCedar parses a Cedar language representation of an EntityUID. | ||
| func (e *EntityUID) UnmarshalCedar(data []byte) error { | ||
| // NB: In a perfect world we'd use the full parsing from internal/parser, but |
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.
Thanks for writing this up. It's good to document our warts.
| s := string(data) | ||
| idx := strings.Index(s, "::\"") | ||
| if idx <= 0 { | ||
| // If idx == 0, the entity has no type, which is invalid. |
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.
tiny nit, == should be <=
Alternatively, just remove the comment :)
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.
Oh, I actually was only referring to the == 0 case for this comment. If we do find the ::" string but it's the first thing then there is no entity type which is also invalid. (There a test that exercises this scenario)
Signed-off-by: Ryan Harris <[email protected]>
Signed-off-by: Ryan Harris <[email protected]>
Issue #125 & #44
I was attempting to use
cedar.EntityUIDs directly as keys in a bstore (bbolt) K/V store but needed to do some juggling to make it work.This PR implements a straightforward variant of
EntityUID.UnmarshalCedarand uses that to implement theencoding.BinaryMarshalerandencoding.BinaryUnmarshalerinterfaces.