-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.go
43 lines (35 loc) · 809 Bytes
/
clean.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
package main
import (
"net/http"
"time"
"github.com/urfave/cli"
s "github.com/webtor-io/cache-keeper/services"
cs "github.com/webtor-io/common-services"
)
func makeCleanCMD() cli.Command {
cleanCmd := cli.Command{
Name: "clean",
Aliases: []string{"c"},
Usage: "cleans cache",
Action: clean,
}
configureClean(&cleanCmd)
return cleanCmd
}
func configureClean(c *cli.Command) {
c.Flags = cs.RegisterS3ClientFlags(c.Flags)
c.Flags = s.RegisterS3StorageFlags(c.Flags)
c.Flags = s.RegisterCleanerFlags(c.Flags)
}
func clean(c *cli.Context) error {
// Setting S3 Client
s3cl := cs.NewS3Client(c, &http.Client{
Timeout: time.Second * 60,
})
// Setting S3 Storage
s3st := s.NewS3Storage(c, s3cl)
// Setting Cleaner
cl := s.NewCleaner(c, s3st)
// Clean!
return cl.Clean()
}