From 37b090f092468c52928e1cfc8cfe605170f753e3 Mon Sep 17 00:00:00 2001 From: Cem Deniz Kabakci Date: Thu, 2 May 2024 16:11:16 +0200 Subject: [PATCH] [receiver/cloudfoundryreceiver] Move shardID check to validate in the config Co-authored-by: Jose Riguera Co-authored-by: Sam Clulow --- receiver/cloudfoundryreceiver/config.go | 5 +++++ receiver/cloudfoundryreceiver/stream.go | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/receiver/cloudfoundryreceiver/config.go b/receiver/cloudfoundryreceiver/config.go index f871288aac18..ed38825c2ad5 100644 --- a/receiver/cloudfoundryreceiver/config.go +++ b/receiver/cloudfoundryreceiver/config.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/url" + "strings" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/config/configopaque" @@ -47,6 +48,10 @@ func (c *Config) Validate() error { return err } + if strings.TrimSpace(c.RLPGateway.ShardID) == "" { + return errors.New("shardID cannot be empty") + } + err = validateURLOption("uaa.endpoint", c.UAA.Endpoint) if err != nil { return err diff --git a/receiver/cloudfoundryreceiver/stream.go b/receiver/cloudfoundryreceiver/stream.go index fc86e0569459..2872f8989f92 100644 --- a/receiver/cloudfoundryreceiver/stream.go +++ b/receiver/cloudfoundryreceiver/stream.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "net/http" - "strings" "code.cloudfoundry.org/go-loggregator" "code.cloudfoundry.org/go-loggregator/rpc/loggregator_v2" @@ -49,10 +48,6 @@ func (rgc *EnvelopeStreamFactory) CreateStream( ctx context.Context, shardID string) (loggregator.EnvelopeStream, error) { - if strings.TrimSpace(shardID) == "" { - return nil, errors.New("shardID cannot be empty") - } - stream := rgc.rlpGatewayClient.Stream(ctx, &loggregator_v2.EgressBatchRequest{ ShardId: shardID, Selectors: []*loggregator_v2.Selector{