MCPcopy
hub / github.com/dgraph-io/dgraph / initSubcommands

Function initSubcommands

acl/run.go:58–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56}
57
58func initSubcommands() []*x.SubCommand {
59 var cmdAdd x.SubCommand
60 cmdAdd.Cmd = &cobra.Command{
61 Use: "add",
62 Short: "Run Dgraph acl tool to add a user or group",
63 Run: func(cmd *cobra.Command, args []string) {
64 if err := add(cmdAdd.Conf); err != nil {
65 fmt.Printf("%v\n", err)
66 os.Exit(1)
67 }
68 },
69 }
70
71 addFlags := cmdAdd.Cmd.Flags()
72 addFlags.StringP("user", "u", "", "The user id to be created")
73 addFlags.StringP("password", "p", "", "The password for the user")
74 addFlags.StringP("group", "g", "", "The group id to be created")
75
76 var cmdDel x.SubCommand
77 cmdDel.Cmd = &cobra.Command{
78 Use: "del",
79 Short: "Run Dgraph acl tool to delete a user or group",
80 Run: func(cmd *cobra.Command, args []string) {
81 if err := del(cmdDel.Conf); err != nil {
82 fmt.Printf("Unable to delete the user: %v\n", err)
83 os.Exit(1)
84 }
85 },
86 }
87
88 delFlags := cmdDel.Cmd.Flags()
89 delFlags.StringP("user", "u", "", "The user id to be deleted")
90 delFlags.StringP("group", "g", "", "The group id to be deleted")
91
92 var cmdMod x.SubCommand
93 cmdMod.Cmd = &cobra.Command{
94 Use: "mod",
95 Short: "Run Dgraph acl tool to modify a user's password, a user's group list, or a" +
96 "group's predicate permissions",
97 Run: func(cmd *cobra.Command, args []string) {
98 if err := mod(cmdMod.Conf); err != nil {
99 fmt.Printf("Unable to modify: %v\n", err)
100 os.Exit(1)
101 }
102 },
103 }
104
105 modFlags := cmdMod.Cmd.Flags()
106 modFlags.StringP("user", "u", "", "The user id to be changed")
107 modFlags.BoolP("new_password", "n", false, "Whether to reset password for the user")
108 modFlags.StringP("group_list", "l", defaultGroupList,
109 "The list of groups to be set for the user")
110 modFlags.StringP("group", "g", "", "The group whose permission is to be changed")
111 modFlags.StringP("pred", "p", "", "The predicates whose acls are to be changed")
112 modFlags.IntP("perm", "m", 0, "The acl represented using "+
113 "an integer: 4 for read, 2 for write, and 1 for modify. Use a negative value to remove a "+
114 "predicate from the group")
115

Callers 1

initFunction · 0.70

Calls 4

delFunction · 0.85
modFunction · 0.85
infoFunction · 0.85
addFunction · 0.70

Tested by

no test coverage detected