@@ -4,8 +4,20 @@ import "context"
4
4
5
5
type ACLCmdable interface {
6
6
ACLDryRun (ctx context.Context , username string , command ... interface {}) * StringCmd
7
+
7
8
ACLLog (ctx context.Context , count int64 ) * ACLLogCmd
8
9
ACLLogReset (ctx context.Context ) * StatusCmd
10
+
11
+ ACLSetUser (ctx context.Context , username string , rules ... string ) * StatusCmd
12
+ ACLDelUser (ctx context.Context , username string ) * IntCmd
13
+ ACLList (ctx context.Context ) * StringSliceCmd
14
+
15
+ ACLCat (ctx context.Context ) * StringSliceCmd
16
+ ACLCatArgs (ctx context.Context , options * ACLCatArgs ) * StringSliceCmd
17
+ }
18
+
19
+ type ACLCatArgs struct {
20
+ Category string
9
21
}
10
22
11
23
func (c cmdable ) ACLDryRun (ctx context.Context , username string , command ... interface {}) * StringCmd {
@@ -33,3 +45,45 @@ func (c cmdable) ACLLogReset(ctx context.Context) *StatusCmd {
33
45
_ = c (ctx , cmd )
34
46
return cmd
35
47
}
48
+
49
+ func (c cmdable ) ACLDelUser (ctx context.Context , username string ) * IntCmd {
50
+ cmd := NewIntCmd (ctx , "acl" , "deluser" , username )
51
+ _ = c (ctx , cmd )
52
+ return cmd
53
+ }
54
+
55
+ func (c cmdable ) ACLSetUser (ctx context.Context , username string , rules ... string ) * StatusCmd {
56
+ args := make ([]interface {}, 3 + len (rules ))
57
+ args [0 ] = "acl"
58
+ args [1 ] = "setuser"
59
+ args [2 ] = username
60
+ for i , rule := range rules {
61
+ args [i + 3 ] = rule
62
+ }
63
+ cmd := NewStatusCmd (ctx , args ... )
64
+ _ = c (ctx , cmd )
65
+ return cmd
66
+ }
67
+
68
+ func (c cmdable ) ACLList (ctx context.Context ) * StringSliceCmd {
69
+ cmd := NewStringSliceCmd (ctx , "acl" , "list" )
70
+ _ = c (ctx , cmd )
71
+ return cmd
72
+ }
73
+
74
+ func (c cmdable ) ACLCat (ctx context.Context ) * StringSliceCmd {
75
+ cmd := NewStringSliceCmd (ctx , "acl" , "cat" )
76
+ _ = c (ctx , cmd )
77
+ return cmd
78
+ }
79
+
80
+ func (c cmdable ) ACLCatArgs (ctx context.Context , options * ACLCatArgs ) * StringSliceCmd {
81
+ // if there is a category passed, build new cmd, if there isn't - use the ACLCat method
82
+ if options != nil && options .Category != "" {
83
+ cmd := NewStringSliceCmd (ctx , "acl" , "cat" , options .Category )
84
+ _ = c (ctx , cmd )
85
+ return cmd
86
+ }
87
+
88
+ return c .ACLCat (ctx )
89
+ }
0 commit comments