Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
  • Loading branch information
jimil749 committed Jul 5, 2021
1 parent 6f37009 commit a03c165
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Binary file modified examples/plugin/json
Binary file not shown.
4 changes: 2 additions & 2 deletions internal/grpc/services/userprovider/userprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ func parseConfig(m map[string]interface{}) (*config, error) {
}

// getDriverPlugin fetches the runtime driver from the plugins package
func getDriverPlugin(c *config) (user.UserManager, error) {
func getDriverPlugin(c *config) (user.ManagerRPC, error) {
sym, err := c.load()
if err != nil {
return nil, err
}

// assert the loaded plugin into required interface
manager, ok := sym.(user.UserManager)
manager, ok := sym.(user.ManagerRPC)
if !ok {
return nil, fmt.Errorf("could not assert the loaded plugin")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

// pluginMap contains all the plugins that can be consumed.
var pluginMap = map[string]plugin.Plugin{
"userprovider": &user.UserProviderPlugin{},
"userprovider": &user.ProviderPlugin{},
}

var handshake = plugin.HandshakeConfig{
Expand All @@ -38,7 +38,7 @@ var handshake = plugin.HandshakeConfig{
MagicCookieValue: "hello",
}

// Load loads the plugin using the hashicorp go-plugin sytem
// Load loads the plugin using the hashicorp go-plugin system
func Load(driver string, pluginType string) (interface{}, error) {
logger := hclog.New(&hclog.LoggerOptions{
Name: "plugin",
Expand Down
18 changes: 9 additions & 9 deletions pkg/user/rpc_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ import (
"github.com/hashicorp/go-plugin"
)

// UserProviderPlugin is the implemenation of plugin.Plugin so we can serve/consume this.
type UserProviderPlugin struct {
Impl UserManager
// ProviderPlugin is the implemenation of plugin.Plugin so we can serve/consume this.
type ProviderPlugin struct {
Impl ManagerRPC
}

func (p *UserProviderPlugin) Server(*plugin.MuxBroker) (interface{}, error) {
func (p *ProviderPlugin) Server(*plugin.MuxBroker) (interface{}, error) {
return &RPCServer{Impl: p.Impl}, nil
}

func (p *UserProviderPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error) {
func (p *ProviderPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error) {
return &RPCClient{Client: c}, nil
}

Expand Down Expand Up @@ -64,7 +64,7 @@ func (m *RPCClient) New(ml map[string]interface{}) error {

// GetUserArg for RPC
type GetUserArg struct {
Uid *userpb.UserId
UID *userpb.UserId
}

// GetUserReply for RPC
Expand All @@ -74,7 +74,7 @@ type GetUserReply struct {
}

func (m *RPCClient) GetUser(ctx context.Context, uid *userpb.UserId) (*userpb.User, error) {
args := GetUserArg{Uid: uid}
args := GetUserArg{UID: uid}
resp := GetUserReply{}
err := m.Client.Call("Plugin.GetUser", args, &resp)
if err != nil {
Expand Down Expand Up @@ -150,7 +150,7 @@ func (m *RPCClient) FindUsers(ctx context.Context, query string) ([]*userpb.User
// RPCServer is the server that RPCClient talks to, conforming to the requirements of net/rpc
type RPCServer struct {
// This is the real implementation
Impl UserManager
Impl ManagerRPC
}

func (m *RPCServer) New(args NewArg, resp *NewReply) error {
Expand All @@ -159,7 +159,7 @@ func (m *RPCServer) New(args NewArg, resp *NewReply) error {
}

func (m *RPCServer) GetUser(args GetUserArg, resp *GetUserReply) error {
resp.User, resp.Err = m.Impl.GetUser(context.Background(), args.Uid)
resp.User, resp.Err = m.Impl.GetUser(context.Background(), args.UID)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ type Manager interface {
FindUsers(ctx context.Context, query string) ([]*userpb.User, error)
}

// UserManager is the interface to implement to manipulate users via RPC
type UserManager interface {
// ManagerRPC is the interface to implement to manipulate users via RPC
type ManagerRPC interface {
New(m map[string]interface{}) error
GetUser(ctx context.Context, uid *userpb.UserId) (*userpb.User, error)
GetUserByClaim(ctx context.Context, claim, value string) (*userpb.User, error)
Expand Down

0 comments on commit a03c165

Please sign in to comment.