From 64ee62897ba71e340e3074cd7cfc9d6fb8802279 Mon Sep 17 00:00:00 2001 From: Andrea Spacca Date: Thu, 28 Oct 2021 13:40:40 +0200 Subject: [PATCH] not setting queue_url bucket_arn or non_aws_bucket_name returns error (#28666) * not setting queue_url bucket_arn or non_aws_bucket_name returns error (cherry picked from commit 2a1a0ca67c1d005dd3876cc54e1a38428b9cc158) --- x-pack/filebeat/input/awss3/config.go | 4 +--- x-pack/filebeat/input/awss3/config_test.go | 13 ++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/x-pack/filebeat/input/awss3/config.go b/x-pack/filebeat/input/awss3/config.go index d1d4989ead80..5b8308d1771e 100644 --- a/x-pack/filebeat/input/awss3/config.go +++ b/x-pack/filebeat/input/awss3/config.go @@ -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" @@ -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) diff --git a/x-pack/filebeat/input/awss3/config_test.go b/x-pack/filebeat/input/awss3/config_test.go index e7ece7a62693..189ce447ff85 100644 --- a/x-pack/filebeat/input/awss3/config_test.go +++ b/x-pack/filebeat/input/awss3/config_test.go @@ -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",