-
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 conversions to/from decisionpb.TLSIdentity * Map timestamppb.Timestamp{} to 0-0-0 0:0.0 (instead of unix epoch) * Document that slices are not deep-copied
* Add conversions to/from decisionpb.TLSIdentity * Map timestamppb.Timestamp{} to 0-0-0 0:0.0 (instead of unix epoch) * Document that slices are not deep-copied
* Add conversions to/from decisionpb.TLSIdentity * Map timestamppb.Timestamp{} to 0-0-0 0:0.0 (instead of unix epoch) * Document that slices are not deep-copied
* Add initial Decision (aka PDP) protos (#49875) * Clone protos from fspmarshall/pdp-work-02 * Use decisionpb as the Go package alias * Update DecisionService docs * Split identity protos into separate files * Update Metadata docs * Split metadata into separate files * Update Resource docs * Update database access docs and fields * Update SSH access docs and fields * Ignore breaking changes on decision protos * Update generated protos * Use teleport.trait.v1.Trait * Document mutual dependency between "ResourceID" types * nit: s/ResourceID/ResourceId * nit: Use the correct CamelCase field name in comments * Update generated protos * Add RouteToApp.target_port * Update generated protos * Update comments on TLSIdentity / tlsca.Identity * Update generated protos * Add the decisionv1.Service boilerplate (#49912) * Add the decisionv1.Service boilerplate * Wire decisionv1.Service to auth.GRPCServer * Wire decisionpb.DecisionServiceClient to client.Client * Add basic service testing * Add conversions to/from decisionpb.TLSIdentity (#50308) * Add conversions to/from decisionpb.TLSIdentity * Map timestamppb.Timestamp{} to 0-0-0 0:0.0 (instead of unix epoch) * Document that slices are not deep-copied * Add EvaluateDatabaseAccessRequest.database (#50481) * Add EvaluateDatabaseAccessRequest.database * Update generated protos * fix protos & tls identity --------- Co-authored-by: Alan Parra <alan.parra@goteleport.com>
* Add initial Decision (aka PDP) protos (#49875) * Clone protos from fspmarshall/pdp-work-02 * Use decisionpb as the Go package alias * Update DecisionService docs * Split identity protos into separate files * Update Metadata docs * Split metadata into separate files * Update Resource docs * Update database access docs and fields * Update SSH access docs and fields * Ignore breaking changes on decision protos * Update generated protos * Use teleport.trait.v1.Trait * Document mutual dependency between "ResourceID" types * nit: s/ResourceID/ResourceId * nit: Use the correct CamelCase field name in comments * Update generated protos * Add RouteToApp.target_port * Update generated protos * Update comments on TLSIdentity / tlsca.Identity * Update generated protos * Add the decisionv1.Service boilerplate (#49912) * Add the decisionv1.Service boilerplate * Wire decisionv1.Service to auth.GRPCServer * Wire decisionpb.DecisionServiceClient to client.Client * Add basic service testing * Add conversions to/from decisionpb.TLSIdentity (#50308) * Add conversions to/from decisionpb.TLSIdentity * Map timestamppb.Timestamp{} to 0-0-0 0:0.0 (instead of unix epoch) * Document that slices are not deep-copied * Add EvaluateDatabaseAccessRequest.database (#50481) * Add EvaluateDatabaseAccessRequest.database * Update generated protos * fix protos & tls identity --------- Co-authored-by: Alan Parra <alan.parra@goteleport.com>
* Add initial Decision (aka PDP) protos (#49875) * Clone protos from fspmarshall/pdp-work-02 * Use decisionpb as the Go package alias * Update DecisionService docs * Split identity protos into separate files * Update Metadata docs * Split metadata into separate files * Update Resource docs * Update database access docs and fields * Update SSH access docs and fields * Ignore breaking changes on decision protos * Update generated protos * Use teleport.trait.v1.Trait * Document mutual dependency between "ResourceID" types * nit: s/ResourceID/ResourceId * nit: Use the correct CamelCase field name in comments * Update generated protos * Add RouteToApp.target_port * Update generated protos * Update comments on TLSIdentity / tlsca.Identity * Update generated protos * Add the decisionv1.Service boilerplate (#49912) * Add the decisionv1.Service boilerplate * Wire decisionv1.Service to auth.GRPCServer * Wire decisionpb.DecisionServiceClient to client.Client * Add basic service testing * Add conversions to/from decisionpb.TLSIdentity (#50308) * Add conversions to/from decisionpb.TLSIdentity * Map timestamppb.Timestamp{} to 0-0-0 0:0.0 (instead of unix epoch) * Document that slices are not deep-copied * Add EvaluateDatabaseAccessRequest.database (#50481) * Add EvaluateDatabaseAccessRequest.database * Update generated protos --------- Co-authored-by: Alan Parra <alan.parra@goteleport.com>
Add conversion methods between tlsca.Identity and decisionpb.TLSIdentity.
#49837