From 6049c95dc989f3c41a66eaae5ff3c2040a0996af Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 29 Apr 2016 11:03:20 -0700 Subject: [PATCH] clientv3: auth with rpctypes.Error --- clientv3/auth.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/clientv3/auth.go b/clientv3/auth.go index 9370295f2..d72657edc 100644 --- a/clientv3/auth.go +++ b/clientv3/auth.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/coreos/etcd/auth/authpb" + "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "golang.org/x/net/context" "google.golang.org/grpc" @@ -87,37 +88,37 @@ func NewAuth(c *Client) Auth { func (auth *auth) AuthEnable(ctx context.Context) (*AuthEnableResponse, error) { resp, err := auth.remote.AuthEnable(ctx, &pb.AuthEnableRequest{}) - return (*AuthEnableResponse)(resp), err + return (*AuthEnableResponse)(resp), rpctypes.Error(err) } func (auth *auth) Authenticate(ctx context.Context, name string, password string) (*AuthenticateResponse, error) { resp, err := auth.remote.Authenticate(ctx, &pb.AuthenticateRequest{Name: name, Password: password}) - return (*AuthenticateResponse)(resp), err + return (*AuthenticateResponse)(resp), rpctypes.Error(err) } func (auth *auth) UserAdd(ctx context.Context, name string, password string) (*AuthUserAddResponse, error) { resp, err := auth.remote.UserAdd(ctx, &pb.AuthUserAddRequest{Name: name, Password: password}) - return (*AuthUserAddResponse)(resp), err + return (*AuthUserAddResponse)(resp), rpctypes.Error(err) } func (auth *auth) UserDelete(ctx context.Context, name string) (*AuthUserDeleteResponse, error) { resp, err := auth.remote.UserDelete(ctx, &pb.AuthUserDeleteRequest{Name: name}) - return (*AuthUserDeleteResponse)(resp), err + return (*AuthUserDeleteResponse)(resp), rpctypes.Error(err) } func (auth *auth) UserChangePassword(ctx context.Context, name string, password string) (*AuthUserChangePasswordResponse, error) { resp, err := auth.remote.UserChangePassword(ctx, &pb.AuthUserChangePasswordRequest{Name: name, Password: password}) - return (*AuthUserChangePasswordResponse)(resp), err + return (*AuthUserChangePasswordResponse)(resp), rpctypes.Error(err) } func (auth *auth) UserGrant(ctx context.Context, user string, role string) (*AuthUserGrantResponse, error) { resp, err := auth.remote.UserGrant(ctx, &pb.AuthUserGrantRequest{User: user, Role: role}) - return (*AuthUserGrantResponse)(resp), err + return (*AuthUserGrantResponse)(resp), rpctypes.Error(err) } func (auth *auth) RoleAdd(ctx context.Context, name string) (*AuthRoleAddResponse, error) { resp, err := auth.remote.RoleAdd(ctx, &pb.AuthRoleAddRequest{Name: name}) - return (*AuthRoleAddResponse)(resp), err + return (*AuthRoleAddResponse)(resp), rpctypes.Error(err) } func (auth *auth) RoleGrant(ctx context.Context, name string, key string, permType PermissionType) (*AuthRoleGrantResponse, error) { @@ -126,7 +127,7 @@ func (auth *auth) RoleGrant(ctx context.Context, name string, key string, permTy PermType: authpb.Permission_Type(permType), } resp, err := auth.remote.RoleGrant(ctx, &pb.AuthRoleGrantRequest{Name: name, Perm: perm}) - return (*AuthRoleGrantResponse)(resp), err + return (*AuthRoleGrantResponse)(resp), rpctypes.Error(err) } func StrToPermissionType(s string) (PermissionType, error) {