mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 00:40:25 +02:00
grpc: remove ptypes references (#3078)
This commit is contained in:
parent
35f697e491
commit
1342523cda
13 changed files with 83 additions and 177 deletions
|
@ -4,49 +4,19 @@ package directory
|
|||
import (
|
||||
context "context"
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
|
||||
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
||||
)
|
||||
|
||||
// GetGroup gets a directory group from the databroker.
|
||||
func GetGroup(ctx context.Context, client databroker.DataBrokerServiceClient, groupID string) (*Group, error) {
|
||||
any, _ := ptypes.MarshalAny(new(Group))
|
||||
|
||||
res, err := client.Get(ctx, &databroker.GetRequest{
|
||||
Type: any.GetTypeUrl(),
|
||||
Id: groupID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var g Group
|
||||
err = ptypes.UnmarshalAny(res.GetRecord().GetData(), &g)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &g, nil
|
||||
g := Group{Id: groupID}
|
||||
return &g, databroker.Get(ctx, client, &g)
|
||||
}
|
||||
|
||||
// GetUser gets a directory user from the databroker.
|
||||
func GetUser(ctx context.Context, client databroker.DataBrokerServiceClient, userID string) (*User, error) {
|
||||
any, _ := ptypes.MarshalAny(new(User))
|
||||
|
||||
res, err := client.Get(ctx, &databroker.GetRequest{
|
||||
Type: any.GetTypeUrl(),
|
||||
Id: userID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var u User
|
||||
err = ptypes.UnmarshalAny(res.GetRecord().GetData(), &u)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &u, nil
|
||||
u := User{Id: userID}
|
||||
return &u, databroker.Get(ctx, client, &u)
|
||||
}
|
||||
|
||||
// Options are directory provider options.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue