Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>
  • Loading branch information
fjogeleit committed Sep 6, 2024
1 parent 2e8fd3d commit d8da748
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/policy-reporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ image:
registry: ghcr.io
repository: kyverno/policy-reporter
pullPolicy: IfNotPresent
tag: 2e1d691
tag: 2e8fd3d

imagePullSecrets: []

Expand Down
2 changes: 1 addition & 1 deletion pkg/target/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ func (f *TargetFactory) CreateSecurityHubTarget(config, parent *target.Config[ta
config.Config.Endpoint,
)

sugar.Infof("%s configured", config.Name)
zap.L().Info(config.Name+" configured", zap.Bool("cleanup", config.Config.Cleanup))

hub := securityhub.NewClient(securityhub.Options{
ClientOptions: target.ClientOptions{
Expand Down
10 changes: 8 additions & 2 deletions pkg/target/securityhub/securityhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (c *client) Sync(ctx context.Context) error {
if !c.cleanup {
return nil
}
defer zap.L().Info(c.Name() + ": START SYNC")

list, err := c.getFindings(ctx, "")
if err != nil {
Expand All @@ -191,6 +192,7 @@ func (c *client) Sync(ctx context.Context) error {
}

if len(list) == 0 {
zap.L().Info(c.Name() + ": no findings to sync")
return nil
}

Expand All @@ -201,12 +203,14 @@ func (c *client) Sync(ctx context.Context) error {
}
})

_, err = c.batchUpdate(ctx, findings, types.WorkflowStatusResolved)
count, err := c.batchUpdate(ctx, findings, types.WorkflowStatusResolved)
if err != nil {
zap.L().Error("failed to sync findings", zap.Error(err))
zap.L().Error(c.Name()+": failed to sync findings", zap.Error(err))
return err
}

zap.L().Info(c.Name()+": FINISHED SYNC", zap.Int("updated", count))

return nil
}

Expand All @@ -215,6 +219,8 @@ func (c *client) CleanUp(ctx context.Context, report v1alpha2.ReportInterface) {
return
}

zap.L().Info(c.Name()+": start cleanup", zap.String("report", report.GetKey()))

if source := report.GetSource(); source != "" && len(c.BaseClient.Sources()) > 0 {
if !helper.Contains(source, c.BaseClient.Sources()) {
return
Expand Down

0 comments on commit d8da748

Please sign in to comment.