mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
Support additional flags for ACL in CommandsInfo
This commit is contained in:
23
command.go
23
command.go
@ -2019,6 +2019,7 @@ type CommandInfo struct {
|
|||||||
Name string
|
Name string
|
||||||
Arity int8
|
Arity int8
|
||||||
Flags []string
|
Flags []string
|
||||||
|
ACLFlags []string
|
||||||
FirstKeyPos int8
|
FirstKeyPos int8
|
||||||
LastKeyPos int8
|
LastKeyPos int8
|
||||||
StepCount int8
|
StepCount int8
|
||||||
@ -2071,8 +2072,8 @@ func (cmd *CommandsInfoCmd) readReply(rd *proto.Reader) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
|
func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
if n != 6 {
|
if n != 7 {
|
||||||
return nil, fmt.Errorf("redis: got %d elements in COMMAND reply, wanted 6", n)
|
return nil, fmt.Errorf("redis: got %d elements in COMMAND reply, wanted 7", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
var cmd CommandInfo
|
var cmd CommandInfo
|
||||||
@ -2125,6 +2126,24 @@ func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
cmd.StepCount = int8(stepCount)
|
cmd.StepCount = int8(stepCount)
|
||||||
|
|
||||||
|
_, err = rd.ReadReply(func(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
|
cmd.ACLFlags = make([]string, n)
|
||||||
|
for i := 0; i < len(cmd.Flags); i++ {
|
||||||
|
switch s, err := rd.ReadString(); {
|
||||||
|
case err == Nil:
|
||||||
|
cmd.ACLFlags[i] = ""
|
||||||
|
case err != nil:
|
||||||
|
return nil, err
|
||||||
|
default:
|
||||||
|
cmd.ACLFlags[i] = s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
for _, flag := range cmd.Flags {
|
for _, flag := range cmd.Flags {
|
||||||
if flag == "readonly" {
|
if flag == "readonly" {
|
||||||
cmd.ReadOnly = true
|
cmd.ReadOnly = true
|
||||||
|
Reference in New Issue
Block a user