-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add conversions to/from decisionpb.TLSIdentity #50308
Conversation
|
||
// TLSIdentityToTLSCA transforms a [decisionpb.TLSIdentity] into its | ||
// equivalent [tlsca.Identity]. | ||
func TLSIdentityToTLSCA(id *decisionpb.TLSIdentity) *tlsca.Identity { |
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.
@fspmarshall these are very similar to the helpers in our shared branch, with the major exception that I'm passing tlsca.Identity around as a pointer instead of by value - the struct is too big to keep copying around IMO (despite what a large part of the codebase seems to do).
I also don't distinguish between zero and nil for structs within tlsca.Identity, as they aren't distinguished there either. Semantics should be alright in the existing system (for example we'll handle an "empty" DeviceExtensions just fine).
return apitraitconvert.ToProto(apiTraits) | ||
} | ||
|
||
func routeToAppFromProto(routeToApp *decisionpb.RouteToApp) tlsca.RouteToApp { |
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.
This returns tlsca.RouterToApp by value as that is how tlsca.Identity wants it. The inverse conversion (routeToAppToProto) will both take and return a pointer.
Same for other structs.
Friendly ping reviewers? |
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 be useful to put those conversion functions in api/
?
Also, are we okay with the fact some fields are not deep copied and that editing the result of the conversion might change the original resource? (I think a few slices are passed as-is). Do we want to mention it in the godoc?
We can move if needed, for now I think this is fine (I don't see api/ code touching the protos here).
Seems OK too. I'll mention in godocs, that is a good suggestion. |
PTAL @hugoShaka. Friendly ping @fspmarshall @eriktate. |
Add conversion methods between tlsca.Identity and decisionpb.TLSIdentity.
#49837