/
update_checksum.go
73 lines (62 loc) · 1.89 KB
/
update_checksum.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
63
64
65
66
67
68
69
70
71
72
73
package cli
import (
"fmt"
"net/http"
"github.com/aquaproj/aqua/v2/pkg/config"
"github.com/aquaproj/aqua/v2/pkg/controller"
"github.com/urfave/cli/v2"
)
func (r *Runner) newUpdateChecksumCommand() *cli.Command {
return &cli.Command{
Name: "update-checksum",
Aliases: []string{
"upc",
},
Usage: "Create or Update aqua-checksums.json",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "all",
Aliases: []string{"a"},
Usage: "Create or Update all aqua-checksums.json including global configuration",
},
&cli.BoolFlag{
Name: "deep",
Usage: "This flag was deprecated and had no meaning from aqua v2.0.0. This flag will be removed in aqua v3.0.0. https://github.com/aquaproj/aqua/issues/1769",
},
&cli.BoolFlag{
Name: "prune",
Usage: "Remove unused checksums",
},
},
Description: `Create or Update aqua-checksums.json.
e.g.
$ aqua update-checksum
By default aqua doesn't update aqua-checksums.json of the global configuration.
If you want to update them too,
please set "-a" option.
$ aqua update-checksum -a
By default, aqua update-checksum doesn't remove existing checksums even if they aren't unused.
If -prune option is set, aqua unused checksums would be removed.
$ aqua update-checksum -prune
`,
Action: r.updateChecksumAction,
}
}
func (r *Runner) updateChecksumAction(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, "update-checksum", param); err != nil {
return fmt.Errorf("parse the command line arguments: %w", err)
}
ctrl := controller.InitializeUpdateChecksumCommandController(c.Context, param, http.DefaultClient, r.Runtime)
return ctrl.UpdateChecksum(c.Context, r.LogE, param) //nolint:wrapcheck
}