From 697f7e9e3f94f8f94132f2965bd036267f88f76c Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Mon, 30 Sep 2024 16:25:54 +0200 Subject: [PATCH] fix(config): Correctly print removal version info (#15937) --- config/deprecation.go | 4 ++-- config/deprecation_test.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/config/deprecation.go b/config/deprecation.go index ca06fe5b0..40767b925 100644 --- a/config/deprecation.go +++ b/config/deprecation.go @@ -366,7 +366,7 @@ func PrintOptionDeprecationNotice(plugin, option string, info telegraf.Deprecati prefix := deprecationPrefix(di.logLevel) log.Printf( "%s: Option %q of plugin %q deprecated since version %s and will be removed in %s: %s", - prefix, option, plugin, info.Since, info.RemovalIn, info.Notice, + prefix, option, plugin, di.info.Since, di.info.RemovalIn, di.info.Notice, ) } } @@ -387,7 +387,7 @@ func PrintOptionValueDeprecationNotice(plugin, option string, value interface{}, prefix := deprecationPrefix(di.logLevel) log.Printf( `%s: Value "%+v" for option %q of plugin %q deprecated since version %s and will be removed in %s: %s`, - prefix, value, option, plugin, info.Since, info.RemovalIn, info.Notice, + prefix, value, option, plugin, di.info.Since, di.info.RemovalIn, di.info.Notice, ) } } diff --git a/config/deprecation_test.go b/config/deprecation_test.go index 1a98ac8a9..35cd0965a 100644 --- a/config/deprecation_test.go +++ b/config/deprecation_test.go @@ -106,6 +106,12 @@ func TestPluginOptionDeprecation(t *testing.T) { expectedLevel: telegraf.Warn, expected: `Option "option" of plugin "test" deprecated since version 1.23.0 and will be removed in 2.0.0: please check`, }, + { + name: "No removal info", + since: "1.23.0", + expectedLevel: telegraf.Warn, + expected: `Option "option" of plugin "test" deprecated since version 1.23.0 and will be removed in 2.0.0: please check`, + }, { name: "None", expectedLevel: telegraf.None, @@ -190,6 +196,13 @@ func TestPluginOptionValueDeprecation(t *testing.T) { expected: `Value "foobar" for option "option" of plugin "test" deprecated since version 1.25.0 and will be removed in 2.0.0: please check`, expectedLevel: telegraf.Warn, }, + { + name: "No removal info", + since: "1.25.0", + value: "foobar", + expected: `Value "foobar" for option "option" of plugin "test" deprecated since version 1.25.0 and will be removed in 2.0.0: please check`, + expectedLevel: telegraf.Warn, + }, { name: "None", expected: ``,