-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
allow_policy.go
42 lines (36 loc) · 1001 Bytes
/
allow_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) newAllowPolicyCommand() *cli.Command {
return &cli.Command{
Name: "allow",
Usage: "Allow a policy file",
Description: `Allow a policy file
e.g.
$ aqua policy allow [<policy file path>]
`,
Action: r.allowPolicyAction,
}
}
func (r *Runner) allowPolicyAction(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, "allow-policy", param); err != nil {
return fmt.Errorf("parse the command line arguments: %w", err)
}
ctrl := controller.InitializeAllowPolicyCommandController(c.Context, param)
return ctrl.Allow(r.LogE, param, c.Args().First()) //nolint:wrapcheck
}