-
Notifications
You must be signed in to change notification settings - Fork 11
/
rule-deny.go
36 lines (29 loc) · 1002 Bytes
/
rule-deny.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
package rule
import (
"github.com/airbnb/rudolph/internal/cli/flags"
"github.com/airbnb/rudolph/pkg/clock"
"github.com/airbnb/rudolph/pkg/dynamodb"
"github.com/airbnb/rudolph/pkg/types"
"github.com/spf13/cobra"
)
func init() {
tf := flags.TargetFlags{}
rf := flags.RuleInfoFlags{}
var ruleDenyCmd = &cobra.Command{
Use: "deny <file-path>",
Aliases: []string{"block"},
Short: "Create a rule that applies the Blocklist policy to the specified file",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
// args[0] has already been validated as a file before this
region, _ := cmd.Flags().GetString("region")
table, _ := cmd.Flags().GetString("dynamodb_table")
dynamodbClient := dynamodb.GetClient(table, region)
time := clock.ConcreteTimeProvider{}
return applyPolicyForPath(time, dynamodbClient, types.Blocklist, tf, rf)
},
}
tf.AddTargetFlags(ruleDenyCmd)
rf.AddRuleInfoFlags(ruleDenyCmd)
RuleCmd.AddCommand(ruleDenyCmd)
}