From db3afa4e11f29caa08cd131c80309f66799733fa Mon Sep 17 00:00:00 2001 From: Song Gao Date: Mon, 3 Jun 2024 13:55:08 +0800 Subject: [PATCH] fix: fix influx sink validate (#2893) Signed-off-by: yisaer --- extensions/sinks/influx2/ext/influx2.go | 2 +- extensions/sinks/influx2/ext/influx2_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/sinks/influx2/ext/influx2.go b/extensions/sinks/influx2/ext/influx2.go index 9e915b2b98..33a269ef7e 100644 --- a/extensions/sinks/influx2/ext/influx2.go +++ b/extensions/sinks/influx2/ext/influx2.go @@ -105,7 +105,7 @@ func (m *influxSink2) Configure(props map[string]any) error { default: return fmt.Errorf("precision %s is not supported", m.conf.PrecisionStr) } - if len(m.conf.Measurement) == 0 && m.conf.UseLineProtocol { + if len(m.conf.Measurement) == 0 && !m.conf.UseLineProtocol { return fmt.Errorf("measurement is required") } err = cast.MapToStruct(props, &m.conf.WriteOptions) diff --git a/extensions/sinks/influx2/ext/influx2_test.go b/extensions/sinks/influx2/ext/influx2_test.go index 946be0d8fb..0691d0d48f 100644 --- a/extensions/sinks/influx2/ext/influx2_test.go +++ b/extensions/sinks/influx2/ext/influx2_test.go @@ -116,7 +116,7 @@ func TestConfig(t *testing.T) { "precision": "ns", "useLineProtocol": true, }, - error: "measurement is required", + error: "", }, { name: "no err", @@ -127,7 +127,7 @@ func TestConfig(t *testing.T) { "precision": "ns", "useLineProtocol": false, }, - error: "", + error: "measurement is required", }, { name: "unmarshall error for tls",