forked from raystack/frontier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
62 lines (57 loc) · 1.85 KB
/
root.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
53
54
55
56
57
58
59
60
61
62
package cmd
import (
"github.com/MakeNowJust/heredoc"
"github.com/goto/salt/cmdx"
"github.com/spf13/cobra"
cli "github.com/spf13/cobra"
)
func New(cliConfig *Config) *cli.Command {
cmd := &cli.Command{
Use: "shield <command> <subcommand> [flags]",
Short: "A cloud native role-based authorization aware reverse-proxy service",
Long: heredoc.Doc(`
A cloud native role-based authorization aware reverse-proxy service.`),
SilenceUsage: true,
SilenceErrors: true,
Annotations: map[string]string{
"group": "core",
"help:learn": heredoc.Doc(`
Use 'shield <command> <subcommand> --help' for info about a command.
Read the manual at https://goto.github.io/shield/
`),
"help:feedback": heredoc.Doc(`
Open an issue here https://github.com/goto/shield/issues
`),
"help:environment": heredoc.Doc(`
See 'shield help environment' for the list of supported environment variables.
`),
},
}
cmd.PersistentPreRunE = func(subCmd *cobra.Command, args []string) error {
if isClientCLI(subCmd) {
if err := overrideClientConfigHost(subCmd, cliConfig); err != nil {
return err
}
}
return nil
}
cmd.AddCommand(ServerCommand())
cmd.AddCommand(NamespaceCommand(cliConfig))
cmd.AddCommand(UserCommand(cliConfig))
cmd.AddCommand(OrganizationCommand(cliConfig))
cmd.AddCommand(GroupCommand(cliConfig))
cmd.AddCommand(ProjectCommand(cliConfig))
cmd.AddCommand(RoleCommand(cliConfig))
cmd.AddCommand(ActionCommand(cliConfig))
cmd.AddCommand(PolicyCommand(cliConfig))
cmd.AddCommand(configCommand())
cmd.AddCommand(RuleCommand(cliConfig))
cmd.AddCommand(ResourceCommand(cliConfig))
// Help topics
cmdx.SetHelp(cmd)
cmd.AddCommand(cmdx.SetCompletionCmd("shield"))
cmd.AddCommand(cmdx.SetHelpTopicCmd("environment", envHelp))
cmd.AddCommand(cmdx.SetHelpTopicCmd("auth", authHelp))
cmd.AddCommand(cmdx.SetRefCmd(cmd))
return cmd
}