grpc: remove ptypes references (#3078)

This commit is contained in:
Caleb Doxsey 2022-02-24 08:37:59 -07:00 committed by GitHub
parent 35f697e491
commit 1342523cda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 83 additions and 177 deletions

View file

@ -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.