*: support getting role in auth v3

This commit implements RoleGet() RPC of etcdserver and adds a new
subcommand "role get" to etcdctl v3. It will list up permissions that
are granted to a given role.

$ ETCDCTL_API=3 bin/etcdctl role get r1
Role r1
KV Read:
        b
        d
KV Write:
        a
        c
        d
This commit is contained in:
Hitoshi Mitake
2016-06-02 23:25:15 +09:00
committed by Hitoshi Mitake
parent 755567cb3d
commit 10ee69b44c
10 changed files with 452 additions and 206 deletions

View File

@ -64,6 +64,7 @@ type applierV3 interface {
UserGet(ua *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error)
RoleAdd(ua *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error)
RoleGrant(ua *pb.AuthRoleGrantRequest) (*pb.AuthRoleGrantResponse, error)
RoleGet(ua *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error)
}
type applierV3backend struct {
@ -117,6 +118,8 @@ func (s *EtcdServer) applyV3Request(r *pb.InternalRaftRequest) *applyResult {
ar.resp, ar.err = s.applyV3.RoleAdd(r.AuthRoleAdd)
case r.AuthRoleGrant != nil:
ar.resp, ar.err = s.applyV3.RoleGrant(r.AuthRoleGrant)
case r.AuthRoleGet != nil:
ar.resp, ar.err = s.applyV3.RoleGet(r.AuthRoleGet)
default:
panic("not implemented")
}
@ -547,6 +550,10 @@ func (a *applierV3backend) RoleGrant(r *pb.AuthRoleGrantRequest) (*pb.AuthRoleGr
return a.s.AuthStore().RoleGrant(r)
}
func (a *applierV3backend) RoleGet(r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error) {
return a.s.AuthStore().RoleGet(r)
}
type quotaApplierV3 struct {
applierV3
q Quota