Skip to content

Commit

Permalink
Make Bucket for S3 targets mendatory and don't show error logs (#447)
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <[email protected]>
  • Loading branch information
fjogeleit committed Jun 8, 2024
1 parent 2230842 commit 9a90648
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions pkg/config/target_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,20 +612,18 @@ func (f *TargetFactory) createS3Client(config, parent *S3) target.Client {
return nil
}

setFallback(&config.Bucket, parent.Bucket)
if config.Bucket == "" {
return nil
}

sugar := zap.S()

if err := checkAWSConfig(config.Name, config.AWSConfig, parent.AWSConfig); err != nil {
sugar.Error(err)

return nil
}

setFallback(&config.Bucket, parent.Bucket)
if config.Bucket == "" {
sugar.Errorf("%s.Bucket has not been declared", config.Name)
return nil
}

setFallback(&config.Region, os.Getenv("AWS_REGION"))
setFallback(&config.Prefix, parent.Prefix, "policy-reporter")
setFallback(&config.KmsKeyID, parent.KmsKeyID)
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/target_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func Test_ResolveTargetWithoutHost(t *testing.T) {
}
})
t.Run("GCS.Credentials", func(t *testing.T) {
if len(factory.GCSClients(&config.GCS{Bucket: "policy-reporter"})) != 0 {
if len(factory.GCSClients(&config.GCS{Bucket: "policy-reporter", Credentials: "{}"})) != 0 {
t.Error("Expected Client to be nil if no accessKey is configured")
}
})
Expand Down

0 comments on commit 9a90648

Please sign in to comment.