Skip to content

Commit 9e14eff

Browse files
committed
Target only suspendable resources when tailing
1 parent b000549 commit 9e14eff

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

internal/auditlog/tail.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ import (
1616
"google.golang.org/grpc/status"
1717
)
1818

19+
var suspendableResourceNames = []string{
20+
"alerts",
21+
"buckets",
22+
"gitrepositories",
23+
"helmcharts",
24+
"helmreleases",
25+
"helmrepositories",
26+
"imagerepositories",
27+
"imageupdateautomations",
28+
"kustomizations",
29+
"ocirepositories",
30+
"providers",
31+
"receivers",
32+
}
33+
1934
func Tail(ctx context.Context, projectID, clusterName string, cb func(*audit.AuditLog) error) error {
2035
client, err := logging.NewClient(ctx)
2136
if err != nil {
@@ -64,7 +79,7 @@ func tailLogs(ctx context.Context, client *logging.Client, projectID, clusterNam
6479
fmt.Sprintf(`log_name="projects/%s/logs/cloudaudit.googleapis.com%%2Factivity"`, projectID),
6580
fmt.Sprintf(`resource.labels.cluster_name="%s"`, clusterName),
6681
`protoPayload."@type"="type.googleapis.com/google.cloud.audit.AuditLog"`,
67-
`protoPayload.methodName=~"io\.fluxcd\.toolkit\..*\.patch"`,
82+
fmt.Sprintf(`protoPayload.methodName=~"io\.fluxcd\.toolkit\..*\.(%s)\.patch"`, strings.Join(suspendableResourceNames, "|")),
6883
`-protoPayload.authenticationInfo.principalEmail=~"system:.*"`,
6984
},
7085
" AND ",

0 commit comments

Comments
 (0)