-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmdList.go
59 lines (51 loc) · 1.48 KB
/
cmdList.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
package commands
import (
"fmt"
"github.com/urfave/cli/v2"
. "github.com/jonhadfield/azwaf/policy"
)
func CmdList() *cli.Command {
return &cli.Command{
Name: "list",
Usage: "list front doors and policies",
Action: func(c *cli.Context) error {
return cli.ShowSubcommandHelp(c)
},
Subcommands: []*cli.Command{
{
Name: "frontdoors",
Usage: "list front doors and associated policies in subscription",
UsageText: "azwaf list frontdoors [--subscription=<AZURE_SUBSCRIPTION_ID>]",
Aliases: []string{"f"},
Action: func(c *cli.Context) error {
if c.String("subscription-id") == "" {
return fmt.Errorf("subscription-id required")
}
return ListFrontDoors(c.String("subscription-id"))
},
},
{
Name: "policies",
Usage: "list all policies in subscription",
Aliases: []string{"p"},
Flags: []cli.Flag{
&cli.BoolFlag{Name: "full", Aliases: []string{"f"}, Usage: "include resource id in output"},
&cli.IntFlag{Name: "top", Aliases: []string{"max"}, Usage: "number of policies to list", Value: MaxPoliciesToFetch},
},
Action: func(c *cli.Context) error {
input := ListPoliciesInput{
SubscriptionID: c.String("subscription-id"),
Full: c.Bool("full"),
Max: c.Int("top"),
}
if err := input.Validate(); err != nil {
// nolint:errcheck
_ = cli.ShowSubcommandHelp(c)
return err
}
return ListPolicies(input)
},
},
},
}
}