-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
deny_policy.go
42 lines (36 loc) · 991 Bytes
/
deny_policy.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
package cli //nolint:dupl
import (
"fmt"
"github.com/aquaproj/aqua/v2/pkg/config"
"github.com/aquaproj/aqua/v2/pkg/controller"
"github.com/urfave/cli/v2"
)
func (r *Runner) newDenyPolicyCommand() *cli.Command {
return &cli.Command{
Name: "deny",
Usage: "Deny a policy file",
Description: `Deny a policy file
e.g.
$ aqua policy deny [<policy file path>]
`,
Action: r.denyPolicyAction,
}
}
func (r *Runner) denyPolicyAction(c *cli.Context) error {
tracer, err := startTrace(c.String("trace"))
if err != nil {
return err
}
defer tracer.Stop()
cpuProfiler, err := startCPUProfile(c.String("cpu-profile"))
if err != nil {
return err
}
defer cpuProfiler.Stop()
param := &config.Param{}
if err := r.setParam(c, "deny-policy", param); err != nil {
return fmt.Errorf("parse the command line arguments: %w", err)
}
ctrl := controller.InitializeDenyPolicyCommandController(c.Context, param)
return ctrl.Deny(r.LogE, param, c.Args().First()) //nolint:wrapcheck
}