forked from mantl/consul-cli
/
acl_info.go
52 lines (43 loc) · 1.02 KB
/
acl_info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package commands
import (
"github.com/spf13/cobra"
)
func (a *Acl) AddInfoSub(c *cobra.Command) {
infoCmd := &cobra.Command{
Use: "info <token>",
Short: "Query information about an ACL token",
Long: "Query information about an ACL token",
RunE: func(cmd *cobra.Command, args []string) error {
return a.Info(args)
},
}
oldInfoCmd := &cobra.Command{
Use: "acl-info <token>",
Short: "Query information about an ACL token",
Long: "Query information about an ACL token",
Deprecated: "Use acl info",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
return a.Info(args)
},
}
a.AddTemplateOption(infoCmd)
c.AddCommand(infoCmd)
a.AddCommand(oldInfoCmd)
}
func (a *Acl) Info(args []string) error {
if err := a.CheckIdArg(args); err != nil {
return err
}
id := args[0]
client, err := a.ACL()
if err != nil {
return err
}
queryOpts := a.QueryOptions()
acl, _, err := client.Info(id, queryOpts)
if err != nil {
return err
}
return a.Output(acl)
}