Skip to content

Commit

Permalink
not setting queue_url bucket_arn or non_aws_bucket_name returns error (
Browse files Browse the repository at this point in the history
…#28666) (#28929)

* not setting queue_url bucket_arn or non_aws_bucket_name returns error

(cherry picked from commit 2a1a0ca)

Co-authored-by: Andrea Spacca <andrea.spacca@elastic.co>
  • Loading branch information
mergify[bot] and Andrea Spacca committed Nov 11, 2021
1 parent 67e1f7d commit eb9b4c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 1 addition & 3 deletions x-pack/filebeat/input/awss3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/elastic/beats/v7/libbeat/common/cfgtype"
"github.com/elastic/beats/v7/libbeat/common/match"
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/reader/parser"
"github.com/elastic/beats/v7/libbeat/reader/readfile"
"github.com/elastic/beats/v7/libbeat/reader/readfile/encoding"
Expand Down Expand Up @@ -65,8 +64,7 @@ func (c *config) Validate() error {
}
}
if len(enabled) == 0 {
logp.NewLogger(inputName).Warnf("neither queue_url, bucket_arn, non_aws_bucket_name were provided, input %s will stop", inputName)
return nil
return errors.New("neither queue_url, bucket_arn nor non_aws_bucket_name were provided")
} else if len(enabled) > 1 {
return fmt.Errorf("queue_url <%v>, bucket_arn <%v>, non_aws_bucket_name <%v> "+
"cannot be set at the same time", c.QueueURL, c.BucketARN, c.NonAWSBucketName)
Expand Down
13 changes: 6 additions & 7 deletions x-pack/filebeat/input/awss3/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,17 @@ func TestConfig(t *testing.T) {
},
},
{
"error on no queueURL and s3Bucket",
"error on no queueURL and s3Bucket and nonAWSS3Bucket",
"",
"",
"",
common.MapStr{
"queue_url": "",
"bucket_arn": "",
},
"",
func(queueURL, s3Bucket string, nonAWSS3Bucket string) config {
return makeConfig("", "", "")
"queue_url": "",
"bucket_arn": "",
"non_aws_bucket_name": "",
},
"neither queue_url, bucket_arn nor non_aws_bucket_name were provided",
nil,
},
{
"error on both queueURL and s3Bucket",
Expand Down

0 comments on commit eb9b4c9

Please sign in to comment.