Skip to content

Commit 23f6dd4

Browse files
yuukivmihailenco
authored andcommitted
Support additional flags for ACL in CommandsInfo
1 parent 8f52186 commit 23f6dd4

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

command.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,7 @@ type CommandInfo struct {
18851885
Name string
18861886
Arity int8
18871887
Flags []string
1888+
ACLFlags []string
18881889
FirstKeyPos int8
18891890
LastKeyPos int8
18901891
StepCount int8
@@ -1934,8 +1935,8 @@ func (cmd *CommandsInfoCmd) readReply(rd *proto.Reader) error {
19341935
}
19351936

19361937
func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
1937-
if n != 6 {
1938-
return nil, fmt.Errorf("redis: got %d elements in COMMAND reply, wanted 6", n)
1938+
if n != 7 {
1939+
return nil, fmt.Errorf("redis: got %d elements in COMMAND reply, wanted 7", n)
19391940
}
19401941

19411942
var cmd CommandInfo
@@ -1988,6 +1989,24 @@ func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
19881989
}
19891990
cmd.StepCount = int8(stepCount)
19901991

1992+
_, err = rd.ReadReply(func(rd *proto.Reader, n int64) (interface{}, error) {
1993+
cmd.ACLFlags = make([]string, n)
1994+
for i := 0; i < len(cmd.Flags); i++ {
1995+
switch s, err := rd.ReadString(); {
1996+
case err == Nil:
1997+
cmd.ACLFlags[i] = ""
1998+
case err != nil:
1999+
return nil, err
2000+
default:
2001+
cmd.ACLFlags[i] = s
2002+
}
2003+
}
2004+
return nil, nil
2005+
})
2006+
if err != nil {
2007+
return nil, err
2008+
}
2009+
19912010
for _, flag := range cmd.Flags {
19922011
if flag == "readonly" {
19932012
cmd.ReadOnly = true

0 commit comments

Comments
 (0)