chore(outputs.influxdb)!: Remove deprecated 'url' option (#14916)

This commit is contained in:
Sven Rebhan 2024-02-29 20:30:01 +01:00 committed by GitHub
parent e78b813405
commit 82e4d8b852
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 19 deletions

View File

@ -1062,7 +1062,7 @@ func TestDBRPTagsCreateDatabaseNotCalledOnRetryAfterForbidden(t *testing.T) {
}
output := influxdb.InfluxDB{
URL: u.String(),
URLs: []string{u.String()},
Database: "telegraf",
DatabaseTag: "database",
Log: testutil.Logger{},
@ -1149,7 +1149,7 @@ func TestDBRPTagsCreateDatabaseCalledOnDatabaseNotFound(t *testing.T) {
}
output := influxdb.InfluxDB{
URL: u.String(),
URLs: []string{u.String()},
Database: "telegraf",
DatabaseTag: "database",
Log: testutil.Logger{},
@ -1203,7 +1203,7 @@ func TestDBNotFoundShouldDropMetricWhenSkipDatabaseCreateIsTrue(t *testing.T) {
logger := &testutil.CaptureLogger{}
output := influxdb.InfluxDB{
URL: u.String(),
URLs: []string{u.String()},
Database: "telegraf",
DatabaseTag: "database",
SkipDatabaseCreation: true,

View File

@ -36,7 +36,6 @@ type Client interface {
// InfluxDB struct is the primary data structure for the plugin
type InfluxDB struct {
URL string `toml:"url" deprecated:"0.1.9;1.30.0;use 'urls' instead"`
URLs []string `toml:"urls"`
Username config.Secret `toml:"username"`
Password config.Secret `toml:"password"`
@ -55,16 +54,14 @@ type InfluxDB struct {
ContentEncoding string `toml:"content_encoding"`
SkipDatabaseCreation bool `toml:"skip_database_creation"`
InfluxUintSupport bool `toml:"influx_uint_support"`
Precision string `toml:"precision" deprecated:"1.0.0;option is ignored"`
Log telegraf.Logger `toml:"-"`
tls.ClientConfig
Precision string `toml:"precision" deprecated:"1.0.0;option is ignored"`
clients []Client
CreateHTTPClientF func(config *HTTPConfig) (Client, error)
CreateUDPClientF func(config *UDPConfig) (Client, error)
Log telegraf.Logger
}
func (*InfluxDB) SampleConfig() string {
@ -74,17 +71,11 @@ func (*InfluxDB) SampleConfig() string {
func (i *InfluxDB) Connect() error {
ctx := context.Background()
urls := make([]string, 0, len(i.URLs))
urls = append(urls, i.URLs...)
if i.URL != "" {
urls = append(urls, i.URL)
if len(i.URLs) == 0 {
i.URLs = []string{defaultURL}
}
if len(urls) == 0 {
urls = append(urls, defaultURL)
}
for _, u := range urls {
for _, u := range i.URLs {
parts, err := url.Parse(u)
if err != nil {
return fmt.Errorf("error parsing url [%q]: %w", u, err)

View File

@ -53,8 +53,7 @@ func (c *MockClient) SetLogger(log telegraf.Logger) {
func TestDeprecatedURLSupport(t *testing.T) {
var actual *influxdb.UDPConfig
output := influxdb.InfluxDB{
URL: "udp://localhost:8089",
URLs: []string{"udp://localhost:8089"},
CreateUDPClientF: func(config *influxdb.UDPConfig) (influxdb.Client, error) {
actual = config
return &MockClient{}, nil