chore(outputs.influxdb)!: Remove deprecated 'url' option (#14916)
This commit is contained in:
parent
e78b813405
commit
82e4d8b852
|
|
@ -1062,7 +1062,7 @@ func TestDBRPTagsCreateDatabaseNotCalledOnRetryAfterForbidden(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
output := influxdb.InfluxDB{
|
output := influxdb.InfluxDB{
|
||||||
URL: u.String(),
|
URLs: []string{u.String()},
|
||||||
Database: "telegraf",
|
Database: "telegraf",
|
||||||
DatabaseTag: "database",
|
DatabaseTag: "database",
|
||||||
Log: testutil.Logger{},
|
Log: testutil.Logger{},
|
||||||
|
|
@ -1149,7 +1149,7 @@ func TestDBRPTagsCreateDatabaseCalledOnDatabaseNotFound(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
output := influxdb.InfluxDB{
|
output := influxdb.InfluxDB{
|
||||||
URL: u.String(),
|
URLs: []string{u.String()},
|
||||||
Database: "telegraf",
|
Database: "telegraf",
|
||||||
DatabaseTag: "database",
|
DatabaseTag: "database",
|
||||||
Log: testutil.Logger{},
|
Log: testutil.Logger{},
|
||||||
|
|
@ -1203,7 +1203,7 @@ func TestDBNotFoundShouldDropMetricWhenSkipDatabaseCreateIsTrue(t *testing.T) {
|
||||||
|
|
||||||
logger := &testutil.CaptureLogger{}
|
logger := &testutil.CaptureLogger{}
|
||||||
output := influxdb.InfluxDB{
|
output := influxdb.InfluxDB{
|
||||||
URL: u.String(),
|
URLs: []string{u.String()},
|
||||||
Database: "telegraf",
|
Database: "telegraf",
|
||||||
DatabaseTag: "database",
|
DatabaseTag: "database",
|
||||||
SkipDatabaseCreation: true,
|
SkipDatabaseCreation: true,
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ type Client interface {
|
||||||
|
|
||||||
// InfluxDB struct is the primary data structure for the plugin
|
// InfluxDB struct is the primary data structure for the plugin
|
||||||
type InfluxDB struct {
|
type InfluxDB struct {
|
||||||
URL string `toml:"url" deprecated:"0.1.9;1.30.0;use 'urls' instead"`
|
|
||||||
URLs []string `toml:"urls"`
|
URLs []string `toml:"urls"`
|
||||||
Username config.Secret `toml:"username"`
|
Username config.Secret `toml:"username"`
|
||||||
Password config.Secret `toml:"password"`
|
Password config.Secret `toml:"password"`
|
||||||
|
|
@ -55,16 +54,14 @@ type InfluxDB struct {
|
||||||
ContentEncoding string `toml:"content_encoding"`
|
ContentEncoding string `toml:"content_encoding"`
|
||||||
SkipDatabaseCreation bool `toml:"skip_database_creation"`
|
SkipDatabaseCreation bool `toml:"skip_database_creation"`
|
||||||
InfluxUintSupport bool `toml:"influx_uint_support"`
|
InfluxUintSupport bool `toml:"influx_uint_support"`
|
||||||
tls.ClientConfig
|
|
||||||
|
|
||||||
Precision string `toml:"precision" deprecated:"1.0.0;option is ignored"`
|
Precision string `toml:"precision" deprecated:"1.0.0;option is ignored"`
|
||||||
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
tls.ClientConfig
|
||||||
|
|
||||||
clients []Client
|
clients []Client
|
||||||
|
|
||||||
CreateHTTPClientF func(config *HTTPConfig) (Client, error)
|
CreateHTTPClientF func(config *HTTPConfig) (Client, error)
|
||||||
CreateUDPClientF func(config *UDPConfig) (Client, error)
|
CreateUDPClientF func(config *UDPConfig) (Client, error)
|
||||||
|
|
||||||
Log telegraf.Logger
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*InfluxDB) SampleConfig() string {
|
func (*InfluxDB) SampleConfig() string {
|
||||||
|
|
@ -74,17 +71,11 @@ func (*InfluxDB) SampleConfig() string {
|
||||||
func (i *InfluxDB) Connect() error {
|
func (i *InfluxDB) Connect() error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
urls := make([]string, 0, len(i.URLs))
|
if len(i.URLs) == 0 {
|
||||||
urls = append(urls, i.URLs...)
|
i.URLs = []string{defaultURL}
|
||||||
if i.URL != "" {
|
|
||||||
urls = append(urls, i.URL)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(urls) == 0 {
|
for _, u := range i.URLs {
|
||||||
urls = append(urls, defaultURL)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, u := range urls {
|
|
||||||
parts, err := url.Parse(u)
|
parts, err := url.Parse(u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error parsing url [%q]: %w", u, err)
|
return fmt.Errorf("error parsing url [%q]: %w", u, err)
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,7 @@ func (c *MockClient) SetLogger(log telegraf.Logger) {
|
||||||
func TestDeprecatedURLSupport(t *testing.T) {
|
func TestDeprecatedURLSupport(t *testing.T) {
|
||||||
var actual *influxdb.UDPConfig
|
var actual *influxdb.UDPConfig
|
||||||
output := influxdb.InfluxDB{
|
output := influxdb.InfluxDB{
|
||||||
URL: "udp://localhost:8089",
|
URLs: []string{"udp://localhost:8089"},
|
||||||
|
|
||||||
CreateUDPClientF: func(config *influxdb.UDPConfig) (influxdb.Client, error) {
|
CreateUDPClientF: func(config *influxdb.UDPConfig) (influxdb.Client, error) {
|
||||||
actual = config
|
actual = config
|
||||||
return &MockClient{}, nil
|
return &MockClient{}, nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue