Skip to content

Commit c790398

Browse files
authored
Refactor cleanup job (#750)
1 parent 5d981e8 commit c790398

File tree

3 files changed

+248
-193
lines changed

3 files changed

+248
-193
lines changed

github-actions/cleanup-packages/cmd/cleanup/main.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import (
44
"GDATACyberDefense/cleanup-packages/internal/cleanup"
55
"context"
66
"fmt"
7-
"os"
8-
97
"github.com/docker/docker/client"
108
"github.com/gofri/go-github-ratelimit/github_ratelimit"
119
"github.com/google/go-github/v66/github"
10+
"os"
1211
)
1312

1413
func main() {
@@ -20,9 +19,19 @@ func main() {
2019
authToken := os.Getenv("PAT_CONTAINER_REGISTRY")
2120
registryUsername := "GdataGithubBot"
2221

23-
github := github.NewClient(rateLimiter).WithAuthToken(authToken)
22+
githubClient := github.NewClient(rateLimiter).WithAuthToken(authToken)
2423
docker, _ := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
25-
context := context.Background()
24+
ctx := context.Background()
2625

27-
cleanup.NewCleanup(github, docker, authToken, registryUsername).Run(context)
26+
dryRun := false
27+
28+
if len(os.Args) > 1 {
29+
switch os.Args[1] {
30+
case "--dry-run":
31+
dryRun = true
32+
default:
33+
panic(fmt.Sprintf("unknown flag: %s", os.Args[0]))
34+
}
35+
}
36+
cleanup.NewCleanup(githubClient, docker, authToken, registryUsername).Run(ctx, dryRun)
2837
}

0 commit comments

Comments
 (0)