diff --git a/.golangci.yml b/.golangci.yml index f94af874581b0..0c32a4fed62b4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -258,6 +258,9 @@ linters-settings: arguments: [ 3 ] - name: identical-branches - name: if-return + - name: import-alias-naming + arguments: + - "^[a-z][a-z0-9_]*[a-z0-9]+$" - name: import-shadowing - name: increment-decrement - name: indent-error-flow @@ -269,6 +272,7 @@ linters-settings: - name: range-val-in-closure - name: receiver-naming - name: redefines-builtin-id + - name: redundant-import-alias - name: string-of-int - name: struct-tag - name: superfluous-else diff --git a/internal/internal.go b/internal/internal.go index ac966413d231b..1d93fa88e0f43 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -4,7 +4,7 @@ import ( "bufio" "compress/gzip" "context" - cryptoRand "crypto/rand" + crypto_rand "crypto/rand" "errors" "fmt" "io" @@ -94,7 +94,7 @@ func ReadLines(filename string) ([]string, error) { // RandomString returns a random string of alphanumeric characters func RandomString(n int) (string, error) { var bytes = make([]byte, n) - _, err := cryptoRand.Read(bytes) + _, err := crypto_rand.Read(bytes) if err != nil { return "", err } diff --git a/plugins/aggregators/histogram/histogram.go b/plugins/aggregators/histogram/histogram.go index fff10f95933e2..36f00cda8e6d7 100644 --- a/plugins/aggregators/histogram/histogram.go +++ b/plugins/aggregators/histogram/histogram.go @@ -8,7 +8,7 @@ import ( "time" "github.com/influxdata/telegraf" - telegrafConfig "github.com/influxdata/telegraf/config" + telegraf_config "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/plugins/aggregators" ) @@ -29,11 +29,11 @@ const bucketNegInf = "-Inf" // HistogramAggregator is aggregator with histogram configs and particular histograms for defined metrics type HistogramAggregator struct { - Configs []config `toml:"config"` - ResetBuckets bool `toml:"reset"` - Cumulative bool `toml:"cumulative"` - ExpirationInterval telegrafConfig.Duration `toml:"expiration_interval"` - PushOnlyOnUpdate bool `toml:"push_only_on_update"` + Configs []config `toml:"config"` + ResetBuckets bool `toml:"reset"` + Cumulative bool `toml:"cumulative"` + ExpirationInterval telegraf_config.Duration `toml:"expiration_interval"` + PushOnlyOnUpdate bool `toml:"push_only_on_update"` buckets bucketsByMetrics cache map[uint64]metricHistogramCollection diff --git a/plugins/aggregators/histogram/histogram_test.go b/plugins/aggregators/histogram/histogram_test.go index f87cc4584db07..5767bca804eee 100644 --- a/plugins/aggregators/histogram/histogram_test.go +++ b/plugins/aggregators/histogram/histogram_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" "github.com/influxdata/telegraf" - telegrafConfig "github.com/influxdata/telegraf/config" + telegraf_config "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/testutil" ) @@ -26,7 +26,7 @@ func NewTestHistogramWithExpirationInterval( reset bool, cumulative bool, pushOnlyOnUpdate bool, - expirationInterval telegrafConfig.Duration, + expirationInterval telegraf_config.Duration, ) telegraf.Aggregator { htm := NewHistogramAggregator() htm.Configs = cfg @@ -435,7 +435,7 @@ func TestHistogramMetricExpiration(t *testing.T) { {Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}}, {Metric: "second_metric_name", Buckets: []float64{0.0, 4.0, 10.0, 23.0, 30.0}}, } - histogram := NewTestHistogramWithExpirationInterval(cfg, false, true, false, telegrafConfig.Duration(30)) + histogram := NewTestHistogramWithExpirationInterval(cfg, false, true, false, telegraf_config.Duration(30)) acc := &testutil.Accumulator{} diff --git a/plugins/common/aws/credentials.go b/plugins/common/aws/credentials.go index 8d2c36b6e8090..e93f1f226edce 100644 --- a/plugins/common/aws/credentials.go +++ b/plugins/common/aws/credentials.go @@ -3,10 +3,10 @@ package aws import ( "context" - awsV2 "github.com/aws/aws-sdk-go-v2/aws" - configV2 "github.com/aws/aws-sdk-go-v2/config" - credentialsV2 "github.com/aws/aws-sdk-go-v2/credentials" - stscredsV2 "github.com/aws/aws-sdk-go-v2/credentials/stscreds" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/credentials" + "github.com/aws/aws-sdk-go-v2/credentials/stscreds" "github.com/aws/aws-sdk-go-v2/service/sts" ) @@ -24,61 +24,61 @@ type CredentialConfig struct { WebIdentityTokenFile string `toml:"web_identity_token_file"` } -func (c *CredentialConfig) Credentials() (awsV2.Config, error) { +func (c *CredentialConfig) Credentials() (aws.Config, error) { if c.RoleARN != "" { return c.configWithAssumeCredentials() } return c.configWithRootCredentials() } -func (c *CredentialConfig) configWithRootCredentials() (awsV2.Config, error) { - options := []func(*configV2.LoadOptions) error{ - configV2.WithRegion(c.Region), +func (c *CredentialConfig) configWithRootCredentials() (aws.Config, error) { + options := []func(*config.LoadOptions) error{ + config.WithRegion(c.Region), } if c.Profile != "" { - options = append(options, configV2.WithSharedConfigProfile(c.Profile)) + options = append(options, config.WithSharedConfigProfile(c.Profile)) } if c.Filename != "" { - options = append(options, configV2.WithSharedCredentialsFiles([]string{c.Filename})) + options = append(options, config.WithSharedCredentialsFiles([]string{c.Filename})) } if c.AccessKey != "" || c.SecretKey != "" { - provider := credentialsV2.NewStaticCredentialsProvider(c.AccessKey, c.SecretKey, c.Token) - options = append(options, configV2.WithCredentialsProvider(provider)) + provider := credentials.NewStaticCredentialsProvider(c.AccessKey, c.SecretKey, c.Token) + options = append(options, config.WithCredentialsProvider(provider)) } - return configV2.LoadDefaultConfig(context.Background(), options...) + return config.LoadDefaultConfig(context.Background(), options...) } -func (c *CredentialConfig) configWithAssumeCredentials() (awsV2.Config, error) { +func (c *CredentialConfig) configWithAssumeCredentials() (aws.Config, error) { // To generate credentials using assumeRole, we need to create AWS STS client with the default AWS endpoint, defaultConfig, err := c.configWithRootCredentials() if err != nil { - return awsV2.Config{}, err + return aws.Config{}, err } - var provider awsV2.CredentialsProvider + var provider aws.CredentialsProvider stsService := sts.NewFromConfig(defaultConfig) if c.WebIdentityTokenFile != "" { - provider = stscredsV2.NewWebIdentityRoleProvider( + provider = stscreds.NewWebIdentityRoleProvider( stsService, c.RoleARN, - stscredsV2.IdentityTokenFile(c.WebIdentityTokenFile), - func(opts *stscredsV2.WebIdentityRoleOptions) { + stscreds.IdentityTokenFile(c.WebIdentityTokenFile), + func(opts *stscreds.WebIdentityRoleOptions) { if c.RoleSessionName != "" { opts.RoleSessionName = c.RoleSessionName } }, ) } else { - provider = stscredsV2.NewAssumeRoleProvider(stsService, c.RoleARN, func(opts *stscredsV2.AssumeRoleOptions) { + provider = stscreds.NewAssumeRoleProvider(stsService, c.RoleARN, func(opts *stscreds.AssumeRoleOptions) { if c.RoleSessionName != "" { opts.RoleSessionName = c.RoleSessionName } }) } - defaultConfig.Credentials = awsV2.NewCredentialsCache(provider) + defaultConfig.Credentials = aws.NewCredentialsCache(provider) return defaultConfig, nil } diff --git a/plugins/common/http/config.go b/plugins/common/http/config.go index 3f5bfdfa5f4a2..3e050bc634deb 100644 --- a/plugins/common/http/config.go +++ b/plugins/common/http/config.go @@ -12,7 +12,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/plugins/common/cookie" - oauthConfig "github.com/influxdata/telegraf/plugins/common/oauth" + "github.com/influxdata/telegraf/plugins/common/oauth" "github.com/influxdata/telegraf/plugins/common/proxy" "github.com/influxdata/telegraf/plugins/common/tls" ) @@ -27,7 +27,7 @@ type HTTPClientConfig struct { proxy.HTTPProxy tls.ClientConfig - oauthConfig.OAuth2Config + oauth.OAuth2Config cookie.CookieAuthConfig } diff --git a/plugins/common/kafka/config.go b/plugins/common/kafka/config.go index eba22641200c8..0033c13aa06c9 100644 --- a/plugins/common/kafka/config.go +++ b/plugins/common/kafka/config.go @@ -9,7 +9,7 @@ import ( "github.com/IBM/sarama" "github.com/influxdata/telegraf" - tgConf "github.com/influxdata/telegraf/config" + telegraf_config "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/plugins/common/tls" ) @@ -55,16 +55,16 @@ type Config struct { SASLAuth tls.ClientConfig - Version string `toml:"version"` - ClientID string `toml:"client_id"` - CompressionCodec int `toml:"compression_codec"` - EnableTLS *bool `toml:"enable_tls"` - KeepAlivePeriod *tgConf.Duration `toml:"keep_alive_period"` + Version string `toml:"version"` + ClientID string `toml:"client_id"` + CompressionCodec int `toml:"compression_codec"` + EnableTLS *bool `toml:"enable_tls"` + KeepAlivePeriod *telegraf_config.Duration `toml:"keep_alive_period"` - MetadataRetryMax int `toml:"metadata_retry_max"` - MetadataRetryType string `toml:"metadata_retry_type"` - MetadataRetryBackoff tgConf.Duration `toml:"metadata_retry_backoff"` - MetadataRetryMaxDuration tgConf.Duration `toml:"metadata_retry_max_duration"` + MetadataRetryMax int `toml:"metadata_retry_max"` + MetadataRetryType string `toml:"metadata_retry_type"` + MetadataRetryBackoff telegraf_config.Duration `toml:"metadata_retry_backoff"` + MetadataRetryMaxDuration telegraf_config.Duration `toml:"metadata_retry_max_duration"` // Disable full metadata fetching MetadataFull *bool `toml:"metadata_full"` @@ -145,7 +145,7 @@ func (k *Config) SetConfig(config *sarama.Config, log telegraf.Logger) error { return errors.New("invalid metadata retry type") case "exponential": if k.MetadataRetryBackoff == 0 { - k.MetadataRetryBackoff = tgConf.Duration(250 * time.Millisecond) + k.MetadataRetryBackoff = telegraf_config.Duration(250 * time.Millisecond) log.Warnf("metadata_retry_backoff is 0, using %s", time.Duration(k.MetadataRetryBackoff)) } config.Metadata.Retry.BackoffFunc = makeBackoffFunc( diff --git a/plugins/common/proxy/connect.go b/plugins/common/proxy/connect.go index 6c95ddf95e050..d5543854eacff 100644 --- a/plugins/common/proxy/connect.go +++ b/plugins/common/proxy/connect.go @@ -8,12 +8,12 @@ import ( "net/http" "net/url" - netProxy "golang.org/x/net/proxy" + "golang.org/x/net/proxy" ) // httpConnectProxy proxies (only?) TCP over a HTTP tunnel using the CONNECT method type httpConnectProxy struct { - forward netProxy.Dialer + forward proxy.Dialer url *url.URL } @@ -25,7 +25,7 @@ func (c *httpConnectProxy) DialContext(ctx context.Context, network, addr string var proxyConn net.Conn var err error - if dialer, ok := c.forward.(netProxy.ContextDialer); ok { + if dialer, ok := c.forward.(proxy.ContextDialer); ok { proxyConn, err = dialer.DialContext(ctx, "tcp", c.url.Host) } else { shim := contextDialerShim{c.forward} @@ -93,14 +93,14 @@ func (c *httpConnectProxy) Dial(network, addr string) (net.Conn, error) { return c.DialContext(context.Background(), network, addr) } -func newHTTPConnectProxy(proxyURL *url.URL, forward netProxy.Dialer) (netProxy.Dialer, error) { +func newHTTPConnectProxy(proxyURL *url.URL, forward proxy.Dialer) (proxy.Dialer, error) { return &httpConnectProxy{forward, proxyURL}, nil } func init() { // Register new proxy types - netProxy.RegisterDialerType("http", newHTTPConnectProxy) - netProxy.RegisterDialerType("https", newHTTPConnectProxy) + proxy.RegisterDialerType("http", newHTTPConnectProxy) + proxy.RegisterDialerType("https", newHTTPConnectProxy) } // contextDialerShim allows cancellation of the dial from a context even if the underlying @@ -108,7 +108,7 @@ func init() { // unless a new proxy type is added that doesn't implement `proxy.ContextDialer`, as all the // standard library dialers implement `proxy.ContextDialer`. type contextDialerShim struct { - dialer netProxy.Dialer + dialer proxy.Dialer } func (cd *contextDialerShim) Dial(network, addr string) (net.Conn, error) { diff --git a/plugins/common/proxy/dialer.go b/plugins/common/proxy/dialer.go index 844d12ac73596..dd5051b21d7ad 100644 --- a/plugins/common/proxy/dialer.go +++ b/plugins/common/proxy/dialer.go @@ -5,11 +5,11 @@ import ( "net" "time" - netProxy "golang.org/x/net/proxy" + "golang.org/x/net/proxy" ) type ProxiedDialer struct { - dialer netProxy.Dialer + dialer proxy.Dialer } func (pd *ProxiedDialer) Dial(network, addr string) (net.Conn, error) { @@ -17,7 +17,7 @@ func (pd *ProxiedDialer) Dial(network, addr string) (net.Conn, error) { } func (pd *ProxiedDialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) { - if contextDialer, ok := pd.dialer.(netProxy.ContextDialer); ok { + if contextDialer, ok := pd.dialer.(proxy.ContextDialer); ok { return contextDialer.DialContext(ctx, network, addr) } diff --git a/plugins/common/shim/config_test.go b/plugins/common/shim/config_test.go index 6bb80749683e0..f1da99bc28e4e 100644 --- a/plugins/common/shim/config_test.go +++ b/plugins/common/shim/config_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/influxdata/telegraf" - tgConfig "github.com/influxdata/telegraf/config" + telegraf_config "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/processors" ) @@ -61,9 +61,9 @@ func TestLoadingProcessorWithConfig(t *testing.T) { } type testDurationInput struct { - Duration tgConfig.Duration `toml:"duration"` - Size tgConfig.Size `toml:"size"` - Hex int64 `toml:"hex"` + Duration telegraf_config.Duration `toml:"duration"` + Size telegraf_config.Size `toml:"size"` + Hex int64 `toml:"hex"` } func (i *testDurationInput) SampleConfig() string { diff --git a/plugins/common/shim/processor_test.go b/plugins/common/shim/processor_test.go index 83d135d8fc7d8..a0fb4d1f76b17 100644 --- a/plugins/common/shim/processor_test.go +++ b/plugins/common/shim/processor_test.go @@ -13,7 +13,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/plugins/parsers/influx" - influxSerializer "github.com/influxdata/telegraf/plugins/serializers/influx" + influx_serializer "github.com/influxdata/telegraf/plugins/serializers/influx" ) func TestProcessorShim(t *testing.T) { @@ -52,7 +52,7 @@ func testSendAndReceive(t *testing.T, fieldKey string, fieldValue string) { wg.Done() }() - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) parser := influx.Parser{} diff --git a/plugins/common/socket/socket.go b/plugins/common/socket/socket.go index 3582c16eb8713..482301c3c155f 100644 --- a/plugins/common/socket/socket.go +++ b/plugins/common/socket/socket.go @@ -12,7 +12,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" ) type CallbackData func(net.Addr, []byte) @@ -34,7 +34,7 @@ type Config struct { SocketMode string `toml:"socket_mode"` ContentEncoding string `toml:"content_encoding"` MaxDecompressionSize config.Size `toml:"max_decompression_size"` - tlsint.ServerConfig + common_tls.ServerConfig } type Socket struct { diff --git a/plugins/inputs/aerospike/aerospike.go b/plugins/inputs/aerospike/aerospike.go index 22a775b4975fd..44a3819b2cdb8 100644 --- a/plugins/inputs/aerospike/aerospike.go +++ b/plugins/inputs/aerospike/aerospike.go @@ -11,10 +11,10 @@ import ( "sync" "time" - as "github.com/aerospike/aerospike-client-go/v5" + "github.com/aerospike/aerospike-client-go/v5" "github.com/influxdata/telegraf" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -30,7 +30,7 @@ type Aerospike struct { EnableTLS bool `toml:"enable_tls"` EnableSSL bool `toml:"enable_ssl" deprecated:"1.7.0;1.35.0;use 'enable_tls' instead"` TLSName string `toml:"tls_name"` - tlsint.ClientConfig + common_tls.ClientConfig initialized bool tlsConfig *tls.Config @@ -98,11 +98,11 @@ func (a *Aerospike) Gather(acc telegraf.Accumulator) error { } func (a *Aerospike) gatherServer(acc telegraf.Accumulator, hostPort string) error { - policy := as.NewClientPolicy() + policy := aerospike.NewClientPolicy() policy.User = a.Username policy.Password = a.Password policy.TlsConfig = a.tlsConfig - asHosts, err := as.NewHosts(hostPort) + asHosts, err := aerospike.NewHosts(hostPort) if err != nil { return err } @@ -111,11 +111,11 @@ func (a *Aerospike) gatherServer(acc telegraf.Accumulator, hostPort string) erro asHost.TLSName = a.TLSName } } - c, err := as.NewClientWithPolicyAndHost(policy, asHosts...) + c, err := aerospike.NewClientWithPolicyAndHost(policy, asHosts...) if err != nil { return err } - asInfoPolicy := as.NewInfoPolicy() + asInfoPolicy := aerospike.NewInfoPolicy() defer c.Close() nodes := c.GetNodes() @@ -189,7 +189,7 @@ func (a *Aerospike) gatherServer(acc telegraf.Accumulator, hostPort string) erro return nil } -func (a *Aerospike) getNodeInfo(n *as.Node, infoPolicy *as.InfoPolicy) (map[string]string, error) { +func (a *Aerospike) getNodeInfo(n *aerospike.Node, infoPolicy *aerospike.InfoPolicy) (map[string]string, error) { stats, err := n.RequestInfo(infoPolicy, "statistics") if err != nil { return nil, err @@ -216,7 +216,7 @@ func (a *Aerospike) parseNodeInfo(acc telegraf.Accumulator, stats map[string]str acc.AddFields("aerospike_node", nFields, nTags, time.Now()) } -func (a *Aerospike) getNamespaces(n *as.Node, infoPolicy *as.InfoPolicy) ([]string, error) { +func (a *Aerospike) getNamespaces(n *aerospike.Node, infoPolicy *aerospike.InfoPolicy) ([]string, error) { var namespaces []string if len(a.Namespaces) == 0 { info, err := n.RequestInfo(infoPolicy, "namespaces") @@ -231,7 +231,7 @@ func (a *Aerospike) getNamespaces(n *as.Node, infoPolicy *as.InfoPolicy) ([]stri return namespaces, nil } -func (a *Aerospike) getNamespaceInfo(namespace string, n *as.Node, infoPolicy *as.InfoPolicy) (map[string]string, error) { +func (a *Aerospike) getNamespaceInfo(namespace string, n *aerospike.Node, infoPolicy *aerospike.InfoPolicy) (map[string]string, error) { stats, err := n.RequestInfo(infoPolicy, "namespace/"+namespace) if err != nil { return nil, err @@ -259,7 +259,7 @@ func (a *Aerospike) parseNamespaceInfo(acc telegraf.Accumulator, stats map[strin acc.AddFields("aerospike_namespace", nFields, nTags, time.Now()) } -func (a *Aerospike) getSets(n *as.Node, infoPolicy *as.InfoPolicy) ([]string, error) { +func (a *Aerospike) getSets(n *aerospike.Node, infoPolicy *aerospike.InfoPolicy) ([]string, error) { var namespaceSets []string // Gather all sets if len(a.Sets) == 0 { @@ -296,7 +296,7 @@ func (a *Aerospike) getSets(n *as.Node, infoPolicy *as.InfoPolicy) ([]string, er return namespaceSets, nil } -func (a *Aerospike) getSetInfo(namespaceSet string, n *as.Node, infoPolicy *as.InfoPolicy) (map[string]string, error) { +func (a *Aerospike) getSetInfo(namespaceSet string, n *aerospike.Node, infoPolicy *aerospike.InfoPolicy) (map[string]string, error) { stats, err := n.RequestInfo(infoPolicy, "sets/"+namespaceSet) if err != nil { return nil, err @@ -326,7 +326,14 @@ func (a *Aerospike) parseSetInfo(acc telegraf.Accumulator, stats map[string]stri acc.AddFields("aerospike_set", nFields, nTags, time.Now()) } -func (a *Aerospike) getTTLHistogram(acc telegraf.Accumulator, hostPort string, namespace string, set string, n *as.Node, infoPolicy *as.InfoPolicy) error { +func (a *Aerospike) getTTLHistogram( + acc telegraf.Accumulator, + hostPort string, + namespace string, + set string, + n *aerospike.Node, + infoPolicy *aerospike.InfoPolicy, +) error { stats, err := a.getHistogram(namespace, set, "ttl", n, infoPolicy) if err != nil { return err @@ -343,8 +350,8 @@ func (a *Aerospike) getObjectSizeLinearHistogram( hostPort string, namespace string, set string, - n *as.Node, - infoPolicy *as.InfoPolicy, + n *aerospike.Node, + infoPolicy *aerospike.InfoPolicy, ) error { stats, err := a.getHistogram(namespace, set, "object-size-linear", n, infoPolicy) if err != nil { @@ -357,7 +364,13 @@ func (a *Aerospike) getObjectSizeLinearHistogram( return nil } -func (a *Aerospike) getHistogram(namespace string, set string, histogramType string, n *as.Node, infoPolicy *as.InfoPolicy) (map[string]string, error) { +func (a *Aerospike) getHistogram( + namespace string, + set string, + histogramType string, + n *aerospike.Node, + infoPolicy *aerospike.InfoPolicy, +) (map[string]string, error) { var queryArg string if len(set) > 0 { queryArg = fmt.Sprintf("histogram:type=%s;namespace=%v;set=%v", histogramType, namespace, set) diff --git a/plugins/inputs/apcupsd/apcupsd.go b/plugins/inputs/apcupsd/apcupsd.go index 299b973627204..cf5e8c02c9061 100644 --- a/plugins/inputs/apcupsd/apcupsd.go +++ b/plugins/inputs/apcupsd/apcupsd.go @@ -9,7 +9,7 @@ import ( "strings" "time" - apcupsdClient "github.com/mdlayher/apcupsd" + "github.com/mdlayher/apcupsd" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" @@ -97,8 +97,8 @@ func (h *ApcUpsd) Gather(acc telegraf.Accumulator) error { return nil } -func fetchStatus(ctx context.Context, addr *url.URL) (*apcupsdClient.Status, error) { - client, err := apcupsdClient.DialContext(ctx, addr.Scheme, addr.Host) +func fetchStatus(ctx context.Context, addr *url.URL) (*apcupsd.Status, error) { + client, err := apcupsd.DialContext(ctx, addr.Scheme, addr.Host) if err != nil { return nil, err } diff --git a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go index f52533fcba24c..373379eae27a2 100644 --- a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go +++ b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go @@ -16,8 +16,8 @@ import ( "sync" "time" - dialout "github.com/cisco-ie/nx-telemetry-proto/mdt_dialout" - telemetry "github.com/cisco-ie/nx-telemetry-proto/telemetry_bis" + "github.com/cisco-ie/nx-telemetry-proto/mdt_dialout" + "github.com/cisco-ie/nx-telemetry-proto/telemetry_bis" "google.golang.org/grpc" "google.golang.org/grpc/credentials" _ "google.golang.org/grpc/encoding/gzip" // Required to allow gzip encoding @@ -28,7 +28,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/metric" - internaltls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -65,7 +65,7 @@ type CiscoTelemetryMDT struct { Log telegraf.Logger // GRPC TLS settings - internaltls.ServerConfig + common_tls.ServerConfig // Internal listener / client handle grpcServer *grpc.Server @@ -77,13 +77,13 @@ type CiscoTelemetryMDT struct { warned map[string]struct{} extraTags map[string]map[string]struct{} nxpathMap map[string]map[string]string //per path map - propMap map[string]func(field *telemetry.TelemetryField, value interface{}) interface{} + propMap map[string]func(field *telemetry_bis.TelemetryField, value interface{}) interface{} mutex sync.Mutex acc telegraf.Accumulator wg sync.WaitGroup // Though unused in the code, required by protoc-gen-go-grpc to maintain compatibility - dialout.UnimplementedGRPCMdtDialoutServer + mdtdialout.UnimplementedGRPCMdtDialoutServer } type NxPayloadXfromStructure struct { @@ -107,7 +107,7 @@ func (c *CiscoTelemetryMDT) Start(acc telegraf.Accumulator) error { return err } - c.propMap = make(map[string]func(field *telemetry.TelemetryField, value interface{}) interface{}, 100) + c.propMap = make(map[string]func(field *telemetry_bis.TelemetryField, value interface{}) interface{}, 100) c.propMap["test"] = nxosValueXformUint64Toint64 c.propMap["asn"] = nxosValueXformUint64ToString //uint64 to string. c.propMap["subscriptionId"] = nxosValueXformUint64ToString //uint64 to string. @@ -200,7 +200,7 @@ func (c *CiscoTelemetryMDT) Start(acc telegraf.Accumulator) error { } c.grpcServer = grpc.NewServer(opts...) - dialout.RegisterGRPCMdtDialoutServer(c.grpcServer, c) + mdtdialout.RegisterGRPCMdtDialoutServer(c.grpcServer, c) c.wg.Add(1) go func() { @@ -312,7 +312,7 @@ func (c *CiscoTelemetryMDT) handleTCPClient(conn net.Conn) error { } // MdtDialout RPC server method for grpc-dialout transport -func (c *CiscoTelemetryMDT) MdtDialout(stream dialout.GRPCMdtDialout_MdtDialoutServer) error { +func (c *CiscoTelemetryMDT) MdtDialout(stream mdtdialout.GRPCMdtDialout_MdtDialoutServer) error { peerInCtx, peerOK := peer.FromContext(stream.Context()) if peerOK { c.Log.Debugf("Accepted Cisco MDT GRPC dialout connection from %s", peerInCtx.Addr) @@ -357,7 +357,7 @@ func (c *CiscoTelemetryMDT) MdtDialout(stream dialout.GRPCMdtDialout_MdtDialoutS // Handle telemetry packet from any transport, decode and add as measurement func (c *CiscoTelemetryMDT) handleTelemetry(data []byte) { - msg := &telemetry.Telemetry{} + msg := &telemetry_bis.Telemetry{} err := proto.Unmarshal(data, msg) if err != nil { c.acc.AddError(fmt.Errorf("failed to decode: %w: %s", err, msg.String())) @@ -378,7 +378,7 @@ func (c *CiscoTelemetryMDT) handleTelemetry(data []byte) { timestamp := time.Unix(int64(measured/1000), int64(measured%1000)*1000000) // Find toplevel GPBKV fields "keys" and "content" - var keys, content *telemetry.TelemetryField = nil, nil + var keys, content *telemetry_bis.TelemetryField = nil, nil for _, field := range gpbkv.Fields { if field.Name == "keys" { keys = field @@ -448,54 +448,54 @@ func (c *CiscoTelemetryMDT) handleTelemetry(data []byte) { } } -func decodeValue(field *telemetry.TelemetryField) interface{} { +func decodeValue(field *telemetry_bis.TelemetryField) interface{} { switch val := field.ValueByType.(type) { - case *telemetry.TelemetryField_BytesValue: + case *telemetry_bis.TelemetryField_BytesValue: return val.BytesValue - case *telemetry.TelemetryField_StringValue: + case *telemetry_bis.TelemetryField_StringValue: if len(val.StringValue) > 0 { return val.StringValue } - case *telemetry.TelemetryField_BoolValue: + case *telemetry_bis.TelemetryField_BoolValue: return val.BoolValue - case *telemetry.TelemetryField_Uint32Value: + case *telemetry_bis.TelemetryField_Uint32Value: return val.Uint32Value - case *telemetry.TelemetryField_Uint64Value: + case *telemetry_bis.TelemetryField_Uint64Value: return val.Uint64Value - case *telemetry.TelemetryField_Sint32Value: + case *telemetry_bis.TelemetryField_Sint32Value: return val.Sint32Value - case *telemetry.TelemetryField_Sint64Value: + case *telemetry_bis.TelemetryField_Sint64Value: return val.Sint64Value - case *telemetry.TelemetryField_DoubleValue: + case *telemetry_bis.TelemetryField_DoubleValue: return val.DoubleValue - case *telemetry.TelemetryField_FloatValue: + case *telemetry_bis.TelemetryField_FloatValue: return val.FloatValue } return nil } -func decodeTag(field *telemetry.TelemetryField) string { +func decodeTag(field *telemetry_bis.TelemetryField) string { switch val := field.ValueByType.(type) { - case *telemetry.TelemetryField_BytesValue: + case *telemetry_bis.TelemetryField_BytesValue: return string(val.BytesValue) - case *telemetry.TelemetryField_StringValue: + case *telemetry_bis.TelemetryField_StringValue: return val.StringValue - case *telemetry.TelemetryField_BoolValue: + case *telemetry_bis.TelemetryField_BoolValue: if val.BoolValue { return "true" } return "false" - case *telemetry.TelemetryField_Uint32Value: + case *telemetry_bis.TelemetryField_Uint32Value: return strconv.FormatUint(uint64(val.Uint32Value), 10) - case *telemetry.TelemetryField_Uint64Value: + case *telemetry_bis.TelemetryField_Uint64Value: return strconv.FormatUint(val.Uint64Value, 10) - case *telemetry.TelemetryField_Sint32Value: + case *telemetry_bis.TelemetryField_Sint32Value: return strconv.FormatInt(int64(val.Sint32Value), 10) - case *telemetry.TelemetryField_Sint64Value: + case *telemetry_bis.TelemetryField_Sint64Value: return strconv.FormatInt(val.Sint64Value, 10) - case *telemetry.TelemetryField_DoubleValue: + case *telemetry_bis.TelemetryField_DoubleValue: return strconv.FormatFloat(val.DoubleValue, 'f', -1, 64) - case *telemetry.TelemetryField_FloatValue: + case *telemetry_bis.TelemetryField_FloatValue: return strconv.FormatFloat(float64(val.FloatValue), 'f', -1, 32) default: return "" @@ -503,7 +503,7 @@ func decodeTag(field *telemetry.TelemetryField) string { } // Recursively parse tag fields -func (c *CiscoTelemetryMDT) parseKeyField(tags map[string]string, field *telemetry.TelemetryField, prefix string) { +func (c *CiscoTelemetryMDT) parseKeyField(tags map[string]string, field *telemetry_bis.TelemetryField, prefix string) { localname := strings.ReplaceAll(field.Name, "-", "_") name := localname if len(localname) == 0 { @@ -525,7 +525,7 @@ func (c *CiscoTelemetryMDT) parseKeyField(tags map[string]string, field *telemet } } -func (c *CiscoTelemetryMDT) parseRib(grouper *metric.SeriesGrouper, field *telemetry.TelemetryField, +func (c *CiscoTelemetryMDT) parseRib(grouper *metric.SeriesGrouper, field *telemetry_bis.TelemetryField, encodingPath string, tags map[string]string, timestamp time.Time) { // RIB measurement := encodingPath @@ -558,10 +558,10 @@ func (c *CiscoTelemetryMDT) parseRib(grouper *metric.SeriesGrouper, field *telem } } -func (c *CiscoTelemetryMDT) parseMicroburst(grouper *metric.SeriesGrouper, field *telemetry.TelemetryField, +func (c *CiscoTelemetryMDT) parseMicroburst(grouper *metric.SeriesGrouper, field *telemetry_bis.TelemetryField, encodingPath string, tags map[string]string, timestamp time.Time) { - var nxMicro *telemetry.TelemetryField - var nxMicro1 *telemetry.TelemetryField + var nxMicro *telemetry_bis.TelemetryField + var nxMicro1 *telemetry_bis.TelemetryField // Microburst measurement := encodingPath if len(field.Fields) > 3 { @@ -600,10 +600,10 @@ func (c *CiscoTelemetryMDT) parseMicroburst(grouper *metric.SeriesGrouper, field } } -func (c *CiscoTelemetryMDT) parseClassAttributeField(grouper *metric.SeriesGrouper, field *telemetry.TelemetryField, +func (c *CiscoTelemetryMDT) parseClassAttributeField(grouper *metric.SeriesGrouper, field *telemetry_bis.TelemetryField, encodingPath string, tags map[string]string, timestamp time.Time) { // DME structure: https://developer.cisco.com/site/nxapi-dme-model-reference-api/ - var nxAttributes *telemetry.TelemetryField + var nxAttributes *telemetry_bis.TelemetryField isDme := strings.Contains(encodingPath, "sys/") if encodingPath == "rib" { //handle native data path rib @@ -649,7 +649,7 @@ func (c *CiscoTelemetryMDT) getMeasurementName(encodingPath string) string { return measurement } -func (c *CiscoTelemetryMDT) parseContentField(grouper *metric.SeriesGrouper, field *telemetry.TelemetryField, prefix string, +func (c *CiscoTelemetryMDT) parseContentField(grouper *metric.SeriesGrouper, field *telemetry_bis.TelemetryField, prefix string, encodingPath string, tags map[string]string, timestamp time.Time) { name := strings.ReplaceAll(field.Name, "-", "_") @@ -682,7 +682,7 @@ func (c *CiscoTelemetryMDT) parseContentField(grouper *metric.SeriesGrouper, fie } } - var nxAttributes, nxChildren, nxRows *telemetry.TelemetryField + var nxAttributes, nxChildren, nxRows *telemetry_bis.TelemetryField isNXOS := !strings.ContainsRune(encodingPath, ':') // IOS-XR and IOS-XE have a colon in their encoding path, NX-OS does not isEVENT := isNXOS && strings.Contains(encodingPath, "EVENT-LIST") nxChildren = nil diff --git a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go index 841172f18568f..4fb1a6789614a 100644 --- a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go +++ b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" - dialout "github.com/cisco-ie/nx-telemetry-proto/mdt_dialout" - telemetryBis "github.com/cisco-ie/nx-telemetry-proto/telemetry_bis" + "github.com/cisco-ie/nx-telemetry-proto/mdt_dialout" + "github.com/cisco-ie/nx-telemetry-proto/telemetry_bis" "github.com/stretchr/testify/require" "google.golang.org/grpc" "google.golang.org/grpc/connectivity" @@ -36,55 +36,55 @@ func TestHandleTelemetryTwoSimple(t *testing.T) { // error is expected since we are passing in dummy transport require.Error(t, err) - telemetry := &telemetryBis.Telemetry{ + telemetry := &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: "type:model/some/path", - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "name", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "str"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "str"}, }, { Name: "uint64", - ValueByType: &telemetryBis.TelemetryField_Uint64Value{Uint64Value: 1234}, + ValueByType: &telemetry_bis.TelemetryField_Uint64Value{Uint64Value: 1234}, }, }, }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "bool", - ValueByType: &telemetryBis.TelemetryField_BoolValue{BoolValue: true}, + ValueByType: &telemetry_bis.TelemetryField_BoolValue{BoolValue: true}, }, }, }, }, }, { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "name", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "str2"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "str2"}, }, }, }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "bool", - ValueByType: &telemetryBis.TelemetryField_BoolValue{BoolValue: false}, + ValueByType: &telemetry_bis.TelemetryField_BoolValue{BoolValue: false}, }, }, }, @@ -142,55 +142,55 @@ func TestIncludeDeleteField(t *testing.T) { stateKey := "state" testCases := []struct { - telemetry *telemetryBis.Telemetry + telemetry *telemetry_bis.Telemetry expected []telegraf.Metric }{{ - telemetry: &telemetryBis.Telemetry{ + telemetry: &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: encodingPath.stringValue, - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: source.stringValue}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: subscription.stringValue}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: source.stringValue}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: subscription.stringValue}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: name.name, - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: name.stringValue}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: name.stringValue}, }, { Name: index.name, - ValueByType: &telemetryBis.TelemetryField_Uint32Value{Uint32Value: index.uint32Value}, + ValueByType: &telemetry_bis.TelemetryField_Uint32Value{Uint32Value: index.uint32Value}, }, { Name: ip.name, - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: ip.stringValue}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: ip.stringValue}, }, }, }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: stateKey, - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: ip.name, - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: ip.stringValue}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: ip.stringValue}, }, { Name: prefixLength.name, - ValueByType: &telemetryBis.TelemetryField_Uint32Value{Uint32Value: prefixLength.uint32Value}, + ValueByType: &telemetry_bis.TelemetryField_Uint32Value{Uint32Value: prefixLength.uint32Value}, }, { Name: origin.name, - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: origin.stringValue}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: origin.stringValue}, }, { Name: status.name, - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: status.stringValue}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: status.stringValue}, }, }, }, @@ -222,29 +222,29 @@ func TestIncludeDeleteField(t *testing.T) { )}, }, { - telemetry: &telemetryBis.Telemetry{ + telemetry: &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: encodingPath.stringValue, - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: source.stringValue}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: subscription.stringValue}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: source.stringValue}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: subscription.stringValue}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { Delete: true, - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: name.name, - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: name.stringValue}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: name.stringValue}, }, { Name: index.name, - ValueByType: &telemetryBis.TelemetryField_Uint32Value{Uint32Value: index.uint32Value}, + ValueByType: &telemetry_bis.TelemetryField_Uint32Value{Uint32Value: index.uint32Value}, }, { Name: ip.name, - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: ip.stringValue}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: ip.stringValue}, }, }, }, @@ -299,26 +299,26 @@ func TestHandleTelemetrySingleNested(t *testing.T) { // error is expected since we are passing in dummy transport require.Error(t, err) - telemetry := &telemetryBis.Telemetry{ + telemetry := &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: "type:model/nested/path", - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "nested", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "key", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "level", - ValueByType: &telemetryBis.TelemetryField_DoubleValue{DoubleValue: 3}, + ValueByType: &telemetry_bis.TelemetryField_DoubleValue{DoubleValue: 3}, }, }, }, @@ -328,16 +328,16 @@ func TestHandleTelemetrySingleNested(t *testing.T) { }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "nested", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "value", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "foo", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "bar"}, }, }, }, @@ -376,49 +376,49 @@ func TestHandleEmbeddedTags(t *testing.T) { // error is expected since we are passing in dummy transport require.Error(t, err) - telemetry := &telemetryBis.Telemetry{ + telemetry := &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: "type:model/extra", - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "foo", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "bar"}, }, }, }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "list", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "name", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "entry1"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "entry1"}, }, { Name: "test", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "foo"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "foo"}, }, }, }, { Name: "list", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "name", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "entry2"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "entry2"}, }, { Name: "test", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "bar"}, }, }, }, @@ -464,57 +464,57 @@ func TestHandleNXAPI(t *testing.T) { // error is expected since we are passing in dummy transport require.Error(t, err) - telemetry := &telemetryBis.Telemetry{ + telemetry := &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: "show nxapi", - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "foo", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "bar"}, }, }, }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "TABLE_nxapi", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "ROW_nxapi", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "index", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "i1"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "i1"}, }, { Name: "value", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "foo"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "foo"}, }, }, }, { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "index", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "i2"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "i2"}, }, { Name: "value", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "bar"}, }, }, }, @@ -571,45 +571,45 @@ func TestHandleNXAPIXformNXAPI(t *testing.T) { // error is expected since we are passing in dummy transport require.Error(t, err) - telemetry := &telemetryBis.Telemetry{ + telemetry := &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: "show processes cpu", - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "foo", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "bar"}, }, }, }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "TABLE_process_cpu", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "ROW_process_cpu", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "index", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "i1"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "i1"}, }, { Name: "value", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "foo"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "foo"}, }, }, }, @@ -655,57 +655,57 @@ func TestHandleNXXformMulti(t *testing.T) { // error is expected since we are passing in dummy transport require.Error(t, err) - telemetry := &telemetryBis.Telemetry{ + telemetry := &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: "sys/lldp", - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "foo", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "bar"}, }, }, }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "fooEntity", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "attributes", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "rn", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "some-rn"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "some-rn"}, }, { Name: "portIdV", - ValueByType: &telemetryBis.TelemetryField_Uint32Value{Uint32Value: 12}, + ValueByType: &telemetry_bis.TelemetryField_Uint32Value{Uint32Value: 12}, }, { Name: "portDesc", - ValueByType: &telemetryBis.TelemetryField_Uint64Value{Uint64Value: 100}, + ValueByType: &telemetry_bis.TelemetryField_Uint64Value{Uint64Value: 100}, }, { Name: "test", - ValueByType: &telemetryBis.TelemetryField_Uint64Value{Uint64Value: 281474976710655}, + ValueByType: &telemetry_bis.TelemetryField_Uint64Value{Uint64Value: 281474976710655}, }, { Name: "subscriptionId", - ValueByType: &telemetryBis.TelemetryField_Uint64Value{Uint64Value: 2814749767106551}, + ValueByType: &telemetry_bis.TelemetryField_Uint64Value{Uint64Value: 2814749767106551}, }, }, }, @@ -748,45 +748,45 @@ func TestHandleNXDME(t *testing.T) { // error is expected since we are passing in dummy transport require.Error(t, err) - telemetry := &telemetryBis.Telemetry{ + telemetry := &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: "sys/dme", - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "foo", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "bar"}, }, }, }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "fooEntity", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "attributes", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "rn", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "some-rn"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "some-rn"}, }, { Name: "value", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "foo"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "foo"}, }, }, }, @@ -852,13 +852,13 @@ func TestTCPDialoutOverflow(t *testing.T) { require.Contains(t, acc.Errors, errors.New("dialout packet too long: 1000000000")) } -func mockTelemetryMicroburstMessage() *telemetryBis.Telemetry { +func mockTelemetryMicroburstMessage() *telemetry_bis.Telemetry { data, err := os.ReadFile("./testdata/microburst") if err != nil { panic(err) } - newMessage := &telemetryBis.Telemetry{} + newMessage := &telemetry_bis.Telemetry{} err = proto.Unmarshal(data, newMessage) if err != nil { panic(err) @@ -866,30 +866,30 @@ func mockTelemetryMicroburstMessage() *telemetryBis.Telemetry { return newMessage } -func mockTelemetryMessage() *telemetryBis.Telemetry { - return &telemetryBis.Telemetry{ +func mockTelemetryMessage() *telemetry_bis.Telemetry { + return &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: "type:model/some/path", - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "name", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "str"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "str"}, }, }, }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "value", - ValueByType: &telemetryBis.TelemetryField_Sint64Value{Sint64Value: -1}, + ValueByType: &telemetry_bis.TelemetryField_Sint64Value{Sint64Value: -1}, }, }, }, @@ -1049,11 +1049,11 @@ func TestGRPCDialoutError(t *testing.T) { addr := c.Address() conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) - client := dialout.NewGRPCMdtDialoutClient(conn) + client := mdtdialout.NewGRPCMdtDialoutClient(conn) stream, err := client.MdtDialout(context.Background()) require.NoError(t, err) - args := &dialout.MdtDialoutArgs{Errors: "foobar"} + args := &mdtdialout.MdtDialoutArgs{Errors: "foobar"} require.NoError(t, stream.Send(args)) // Wait for the server to close @@ -1084,28 +1084,28 @@ func TestGRPCDialoutMultiple(t *testing.T) { conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) require.True(t, conn.WaitForStateChange(context.Background(), connectivity.Connecting)) - client := dialout.NewGRPCMdtDialoutClient(conn) + client := mdtdialout.NewGRPCMdtDialoutClient(conn) stream, err := client.MdtDialout(context.TODO()) require.NoError(t, err) data, err := proto.Marshal(telemetry) require.NoError(t, err) - args := &dialout.MdtDialoutArgs{Data: data, ReqId: 456} + args := &mdtdialout.MdtDialoutArgs{Data: data, ReqId: 456} require.NoError(t, stream.Send(args)) conn2, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) require.True(t, conn.WaitForStateChange(context.Background(), connectivity.Connecting)) - client2 := dialout.NewGRPCMdtDialoutClient(conn2) + client2 := mdtdialout.NewGRPCMdtDialoutClient(conn2) stream2, err := client2.MdtDialout(context.TODO()) require.NoError(t, err) telemetry.EncodingPath = "type:model/parallel/path" data, err = proto.Marshal(telemetry) require.NoError(t, err) - args = &dialout.MdtDialoutArgs{Data: data} + args = &mdtdialout.MdtDialoutArgs{Data: data} require.NoError(t, stream2.Send(args)) - require.NoError(t, stream2.Send(&dialout.MdtDialoutArgs{Errors: "testclose"})) + require.NoError(t, stream2.Send(&mdtdialout.MdtDialoutArgs{Errors: "testclose"})) _, err = stream2.Recv() require.True(t, err == nil || errors.Is(err, io.EOF)) require.NoError(t, conn2.Close()) @@ -1113,9 +1113,9 @@ func TestGRPCDialoutMultiple(t *testing.T) { telemetry.EncodingPath = "type:model/other/path" data, err = proto.Marshal(telemetry) require.NoError(t, err) - args = &dialout.MdtDialoutArgs{Data: data} + args = &mdtdialout.MdtDialoutArgs{Data: data} require.NoError(t, stream.Send(args)) - require.NoError(t, stream.Send(&dialout.MdtDialoutArgs{Errors: "testclose"})) + require.NoError(t, stream.Send(&mdtdialout.MdtDialoutArgs{Errors: "testclose"})) _, err = stream.Recv() require.True(t, err == nil || errors.Is(err, io.EOF)) @@ -1169,14 +1169,14 @@ func TestGRPCDialoutKeepalive(t *testing.T) { addr := c.Address() conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) - client := dialout.NewGRPCMdtDialoutClient(conn) + client := mdtdialout.NewGRPCMdtDialoutClient(conn) stream, err := client.MdtDialout(context.Background()) require.NoError(t, err) telemetry := mockTelemetryMessage() data, err := proto.Marshal(telemetry) require.NoError(t, err) - args := &dialout.MdtDialoutArgs{Data: data, ReqId: 456} + args := &mdtdialout.MdtDialoutArgs{Data: data, ReqId: 456} require.NoError(t, stream.Send(args)) c.Stop() @@ -1195,29 +1195,29 @@ func TestSourceFieldRewrite(t *testing.T) { // error is expected since we are passing in dummy transport require.Error(t, err) - telemetry := &telemetryBis.Telemetry{ + telemetry := &telemetry_bis.Telemetry{ MsgTimestamp: 1543236572000, EncodingPath: "type:model/some/path", - NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, - Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, - DataGpbkv: []*telemetryBis.TelemetryField{ + NodeId: &telemetry_bis.Telemetry_NodeIdStr{NodeIdStr: "hostname"}, + Subscription: &telemetry_bis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"}, + DataGpbkv: []*telemetry_bis.TelemetryField{ { - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "keys", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "source", - ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "str"}, + ValueByType: &telemetry_bis.TelemetryField_StringValue{StringValue: "str"}, }, }, }, { Name: "content", - Fields: []*telemetryBis.TelemetryField{ + Fields: []*telemetry_bis.TelemetryField{ { Name: "bool", - ValueByType: &telemetryBis.TelemetryField_BoolValue{BoolValue: false}, + ValueByType: &telemetry_bis.TelemetryField_BoolValue{BoolValue: false}, }, }, }, diff --git a/plugins/inputs/cloud_pubsub_push/cloud_pubsub_push.go b/plugins/inputs/cloud_pubsub_push/cloud_pubsub_push.go index ff797520c44af..3634f9f834e95 100644 --- a/plugins/inputs/cloud_pubsub_push/cloud_pubsub_push.go +++ b/plugins/inputs/cloud_pubsub_push/cloud_pubsub_push.go @@ -15,7 +15,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -42,7 +42,7 @@ type PubSubPush struct { MaxUndeliveredMessages int `toml:"max_undelivered_messages"` - tlsint.ServerConfig + common_tls.ServerConfig telegraf.Parser server *http.Server diff --git a/plugins/inputs/cloudwatch/cloudwatch.go b/plugins/inputs/cloudwatch/cloudwatch.go index b7eb3310b144f..9ba983388ed5e 100644 --- a/plugins/inputs/cloudwatch/cloudwatch.go +++ b/plugins/inputs/cloudwatch/cloudwatch.go @@ -14,7 +14,7 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - cwClient "github.com/aws/aws-sdk-go-v2/service/cloudwatch" + "github.com/aws/aws-sdk-go-v2/service/cloudwatch" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" "github.com/influxdata/telegraf" @@ -22,9 +22,9 @@ import ( "github.com/influxdata/telegraf/filter" "github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/internal/limiter" - internalMetric "github.com/influxdata/telegraf/metric" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" - internalProxy "github.com/influxdata/telegraf/plugins/common/proxy" + telegraf_metric "github.com/influxdata/telegraf/metric" + common_aws "github.com/influxdata/telegraf/plugins/common/aws" + common_proxy "github.com/influxdata/telegraf/plugins/common/proxy" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -37,7 +37,7 @@ type CloudWatch struct { StatisticInclude []string `toml:"statistic_include"` Timeout config.Duration `toml:"timeout"` - internalProxy.HTTPProxy + common_proxy.HTTPProxy Period config.Duration `toml:"period"` Delay config.Duration `toml:"delay"` @@ -59,7 +59,7 @@ type CloudWatch struct { windowStart time.Time windowEnd time.Time - internalaws.CredentialConfig + common_aws.CredentialConfig } // Metric defines a simplified Cloudwatch metric. @@ -86,8 +86,8 @@ type metricCache struct { } type cloudwatchClient interface { - ListMetrics(context.Context, *cwClient.ListMetricsInput, ...func(*cwClient.Options)) (*cwClient.ListMetricsOutput, error) - GetMetricData(context.Context, *cwClient.GetMetricDataInput, ...func(*cwClient.Options)) (*cwClient.GetMetricDataOutput, error) + ListMetrics(context.Context, *cloudwatch.ListMetricsInput, ...func(*cloudwatch.Options)) (*cloudwatch.ListMetricsOutput, error) + GetMetricData(context.Context, *cloudwatch.GetMetricDataInput, ...func(*cloudwatch.Options)) (*cloudwatch.GetMetricDataOutput, error) } func (*CloudWatch) SampleConfig() string { @@ -188,7 +188,7 @@ func (c *CloudWatch) initializeCloudWatch() error { return err } - c.client = cwClient.NewFromConfig(awsCreds, func(options *cwClient.Options) { + c.client = cloudwatch.NewFromConfig(awsCreds, func(options *cloudwatch.Options) { if c.CredentialConfig.EndpointURL != "" && c.CredentialConfig.Region != "" { options.BaseEndpoint = &c.CredentialConfig.EndpointURL } @@ -327,7 +327,7 @@ func (c *CloudWatch) fetchNamespaceMetrics() ([]types.Metric, []string) { metrics := []types.Metric{} var accounts []string for _, namespace := range c.Namespaces { - params := &cwClient.ListMetricsInput{ + params := &cloudwatch.ListMetricsInput{ Dimensions: []types.DimensionFilter{}, Namespace: aws.String(namespace), IncludeLinkedAccounts: &c.IncludeLinkedAccounts, @@ -436,7 +436,7 @@ func (c *CloudWatch) getDataQueries(filteredMetrics []filteredMetric) map[string // gatherMetrics gets metric data from Cloudwatch. func (c *CloudWatch) gatherMetrics( - params *cwClient.GetMetricDataInput, + params *cloudwatch.GetMetricDataInput, ) ([]types.MetricDataResult, error) { results := []types.MetricDataResult{} @@ -457,7 +457,7 @@ func (c *CloudWatch) gatherMetrics( } func (c *CloudWatch) aggregateMetrics(acc telegraf.Accumulator, metricDataResults map[string][]types.MetricDataResult) { - grouper := internalMetric.NewSeriesGrouper() + grouper := telegraf_metric.NewSeriesGrouper() for namespace, results := range metricDataResults { namespace = sanitizeMeasurement(namespace) @@ -532,8 +532,8 @@ func ctod(cDimensions []types.Dimension) *map[string]string { return &dimensions } -func (c *CloudWatch) getDataInputs(dataQueries []types.MetricDataQuery) *cwClient.GetMetricDataInput { - return &cwClient.GetMetricDataInput{ +func (c *CloudWatch) getDataInputs(dataQueries []types.MetricDataQuery) *cloudwatch.GetMetricDataInput { + return &cloudwatch.GetMetricDataInput{ StartTime: aws.Time(c.windowStart), EndTime: aws.Time(c.windowEnd), MetricDataQueries: dataQueries, diff --git a/plugins/inputs/cloudwatch/cloudwatch_test.go b/plugins/inputs/cloudwatch/cloudwatch_test.go index d80b057a1bf01..cfcfad655df9b 100644 --- a/plugins/inputs/cloudwatch/cloudwatch_test.go +++ b/plugins/inputs/cloudwatch/cloudwatch_test.go @@ -8,13 +8,13 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - cwClient "github.com/aws/aws-sdk-go-v2/service/cloudwatch" + "github.com/aws/aws-sdk-go-v2/service/cloudwatch" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" "github.com/stretchr/testify/require" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/filter" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" + common_aws "github.com/influxdata/telegraf/plugins/common/aws" "github.com/influxdata/telegraf/plugins/common/proxy" "github.com/influxdata/telegraf/testutil" ) @@ -23,10 +23,10 @@ type mockGatherCloudWatchClient struct{} func (m *mockGatherCloudWatchClient) ListMetrics( _ context.Context, - params *cwClient.ListMetricsInput, - _ ...func(*cwClient.Options), -) (*cwClient.ListMetricsOutput, error) { - response := &cwClient.ListMetricsOutput{ + params *cloudwatch.ListMetricsInput, + _ ...func(*cloudwatch.Options), +) (*cloudwatch.ListMetricsOutput, error) { + response := &cloudwatch.ListMetricsOutput{ Metrics: []types.Metric{ { Namespace: params.Namespace, @@ -58,10 +58,10 @@ func (m *mockGatherCloudWatchClient) ListMetrics( func (m *mockGatherCloudWatchClient) GetMetricData( _ context.Context, - params *cwClient.GetMetricDataInput, - _ ...func(*cwClient.Options), -) (*cwClient.GetMetricDataOutput, error) { - return &cwClient.GetMetricDataOutput{ + params *cloudwatch.GetMetricDataInput, + _ ...func(*cloudwatch.Options), +) (*cloudwatch.GetMetricDataOutput, error) { + return &cloudwatch.GetMetricDataOutput{ MetricDataResults: []types.MetricDataResult{ { Id: aws.String("minimum_0_0"), @@ -167,7 +167,7 @@ func TestGather(t *testing.T) { require.NoError(t, err) internalDuration := config.Duration(duration) c := &CloudWatch{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: common_aws.CredentialConfig{ Region: "us-east-1", }, Namespace: "AWS/ELB", @@ -204,7 +204,7 @@ func TestGatherDenseMetric(t *testing.T) { require.NoError(t, err) internalDuration := config.Duration(duration) c := &CloudWatch{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: common_aws.CredentialConfig{ Region: "us-east-1", }, Namespace: "AWS/ELB", @@ -243,7 +243,7 @@ func TestMultiAccountGather(t *testing.T) { require.NoError(t, err) internalDuration := config.Duration(duration) c := &CloudWatch{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: common_aws.CredentialConfig{ Region: "us-east-1", }, Namespace: "AWS/ELB", @@ -309,9 +309,9 @@ type mockSelectMetricsCloudWatchClient struct{} func (m *mockSelectMetricsCloudWatchClient) ListMetrics( _ context.Context, - _ *cwClient.ListMetricsInput, - _ ...func(*cwClient.Options), -) (*cwClient.ListMetricsOutput, error) { + _ *cloudwatch.ListMetricsInput, + _ ...func(*cloudwatch.Options), +) (*cloudwatch.ListMetricsOutput, error) { metrics := []types.Metric{} // 4 metrics are available metricNames := []string{"Latency", "RequestCount", "HealthyHostCount", "UnHealthyHostCount"} @@ -352,7 +352,7 @@ func (m *mockSelectMetricsCloudWatchClient) ListMetrics( } } - result := &cwClient.ListMetricsOutput{ + result := &cloudwatch.ListMetricsOutput{ Metrics: metrics, } return result, nil @@ -360,9 +360,9 @@ func (m *mockSelectMetricsCloudWatchClient) ListMetrics( func (m *mockSelectMetricsCloudWatchClient) GetMetricData( _ context.Context, - _ *cwClient.GetMetricDataInput, - _ ...func(*cwClient.Options), -) (*cwClient.GetMetricDataOutput, error) { + _ *cloudwatch.GetMetricDataInput, + _ ...func(*cloudwatch.Options), +) (*cloudwatch.GetMetricDataOutput, error) { return nil, nil } @@ -371,7 +371,7 @@ func TestSelectMetrics(t *testing.T) { require.NoError(t, err) internalDuration := config.Duration(duration) c := &CloudWatch{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: common_aws.CredentialConfig{ Region: "us-east-1", }, Namespace: "AWS/ELB", diff --git a/plugins/inputs/cloudwatch_metric_streams/cloudwatch_metric_streams.go b/plugins/inputs/cloudwatch_metric_streams/cloudwatch_metric_streams.go index aef1c8d98f828..ef20ffa5706bf 100644 --- a/plugins/inputs/cloudwatch_metric_streams/cloudwatch_metric_streams.go +++ b/plugins/inputs/cloudwatch_metric_streams/cloudwatch_metric_streams.go @@ -19,7 +19,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal/choice" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/selfstat" ) @@ -48,7 +48,7 @@ type CloudWatchMetricStreams struct { ageMin selfstat.Stat Log telegraf.Logger - tlsint.ServerConfig + common_tls.ServerConfig wg sync.WaitGroup close chan struct{} listener net.Listener diff --git a/plugins/inputs/couchbase/couchbase.go b/plugins/inputs/couchbase/couchbase.go index df349dfbd07ce..55c3cd9d15c69 100644 --- a/plugins/inputs/couchbase/couchbase.go +++ b/plugins/inputs/couchbase/couchbase.go @@ -10,7 +10,7 @@ import ( "sync" "time" - couchbaseClient "github.com/couchbase/go-couchbase" + "github.com/couchbase/go-couchbase" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/filter" @@ -72,7 +72,7 @@ func (cb *Couchbase) Gather(acc telegraf.Accumulator) error { func (cb *Couchbase) gatherServer(acc telegraf.Accumulator, addr string) error { escapedAddr := regexpURI.ReplaceAllString(addr, "${1}") - client, err := couchbaseClient.Connect(addr) + client, err := couchbase.Connect(addr) if err != nil { return err } @@ -460,15 +460,15 @@ func (cb *Couchbase) Init() error { cb.client = &http.Client{ Timeout: 10 * time.Second, Transport: &http.Transport{ - MaxIdleConnsPerHost: couchbaseClient.MaxIdleConnsPerHost, + MaxIdleConnsPerHost: couchbase.MaxIdleConnsPerHost, TLSClientConfig: tlsConfig, }, } - couchbaseClient.SetSkipVerify(cb.ClientConfig.InsecureSkipVerify) - couchbaseClient.SetCertFile(cb.ClientConfig.TLSCert) - couchbaseClient.SetKeyFile(cb.ClientConfig.TLSKey) - couchbaseClient.SetRootFile(cb.ClientConfig.TLSCA) + couchbase.SetSkipVerify(cb.ClientConfig.InsecureSkipVerify) + couchbase.SetCertFile(cb.ClientConfig.TLSCert) + couchbase.SetKeyFile(cb.ClientConfig.TLSKey) + couchbase.SetRootFile(cb.ClientConfig.TLSCA) return nil } diff --git a/plugins/inputs/cpu/cpu.go b/plugins/inputs/cpu/cpu.go index 72c348bc0a595..1dbf51bdcd9e0 100644 --- a/plugins/inputs/cpu/cpu.go +++ b/plugins/inputs/cpu/cpu.go @@ -7,7 +7,7 @@ import ( "fmt" "time" - cpuUtil "github.com/shirou/gopsutil/v3/cpu" + "github.com/shirou/gopsutil/v3/cpu" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/plugins/inputs" @@ -19,8 +19,8 @@ var sampleConfig string type CPUStats struct { ps system.PS - lastStats map[string]cpuUtil.TimesStat - cpuInfo map[string]cpuUtil.InfoStat + lastStats map[string]cpu.TimesStat + cpuInfo map[string]cpu.InfoStat coreID bool physicalID bool @@ -119,7 +119,7 @@ func (c *CPUStats) Gather(acc telegraf.Accumulator) error { acc.AddGauge("cpu", fieldsG, tags, now) } - c.lastStats = make(map[string]cpuUtil.TimesStat) + c.lastStats = make(map[string]cpu.TimesStat) for _, cts := range times { c.lastStats[cts.CPU] = cts } @@ -129,12 +129,12 @@ func (c *CPUStats) Gather(acc telegraf.Accumulator) error { func (c *CPUStats) Init() error { if c.CoreTags { - cpuInfo, err := cpuUtil.Info() + cpuInfo, err := cpu.Info() if err == nil { c.coreID = cpuInfo[0].CoreID != "" c.physicalID = cpuInfo[0].PhysicalID != "" - c.cpuInfo = make(map[string]cpuUtil.InfoStat) + c.cpuInfo = make(map[string]cpu.InfoStat) for _, ci := range cpuInfo { c.cpuInfo[fmt.Sprintf("cpu%d", ci.CPU)] = ci } @@ -146,12 +146,12 @@ func (c *CPUStats) Init() error { return nil } -func totalCPUTime(t cpuUtil.TimesStat) float64 { +func totalCPUTime(t cpu.TimesStat) float64 { total := t.User + t.System + t.Nice + t.Iowait + t.Irq + t.Softirq + t.Steal + t.Idle return total } -func activeCPUTime(t cpuUtil.TimesStat) float64 { +func activeCPUTime(t cpu.TimesStat) float64 { active := totalCPUTime(t) - t.Idle return active } diff --git a/plugins/inputs/cpu/cpu_test.go b/plugins/inputs/cpu/cpu_test.go index d91d74ecd3fcd..9557db2760b28 100644 --- a/plugins/inputs/cpu/cpu_test.go +++ b/plugins/inputs/cpu/cpu_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - cpuUtil "github.com/shirou/gopsutil/v3/cpu" + "github.com/shirou/gopsutil/v3/cpu" "github.com/stretchr/testify/require" "github.com/influxdata/telegraf/plugins/inputs/system" @@ -24,7 +24,7 @@ func TestCPUStats(t *testing.T) { defer mps.AssertExpectations(t) var acc testutil.Accumulator - cts := cpuUtil.TimesStat{ + cts := cpu.TimesStat{ CPU: "cpu0", User: 8.8, System: 8.2, @@ -38,7 +38,7 @@ func TestCPUStats(t *testing.T) { GuestNice: 0.324, } - cts2 := cpuUtil.TimesStat{ + cts2 := cpu.TimesStat{ CPU: "cpu0", User: 24.9, // increased by 16.1 System: 10.9, // increased by 2.7 @@ -52,7 +52,7 @@ func TestCPUStats(t *testing.T) { GuestNice: 2.524, // increased by 2.2 } - mps.On("CPUTimes").Return([]cpuUtil.TimesStat{cts}, nil) + mps.On("CPUTimes").Return([]cpu.TimesStat{cts}, nil) cs := NewCPUStats(&mps) @@ -74,7 +74,7 @@ func TestCPUStats(t *testing.T) { assertContainsTaggedFloat(t, &acc, "time_guest_nice", 0.324, 0) mps2 := system.MockPS{} - mps2.On("CPUTimes").Return([]cpuUtil.TimesStat{cts2}, nil) + mps2.On("CPUTimes").Return([]cpu.TimesStat{cts2}, nil) cs.ps = &mps2 // Should have added cpu percentages too @@ -163,7 +163,7 @@ func TestCPUCountIncrease(t *testing.T) { cs := NewCPUStats(&mps) mps.On("CPUTimes").Return( - []cpuUtil.TimesStat{ + []cpu.TimesStat{ { CPU: "cpu0", }, @@ -173,7 +173,7 @@ func TestCPUCountIncrease(t *testing.T) { require.NoError(t, err) mps2.On("CPUTimes").Return( - []cpuUtil.TimesStat{ + []cpu.TimesStat{ { CPU: "cpu0", }, @@ -194,28 +194,28 @@ func TestCPUTimesDecrease(t *testing.T) { defer mps.AssertExpectations(t) var acc testutil.Accumulator - cts := cpuUtil.TimesStat{ + cts := cpu.TimesStat{ CPU: "cpu0", User: 18, Idle: 80, Iowait: 2, } - cts2 := cpuUtil.TimesStat{ + cts2 := cpu.TimesStat{ CPU: "cpu0", User: 38, // increased by 20 Idle: 40, // decreased by 40 Iowait: 1, // decreased by 1 } - cts3 := cpuUtil.TimesStat{ + cts3 := cpu.TimesStat{ CPU: "cpu0", User: 56, // increased by 18 Idle: 120, // increased by 80 Iowait: 3, // increased by 2 } - mps.On("CPUTimes").Return([]cpuUtil.TimesStat{cts}, nil) + mps.On("CPUTimes").Return([]cpu.TimesStat{cts}, nil) cs := NewCPUStats(&mps) @@ -229,7 +229,7 @@ func TestCPUTimesDecrease(t *testing.T) { assertContainsTaggedFloat(t, &acc, "time_iowait", 2, 0) mps2 := system.MockPS{} - mps2.On("CPUTimes").Return([]cpuUtil.TimesStat{cts2}, nil) + mps2.On("CPUTimes").Return([]cpu.TimesStat{cts2}, nil) cs.ps = &mps2 // CPU times decreased. An error should be raised @@ -237,7 +237,7 @@ func TestCPUTimesDecrease(t *testing.T) { require.Error(t, err) mps3 := system.MockPS{} - mps3.On("CPUTimes").Return([]cpuUtil.TimesStat{cts3}, nil) + mps3.On("CPUTimes").Return([]cpu.TimesStat{cts3}, nil) cs.ps = &mps3 err = cs.Gather(&acc) diff --git a/plugins/inputs/ctrlx_datalayer/ctrlx_datalayer.go b/plugins/inputs/ctrlx_datalayer/ctrlx_datalayer.go index dd0c4e8c65f0e..201975a0666d3 100644 --- a/plugins/inputs/ctrlx_datalayer/ctrlx_datalayer.go +++ b/plugins/inputs/ctrlx_datalayer/ctrlx_datalayer.go @@ -22,9 +22,9 @@ import ( "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal/choice" "github.com/influxdata/telegraf/metric" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/inputs" - jsonParser "github.com/influxdata/telegraf/plugins/parsers/json" + json_parser "github.com/influxdata/telegraf/plugins/parsers/json" ) // This plugin is based on the official ctrlX CORE API. Documentation can be found in OpenAPI format at: @@ -55,7 +55,7 @@ type CtrlXDataLayer struct { acc telegraf.Accumulator connection *http.Client tokenManager token.TokenManager - httpconfig.HTTPClientConfig + common_http.HTTPClientConfig } // convertTimestamp2UnixTime converts the given Data Layer timestamp of the payload to UnixTime. @@ -197,7 +197,7 @@ func (c *CtrlXDataLayer) createMetric(em *sseEventData, sub *Subscription) (tele switch em.Type { case "object": - flattener := jsonParser.JSONFlattener{} + flattener := json_parser.JSONFlattener{} err := flattener.FullFlattenJSON(fieldKey, em.Value, true, true) if err != nil { return nil, err diff --git a/plugins/inputs/ctrlx_datalayer/ctrlx_datalayer_test.go b/plugins/inputs/ctrlx_datalayer/ctrlx_datalayer_test.go index 09f9dfe2363b9..d82b451666fd2 100644 --- a/plugins/inputs/ctrlx_datalayer/ctrlx_datalayer_test.go +++ b/plugins/inputs/ctrlx_datalayer/ctrlx_datalayer_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/influxdata/telegraf/config" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/testutil" ) @@ -183,7 +183,7 @@ func initRunner(t *testing.T) (*CtrlXDataLayer, *httptest.Server) { url: server.URL, Username: config.NewSecret([]byte("user")), Password: config.NewSecret([]byte("password")), - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ ClientConfig: tls.ClientConfig{ InsecureSkipVerify: true, }, diff --git a/plugins/inputs/disk/disk_test.go b/plugins/inputs/disk/disk_test.go index 2abe8ad2abbbf..877ce416fcd93 100644 --- a/plugins/inputs/disk/disk_test.go +++ b/plugins/inputs/disk/disk_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - diskUtil "github.com/shirou/gopsutil/v3/disk" + "github.com/shirou/gopsutil/v3/disk" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -30,7 +30,7 @@ func TestDiskUsage(t *testing.T) { var acc testutil.Accumulator var err error - psAll := []diskUtil.PartitionStat{ + psAll := []disk.PartitionStat{ { Device: "/dev/sda", Mountpoint: "/", @@ -50,7 +50,7 @@ func TestDiskUsage(t *testing.T) { Opts: []string{"ro", "noatime", "nodiratime", "bind"}, }, } - duAll := []diskUtil.UsageStat{ + duAll := []disk.UsageStat{ { Path: "/", Fstype: "ext4", @@ -170,15 +170,15 @@ func TestDiskUsage(t *testing.T) { func TestDiskUsageHostMountPrefix(t *testing.T) { tests := []struct { name string - partitionStats []diskUtil.PartitionStat - usageStats []*diskUtil.UsageStat + partitionStats []disk.PartitionStat + usageStats []*disk.UsageStat hostMountPrefix string expectedTags map[string]string expectedFields map[string]interface{} }{ { name: "no host mount prefix", - partitionStats: []diskUtil.PartitionStat{ + partitionStats: []disk.PartitionStat{ { Device: "/dev/sda", Mountpoint: "/", @@ -186,7 +186,7 @@ func TestDiskUsageHostMountPrefix(t *testing.T) { Opts: []string{"ro"}, }, }, - usageStats: []*diskUtil.UsageStat{ + usageStats: []*disk.UsageStat{ { Path: "/", Total: 42, @@ -211,7 +211,7 @@ func TestDiskUsageHostMountPrefix(t *testing.T) { }, { name: "host mount prefix", - partitionStats: []diskUtil.PartitionStat{ + partitionStats: []disk.PartitionStat{ { Device: "/dev/sda", Mountpoint: "/hostfs/var", @@ -219,7 +219,7 @@ func TestDiskUsageHostMountPrefix(t *testing.T) { Opts: []string{"ro"}, }, }, - usageStats: []*diskUtil.UsageStat{ + usageStats: []*disk.UsageStat{ { Path: "/hostfs/var", Total: 42, @@ -245,7 +245,7 @@ func TestDiskUsageHostMountPrefix(t *testing.T) { }, { name: "host mount prefix exact match", - partitionStats: []diskUtil.PartitionStat{ + partitionStats: []disk.PartitionStat{ { Device: "/dev/sda", Mountpoint: "/hostfs", @@ -253,7 +253,7 @@ func TestDiskUsageHostMountPrefix(t *testing.T) { Opts: []string{"ro"}, }, }, - usageStats: []*diskUtil.UsageStat{ + usageStats: []*disk.UsageStat{ { Path: "/hostfs", Total: 42, @@ -310,7 +310,7 @@ func TestDiskStats(t *testing.T) { var acc testutil.Accumulator var err error - duAll := []*diskUtil.UsageStat{ + duAll := []*disk.UsageStat{ { Path: "/", Fstype: "ext4", @@ -342,7 +342,7 @@ func TestDiskStats(t *testing.T) { InodesUsed: 1000, }, } - duMountFiltered := []*diskUtil.UsageStat{ + duMountFiltered := []*disk.UsageStat{ { Path: "/", Fstype: "ext4", @@ -354,7 +354,7 @@ func TestDiskStats(t *testing.T) { InodesUsed: 1000, }, } - duOptFiltered := []*diskUtil.UsageStat{ + duOptFiltered := []*disk.UsageStat{ { Path: "/", Fstype: "ext4", @@ -377,7 +377,7 @@ func TestDiskStats(t *testing.T) { }, } - psAll := []*diskUtil.PartitionStat{ + psAll := []*disk.PartitionStat{ { Device: "/dev/sda", Mountpoint: "/", @@ -398,7 +398,7 @@ func TestDiskStats(t *testing.T) { }, } - psMountFiltered := []*diskUtil.PartitionStat{ + psMountFiltered := []*disk.PartitionStat{ { Device: "/dev/sda", Mountpoint: "/", @@ -406,7 +406,7 @@ func TestDiskStats(t *testing.T) { Opts: []string{"ro", "noatime", "nodiratime"}, }, } - psOptFiltered := []*diskUtil.PartitionStat{ + psOptFiltered := []*disk.PartitionStat{ { Device: "/dev/sda", Mountpoint: "/", @@ -495,13 +495,13 @@ func TestDiskUsageIssues(t *testing.T) { tests := []struct { name string prefix string - du diskUtil.UsageStat + du disk.UsageStat expected []telegraf.Metric }{ { name: "success", prefix: "", - du: diskUtil.UsageStat{ + du: disk.UsageStat{ Total: 256, Free: 46, Used: 200, @@ -557,7 +557,7 @@ func TestDiskUsageIssues(t *testing.T) { { name: "issue 10297", prefix: "/host", - du: diskUtil.UsageStat{ + du: disk.UsageStat{ Total: 256, Free: 46, Used: 200, @@ -630,7 +630,7 @@ func TestDiskUsageIssues(t *testing.T) { t.Setenv("HOST_PROC", hostProcPrefix) t.Setenv("HOST_SYS", hostSysPrefix) - partitions, err := diskUtil.Partitions(true) + partitions, err := disk.Partitions(true) require.NoError(t, err) // Mock the disk usage diff --git a/plugins/inputs/docker/client.go b/plugins/inputs/docker/client.go index 5c9afc6f2c287..94fc24c5d1267 100644 --- a/plugins/inputs/docker/client.go +++ b/plugins/inputs/docker/client.go @@ -9,7 +9,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" - dockerClient "github.com/docker/docker/client" + docker_client "github.com/docker/docker/client" ) var ( @@ -30,7 +30,7 @@ type Client interface { } func NewEnvClient() (Client, error) { - client, err := dockerClient.NewClientWithOpts(dockerClient.FromEnv) + client, err := docker_client.NewClientWithOpts(docker_client.FromEnv) if err != nil { return nil, err } @@ -43,11 +43,11 @@ func NewClient(host string, tlsConfig *tls.Config) (Client, error) { } httpClient := &http.Client{Transport: transport} - client, err := dockerClient.NewClientWithOpts( - dockerClient.WithHTTPHeaders(defaultHeaders), - dockerClient.WithHTTPClient(httpClient), - dockerClient.WithAPIVersionNegotiation(), - dockerClient.WithHost(host)) + client, err := docker_client.NewClientWithOpts( + docker_client.WithHTTPHeaders(defaultHeaders), + docker_client.WithHTTPClient(httpClient), + docker_client.WithAPIVersionNegotiation(), + docker_client.WithHost(host)) if err != nil { return nil, err } @@ -56,7 +56,7 @@ func NewClient(host string, tlsConfig *tls.Config) (Client, error) { } type SocketClient struct { - client *dockerClient.Client + client *docker_client.Client } func (c *SocketClient) Info(ctx context.Context) (system.Info, error) { diff --git a/plugins/inputs/docker/docker.go b/plugins/inputs/docker/docker.go index 189b48528416d..365770f553fa4 100644 --- a/plugins/inputs/docker/docker.go +++ b/plugins/inputs/docker/docker.go @@ -17,7 +17,7 @@ import ( "github.com/Masterminds/semver/v3" "github.com/docker/docker/api/types" - typeContainer "github.com/docker/docker/api/types/container" + type_container "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" @@ -25,8 +25,8 @@ import ( "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/filter" "github.com/influxdata/telegraf/internal/choice" - dockerint "github.com/influxdata/telegraf/internal/docker" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + internal_docker "github.com/influxdata/telegraf/internal/docker" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -61,7 +61,7 @@ type Docker struct { Log telegraf.Logger - tlsint.ClientConfig + common_tls.ClientConfig newEnvClient func() (Client, error) newClient func(string, *tls.Config) (Client, error) @@ -218,7 +218,7 @@ func (d *Docker) Gather(acc telegraf.Accumulator) error { } // List containers - opts := typeContainer.ListOptions{ + opts := type_container.ListOptions{ Filters: filterArgs, } ctx, cancel := context.WithTimeout(context.Background(), time.Duration(d.Timeout)) @@ -471,7 +471,7 @@ func (d *Docker) gatherContainer( container types.Container, acc telegraf.Accumulator, ) error { - var v *typeContainer.StatsResponse + var v *type_container.StatsResponse cname := parseContainerName(container.Names) @@ -483,7 +483,7 @@ func (d *Docker) gatherContainer( return nil } - imageName, imageVersion := dockerint.ParseImage(container.Image) + imageName, imageVersion := internal_docker.ParseImage(container.Image) tags := map[string]string{ "engine_host": d.engineHost, @@ -533,7 +533,7 @@ func (d *Docker) gatherContainerInspect( acc telegraf.Accumulator, tags map[string]string, daemonOSType string, - v *typeContainer.StatsResponse, + v *type_container.StatsResponse, ) error { ctx, cancel := context.WithTimeout(context.Background(), time.Duration(d.Timeout)) defer cancel() @@ -605,7 +605,7 @@ func (d *Docker) gatherContainerInspect( } func (d *Docker) parseContainerStats( - stat *typeContainer.StatsResponse, + stat *type_container.StatsResponse, acc telegraf.Accumulator, tags map[string]string, id string, @@ -782,7 +782,7 @@ func (d *Docker) parseContainerStats( } // Make a map of devices to their block io stats -func getDeviceStatMap(blkioStats typeContainer.BlkioStats) map[string]map[string]interface{} { +func getDeviceStatMap(blkioStats type_container.BlkioStats) map[string]map[string]interface{} { deviceStatMap := make(map[string]map[string]interface{}) for _, metric := range blkioStats.IoServiceBytesRecursive { @@ -845,7 +845,7 @@ func getDeviceStatMap(blkioStats typeContainer.BlkioStats) map[string]map[string func (d *Docker) gatherBlockIOMetrics( acc telegraf.Accumulator, - stat *typeContainer.StatsResponse, + stat *type_container.StatsResponse, tags map[string]string, tm time.Time, id string, @@ -928,7 +928,7 @@ func (d *Docker) gatherDiskUsage(acc telegraf.Accumulator, opts types.DiskUsageO "size_root_fs": container.SizeRootFs, } - imageName, imageVersion := dockerint.ParseImage(container.Image) + imageName, imageVersion := internal_docker.ParseImage(container.Image) tags := map[string]string{ "engine_host": d.engineHost, @@ -959,7 +959,7 @@ func (d *Docker) gatherDiskUsage(acc telegraf.Accumulator, opts types.DiskUsageO } if len(image.RepoTags) > 0 { - imageName, imageVersion := dockerint.ParseImage(image.RepoTags[0]) + imageName, imageVersion := internal_docker.ParseImage(image.RepoTags[0]) tags["image_name"] = imageName tags["image_version"] = imageVersion } diff --git a/plugins/inputs/docker/docker_test.go b/plugins/inputs/docker/docker_test.go index ee39cf43d41bc..52d92c2211525 100644 --- a/plugins/inputs/docker/docker_test.go +++ b/plugins/inputs/docker/docker_test.go @@ -11,7 +11,7 @@ import ( "time" "github.com/docker/docker/api/types" - typeContainer "github.com/docker/docker/api/types/container" + type_container "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/system" "github.com/stretchr/testify/require" @@ -23,8 +23,8 @@ import ( type MockClient struct { InfoF func() (system.Info, error) - ContainerListF func(options typeContainer.ListOptions) ([]types.Container, error) - ContainerStatsF func(containerID string) (typeContainer.StatsResponseReader, error) + ContainerListF func(options type_container.ListOptions) ([]types.Container, error) + ContainerStatsF func(containerID string) (type_container.StatsResponseReader, error) ContainerInspectF func() (types.ContainerJSON, error) ServiceListF func() ([]swarm.Service, error) TaskListF func() ([]swarm.Task, error) @@ -38,11 +38,11 @@ func (c *MockClient) Info(context.Context) (system.Info, error) { return c.InfoF() } -func (c *MockClient) ContainerList(_ context.Context, options typeContainer.ListOptions) ([]types.Container, error) { +func (c *MockClient) ContainerList(_ context.Context, options type_container.ListOptions) ([]types.Container, error) { return c.ContainerListF(options) } -func (c *MockClient) ContainerStats(_ context.Context, containerID string, _ bool) (typeContainer.StatsResponseReader, error) { +func (c *MockClient) ContainerStats(_ context.Context, containerID string, _ bool) (type_container.StatsResponseReader, error) { return c.ContainerStatsF(containerID) } @@ -78,10 +78,10 @@ var baseClient = MockClient{ InfoF: func() (system.Info, error) { return info, nil }, - ContainerListF: func(typeContainer.ListOptions) ([]types.Container, error) { + ContainerListF: func(type_container.ListOptions) ([]types.Container, error) { return containerList, nil }, - ContainerStatsF: func(s string) (typeContainer.StatsResponseReader, error) { + ContainerStatsF: func(s string) (type_container.StatsResponseReader, error) { return containerStats(s), nil }, ContainerInspectF: func() (types.ContainerJSON, error) { @@ -426,10 +426,10 @@ func TestDocker_WindowsMemoryContainerStats(t *testing.T) { InfoF: func() (system.Info, error) { return info, nil }, - ContainerListF: func(typeContainer.ListOptions) ([]types.Container, error) { + ContainerListF: func(type_container.ListOptions) ([]types.Container, error) { return containerList, nil }, - ContainerStatsF: func(string) (typeContainer.StatsResponseReader, error) { + ContainerStatsF: func(string) (type_container.StatsResponseReader, error) { return containerStatsWindows(), nil }, ContainerInspectF: func() (types.ContainerJSON, error) { @@ -561,7 +561,7 @@ func TestContainerLabels(t *testing.T) { newClientFunc := func(string, *tls.Config) (Client, error) { client := baseClient - client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) { + client.ContainerListF = func(type_container.ListOptions) ([]types.Container, error) { return []types.Container{tt.container}, nil } return &client, nil @@ -681,10 +681,10 @@ func TestContainerNames(t *testing.T) { newClientFunc := func(string, *tls.Config) (Client, error) { client := baseClient - client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) { + client.ContainerListF = func(type_container.ListOptions) ([]types.Container, error) { return containerList, nil } - client.ContainerStatsF = func(s string) (typeContainer.StatsResponseReader, error) { + client.ContainerStatsF = func(s string) (type_container.StatsResponseReader, error) { return containerStats(s), nil } @@ -891,7 +891,7 @@ func TestContainerStatus(t *testing.T) { acc testutil.Accumulator newClientFunc = func(string, *tls.Config) (Client, error) { client := baseClient - client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) { + client.ContainerListF = func(type_container.ListOptions) ([]types.Container, error) { return containerList[:1], nil } client.ContainerInspectF = func() (types.ContainerJSON, error) { @@ -1176,7 +1176,7 @@ func TestContainerStateFilter(t *testing.T) { newClientFunc := func(string, *tls.Config) (Client, error) { client := baseClient - client.ContainerListF = func(options typeContainer.ListOptions) ([]types.Container, error) { + client.ContainerListF = func(options type_container.ListOptions) ([]types.Container, error) { for k, v := range tt.expected { actual := options.Filters.Get(k) sort.Strings(actual) @@ -1212,15 +1212,15 @@ func TestContainerName(t *testing.T) { name: "container stats name is preferred", clientFunc: func(string, *tls.Config) (Client, error) { client := baseClient - client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) { + client.ContainerListF = func(type_container.ListOptions) ([]types.Container, error) { var containers []types.Container containers = append(containers, types.Container{ Names: []string{"/logspout/foo"}, }) return containers, nil } - client.ContainerStatsF = func(string) (typeContainer.StatsResponseReader, error) { - return typeContainer.StatsResponseReader{ + client.ContainerStatsF = func(string) (type_container.StatsResponseReader, error) { + return type_container.StatsResponseReader{ Body: io.NopCloser(strings.NewReader(`{"name": "logspout"}`)), }, nil } @@ -1232,15 +1232,15 @@ func TestContainerName(t *testing.T) { name: "container stats without name uses container list name", clientFunc: func(string, *tls.Config) (Client, error) { client := baseClient - client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) { + client.ContainerListF = func(type_container.ListOptions) ([]types.Container, error) { var containers []types.Container containers = append(containers, types.Container{ Names: []string{"/logspout"}, }) return containers, nil } - client.ContainerStatsF = func(string) (typeContainer.StatsResponseReader, error) { - return typeContainer.StatsResponseReader{ + client.ContainerStatsF = func(string) (type_container.StatsResponseReader, error) { + return type_container.StatsResponseReader{ Body: io.NopCloser(strings.NewReader(`{}`)), }, nil } @@ -1304,7 +1304,7 @@ func TestHostnameFromID(t *testing.T) { func Test_parseContainerStatsPerDeviceAndTotal(t *testing.T) { type args struct { - stat *typeContainer.StatsResponse + stat *type_container.StatsResponse tags map[string]string id string perDeviceInclude []string diff --git a/plugins/inputs/docker_log/docker_log.go b/plugins/inputs/docker_log/docker_log.go index 892cd0e101486..5024e2cc4038c 100644 --- a/plugins/inputs/docker_log/docker_log.go +++ b/plugins/inputs/docker_log/docker_log.go @@ -16,7 +16,7 @@ import ( "unicode" "github.com/docker/docker/api/types" - typeContainer "github.com/docker/docker/api/types/container" + type_container "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/pkg/stdcopy" @@ -24,7 +24,7 @@ import ( "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/filter" "github.com/influxdata/telegraf/internal/docker" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -53,7 +53,7 @@ type DockerLogs struct { ContainerStateExclude []string `toml:"container_state_exclude"` IncludeSourceTag bool `toml:"source_tag"` - tlsint.ClientConfig + common_tls.ClientConfig newEnvClient func() (Client, error) newClient func(string, *tls.Config) (Client, error) @@ -62,7 +62,7 @@ type DockerLogs struct { labelFilter filter.Filter containerFilter filter.Filter stateFilter filter.Filter - opts typeContainer.ListOptions + opts type_container.ListOptions wg sync.WaitGroup mu sync.Mutex containerList map[string]context.CancelFunc @@ -117,7 +117,7 @@ func (d *DockerLogs) Init() error { } if filterArgs.Len() != 0 { - d.opts = typeContainer.ListOptions{ + d.opts = type_container.ListOptions{ Filters: filterArgs, } } @@ -282,7 +282,7 @@ func (d *DockerLogs) tailContainerLogs( d.lastRecordMtx.Unlock() } - logOptions := typeContainer.LogsOptions{ + logOptions := type_container.LogsOptions{ ShowStdout: true, ShowStderr: true, Timestamps: true, diff --git a/plugins/inputs/elasticsearch/elasticsearch.go b/plugins/inputs/elasticsearch/elasticsearch.go index 9341abc56d8ae..12103ad5af3ff 100644 --- a/plugins/inputs/elasticsearch/elasticsearch.go +++ b/plugins/inputs/elasticsearch/elasticsearch.go @@ -18,7 +18,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/filter" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/inputs" jsonparser "github.com/influxdata/telegraf/plugins/parsers/json" ) @@ -132,7 +132,7 @@ type Elasticsearch struct { Log telegraf.Logger `toml:"-"` client *http.Client - httpconfig.HTTPClientConfig + common_http.HTTPClientConfig serverInfo map[string]serverInfo serverInfoMutex sync.Mutex @@ -152,7 +152,7 @@ func NewElasticsearch() *Elasticsearch { return &Elasticsearch{ ClusterStatsOnlyFromMaster: true, ClusterHealthLevel: "indices", - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ ResponseHeaderTimeout: config.Duration(5 * time.Second), Timeout: config.Duration(5 * time.Second), }, diff --git a/plugins/inputs/elasticsearch_query/elasticsearch_query.go b/plugins/inputs/elasticsearch_query/elasticsearch_query.go index 74856d170d35f..99c7323ebdb6c 100644 --- a/plugins/inputs/elasticsearch_query/elasticsearch_query.go +++ b/plugins/inputs/elasticsearch_query/elasticsearch_query.go @@ -16,7 +16,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -35,7 +35,7 @@ type ElasticsearchQuery struct { Log telegraf.Logger `toml:"-"` httpclient *http.Client - httpconfig.HTTPClientConfig + common_http.HTTPClientConfig esClient *elastic5.Client } @@ -242,7 +242,7 @@ func init() { inputs.Add("elasticsearch_query", func() telegraf.Input { return &ElasticsearchQuery{ HealthCheckInterval: config.Duration(time.Second * 10), - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ ResponseHeaderTimeout: config.Duration(5 * time.Second), Timeout: config.Duration(5 * time.Second), }, diff --git a/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go b/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go index e9da6bcaadd33..305c1699894c4 100644 --- a/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go +++ b/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go @@ -19,7 +19,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/testutil" ) @@ -538,7 +538,7 @@ func setupIntegrationTest(t *testing.T) (*testutil.Container, error) { ) e := &ElasticsearchQuery{ URLs: []string{url}, - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ ResponseHeaderTimeout: config.Duration(30 * time.Second), Timeout: config.Duration(30 * time.Second), }, @@ -618,7 +618,7 @@ func TestElasticsearchQueryIntegration(t *testing.T) { URLs: []string{ fmt.Sprintf("http://%s:%s", container.Address, container.Ports[servicePort]), }, - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ ResponseHeaderTimeout: config.Duration(30 * time.Second), Timeout: config.Duration(30 * time.Second), }, @@ -684,7 +684,7 @@ func TestElasticsearchQueryIntegration_getMetricFields(t *testing.T) { URLs: []string{ fmt.Sprintf("http://%s:%s", container.Address, container.Ports[servicePort]), }, - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ ResponseHeaderTimeout: config.Duration(30 * time.Second), Timeout: config.Duration(30 * time.Second), }, diff --git a/plugins/inputs/ethtool/namespace_linux.go b/plugins/inputs/ethtool/namespace_linux.go index 68df8ff6977dc..a83ba9b62939f 100644 --- a/plugins/inputs/ethtool/namespace_linux.go +++ b/plugins/inputs/ethtool/namespace_linux.go @@ -5,7 +5,7 @@ import ( "net" "runtime" - ethtoolLib "github.com/safchain/ethtool" + "github.com/safchain/ethtool" "github.com/vishvananda/netns" "github.com/influxdata/telegraf" @@ -24,7 +24,7 @@ type NamespacedResult struct { type NamespaceGoroutine struct { name string handle netns.NsHandle - ethtoolClient *ethtoolLib.Ethtool + ethtoolClient *ethtool.Ethtool c chan NamespacedAction Log telegraf.Logger } @@ -71,7 +71,7 @@ func (n *NamespaceGoroutine) Stats(intf NamespacedInterface) (map[string]uint64, func (n *NamespaceGoroutine) Get(intf NamespacedInterface) (map[string]uint64, error) { result, err := n.Do(func(n *NamespaceGoroutine) (interface{}, error) { - ecmd := ethtoolLib.EthtoolCmd{} + ecmd := ethtool.EthtoolCmd{} speed32, err := n.ethtoolClient.CmdGet(&ecmd, intf.Name) if err != nil { return nil, err @@ -134,7 +134,7 @@ func (n *NamespaceGoroutine) Start() error { } // Every namespace needs its own connection to ethtool - e, err := ethtoolLib.NewEthtool() + e, err := ethtool.NewEthtool() if err != nil { n.Log.Errorf("Could not create ethtool client for namespace %q: %s", n.name, err.Error()) started <- err diff --git a/plugins/inputs/eventhub_consumer/eventhub_consumer.go b/plugins/inputs/eventhub_consumer/eventhub_consumer.go index c7331b99bc501..6445117f990ed 100644 --- a/plugins/inputs/eventhub_consumer/eventhub_consumer.go +++ b/plugins/inputs/eventhub_consumer/eventhub_consumer.go @@ -9,7 +9,7 @@ import ( "sync" "time" - eventhubClient "github.com/Azure/azure-event-hubs-go/v3" + "github.com/Azure/azure-event-hubs-go/v3" "github.com/Azure/azure-event-hubs-go/v3/persist" "github.com/influxdata/telegraf" @@ -62,7 +62,7 @@ type EventHub struct { Log telegraf.Logger `toml:"-"` // Azure - hub *eventhubClient.Hub + hub *eventhub.Hub cancel context.CancelFunc wg sync.WaitGroup @@ -91,7 +91,7 @@ func (e *EventHub) Init() (err error) { } // Set hub options - hubOpts := []eventhubClient.HubOption{} + hubOpts := []eventhub.HubOption{} if e.PersistenceDir != "" { persister, err := persist.NewFilePersister(e.PersistenceDir) @@ -99,20 +99,20 @@ func (e *EventHub) Init() (err error) { return err } - hubOpts = append(hubOpts, eventhubClient.HubWithOffsetPersistence(persister)) + hubOpts = append(hubOpts, eventhub.HubWithOffsetPersistence(persister)) } if e.UserAgent != "" { - hubOpts = append(hubOpts, eventhubClient.HubWithUserAgent(e.UserAgent)) + hubOpts = append(hubOpts, eventhub.HubWithUserAgent(e.UserAgent)) } else { - hubOpts = append(hubOpts, eventhubClient.HubWithUserAgent(internal.ProductToken())) + hubOpts = append(hubOpts, eventhub.HubWithUserAgent(internal.ProductToken())) } // Create event hub connection if e.ConnectionString != "" { - e.hub, err = eventhubClient.NewHubFromConnectionString(e.ConnectionString, hubOpts...) + e.hub, err = eventhub.NewHubFromConnectionString(e.ConnectionString, hubOpts...) } else { - e.hub, err = eventhubClient.NewHubFromEnvironment(hubOpts...) + e.hub, err = eventhub.NewHubFromEnvironment(hubOpts...) } return err @@ -155,25 +155,25 @@ func (e *EventHub) Start(acc telegraf.Accumulator) error { return nil } -func (e *EventHub) configureReceiver() []eventhubClient.ReceiveOption { - receiveOpts := []eventhubClient.ReceiveOption{} +func (e *EventHub) configureReceiver() []eventhub.ReceiveOption { + receiveOpts := []eventhub.ReceiveOption{} if e.ConsumerGroup != "" { - receiveOpts = append(receiveOpts, eventhubClient.ReceiveWithConsumerGroup(e.ConsumerGroup)) + receiveOpts = append(receiveOpts, eventhub.ReceiveWithConsumerGroup(e.ConsumerGroup)) } if !e.FromTimestamp.IsZero() { - receiveOpts = append(receiveOpts, eventhubClient.ReceiveFromTimestamp(e.FromTimestamp)) + receiveOpts = append(receiveOpts, eventhub.ReceiveFromTimestamp(e.FromTimestamp)) } else if e.Latest { - receiveOpts = append(receiveOpts, eventhubClient.ReceiveWithLatestOffset()) + receiveOpts = append(receiveOpts, eventhub.ReceiveWithLatestOffset()) } if e.PrefetchCount != 0 { - receiveOpts = append(receiveOpts, eventhubClient.ReceiveWithPrefetchCount(e.PrefetchCount)) + receiveOpts = append(receiveOpts, eventhub.ReceiveWithPrefetchCount(e.PrefetchCount)) } if e.Epoch != 0 { - receiveOpts = append(receiveOpts, eventhubClient.ReceiveWithEpoch(e.Epoch)) + receiveOpts = append(receiveOpts, eventhub.ReceiveWithEpoch(e.Epoch)) } return receiveOpts @@ -182,7 +182,7 @@ func (e *EventHub) configureReceiver() []eventhubClient.ReceiveOption { // OnMessage handles an Event. When this function returns without error the // Event is immediately accepted and the offset is updated. If an error is // returned the Event is marked for redelivery. -func (e *EventHub) onMessage(ctx context.Context, event *eventhubClient.Event) error { +func (e *EventHub) onMessage(ctx context.Context, event *eventhub.Event) error { metrics, err := e.createMetrics(event) if err != nil { return err @@ -264,7 +264,7 @@ func deepCopyMetrics(in []telegraf.Metric) []telegraf.Metric { } // CreateMetrics returns the Metrics from the Event. -func (e *EventHub) createMetrics(event *eventhubClient.Event) ([]telegraf.Metric, error) { +func (e *EventHub) createMetrics(event *eventhub.Event) ([]telegraf.Metric, error) { metrics, err := e.parser.Parse(event.Data) if err != nil { return nil, err diff --git a/plugins/inputs/exec/run_notwinodws.go b/plugins/inputs/exec/run_notwinodws.go index c4604945c0069..adad0925bcb9a 100644 --- a/plugins/inputs/exec/run_notwinodws.go +++ b/plugins/inputs/exec/run_notwinodws.go @@ -6,12 +6,13 @@ import ( "bytes" "fmt" "os" - osExec "os/exec" + "os/exec" "syscall" "time" - "github.com/influxdata/telegraf/internal" "github.com/kballard/go-shellquote" + + "github.com/influxdata/telegraf/internal" ) func (c CommandRunner) Run( @@ -24,7 +25,7 @@ func (c CommandRunner) Run( return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err) } - cmd := osExec.Command(splitCmd[0], splitCmd[1:]...) + cmd := exec.Command(splitCmd[0], splitCmd[1:]...) cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} if len(environments) > 0 { diff --git a/plugins/inputs/execd/execd_test.go b/plugins/inputs/execd/execd_test.go index 9a0ea715edeb9..29e8b8ce80dc9 100644 --- a/plugins/inputs/execd/execd_test.go +++ b/plugins/inputs/execd/execd_test.go @@ -19,7 +19,7 @@ import ( "github.com/influxdata/telegraf/models" "github.com/influxdata/telegraf/plugins/parsers/influx" "github.com/influxdata/telegraf/plugins/parsers/prometheus" - influxSerializer "github.com/influxdata/telegraf/plugins/serializers/influx" + influx_serializer "github.com/influxdata/telegraf/plugins/serializers/influx" "github.com/influxdata/telegraf/testutil" ) @@ -275,7 +275,7 @@ func TestMain(m *testing.M) { func runCounterProgram() error { envMetricName := os.Getenv("METRIC_NAME") - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} if err := serializer.Init(); err != nil { return err } diff --git a/plugins/inputs/github/github.go b/plugins/inputs/github/github.go index 390102030b479..3206dbcf9bdab 100644 --- a/plugins/inputs/github/github.go +++ b/plugins/inputs/github/github.go @@ -11,7 +11,7 @@ import ( "sync" "time" - githubLib "github.com/google/go-github/v32/github" + "github.com/google/go-github/v32/github" "golang.org/x/oauth2" "github.com/influxdata/telegraf" @@ -30,7 +30,7 @@ type GitHub struct { AdditionalFields []string `toml:"additional_fields"` EnterpriseBaseURL string `toml:"enterprise_base_url"` HTTPTimeout config.Duration `toml:"http_timeout"` - githubClient *githubLib.Client + githubClient *github.Client obfuscatedToken string @@ -40,7 +40,7 @@ type GitHub struct { } // Create GitHub Client -func (g *GitHub) createGitHubClient(ctx context.Context) (*githubLib.Client, error) { +func (g *GitHub) createGitHubClient(ctx context.Context) (*github.Client, error) { httpClient := &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyFromEnvironment, @@ -65,11 +65,11 @@ func (g *GitHub) createGitHubClient(ctx context.Context) (*githubLib.Client, err return g.newGithubClient(httpClient) } -func (g *GitHub) newGithubClient(httpClient *http.Client) (*githubLib.Client, error) { +func (g *GitHub) newGithubClient(httpClient *http.Client) (*github.Client, error) { if g.EnterpriseBaseURL != "" { - return githubLib.NewEnterpriseClient(g.EnterpriseBaseURL, "", httpClient) + return github.NewEnterpriseClient(g.EnterpriseBaseURL, "", httpClient) } - return githubLib.NewClient(httpClient), nil + return github.NewClient(httpClient), nil } func (*GitHub) SampleConfig() string { @@ -148,8 +148,8 @@ func (g *GitHub) Gather(acc telegraf.Accumulator) error { return nil } -func (g *GitHub) handleRateLimit(response *githubLib.Response, err error) { - var rlErr *githubLib.RateLimitError +func (g *GitHub) handleRateLimit(response *github.Response, err error) { + var rlErr *github.RateLimitError if err == nil { g.RateLimit.Set(int64(response.Rate.Limit)) g.RateRemaining.Set(int64(response.Rate.Remaining)) @@ -168,7 +168,7 @@ func splitRepositoryName(repositoryName string) (owner string, repository string return splits[0], splits[1], nil } -func getLicense(rI *githubLib.Repository) string { +func getLicense(rI *github.Repository) string { if licenseName := rI.GetLicense().GetName(); licenseName != "" { return licenseName } @@ -176,7 +176,7 @@ func getLicense(rI *githubLib.Repository) string { return "None" } -func getTags(repositoryInfo *githubLib.Repository) map[string]string { +func getTags(repositoryInfo *github.Repository) map[string]string { return map[string]string{ "owner": repositoryInfo.GetOwner().GetLogin(), "name": repositoryInfo.GetName(), @@ -185,7 +185,7 @@ func getTags(repositoryInfo *githubLib.Repository) map[string]string { } } -func getFields(repositoryInfo *githubLib.Repository) map[string]interface{} { +func getFields(repositoryInfo *github.Repository) map[string]interface{} { return map[string]interface{}{ "stars": repositoryInfo.GetStargazersCount(), "subscribers": repositoryInfo.GetSubscribersCount(), @@ -198,9 +198,9 @@ func getFields(repositoryInfo *githubLib.Repository) map[string]interface{} { } func (g *GitHub) getPullRequestFields(ctx context.Context, owner, repo string) (map[string]interface{}, error) { - options := githubLib.SearchOptions{ + options := github.SearchOptions{ TextMatch: false, - ListOptions: githubLib.ListOptions{ + ListOptions: github.ListOptions{ PerPage: 100, Page: 1, }, diff --git a/plugins/inputs/gnmi/gnmi.go b/plugins/inputs/gnmi/gnmi.go index 7b731952252bb..5e2e2cdff0b8c 100644 --- a/plugins/inputs/gnmi/gnmi.go +++ b/plugins/inputs/gnmi/gnmi.go @@ -12,14 +12,14 @@ import ( "time" "github.com/google/gnxi/utils/xpath" - gnmiLib "github.com/openconfig/gnmi/proto/gnmi" + "github.com/openconfig/gnmi/proto/gnmi" "google.golang.org/grpc/keepalive" "google.golang.org/grpc/metadata" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal/choice" - internaltls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/common/yangmodel" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -65,7 +65,7 @@ type GNMI struct { KeepaliveTimeout config.Duration `toml:"keepalive_timeout"` YangModelPaths []string `toml:"yang_model_paths"` Log telegraf.Logger `toml:"-"` - internaltls.ClientConfig + common_tls.ClientConfig // Internal state internalAliases map[*pathInfo]string @@ -85,7 +85,7 @@ type Subscription struct { HeartbeatInterval config.Duration `toml:"heartbeat_interval"` TagOnly bool `toml:"tag_only" deprecated:"1.25.0;1.35.0;please use 'tag_subscription's instead"` - fullPath *gnmiLib.Path + fullPath *gnmi.Path } // Tag Subscription for a gNMI client @@ -201,15 +201,15 @@ func (c *GNMI) Init() error { c.Log.Debugf("Internal alias mapping: %+v", c.internalAliases) // Warn about configures insecure cipher suites - insecure := internaltls.InsecureCiphers(c.ClientConfig.TLSCipherSuites) + insecure := common_tls.InsecureCiphers(c.ClientConfig.TLSCipherSuites) if len(insecure) > 0 { c.Log.Warnf("Configured insecure cipher suites: %s", strings.Join(insecure, ",")) } // Check the TLS configuration if _, err := c.ClientConfig.TLSConfig(); err != nil { - if errors.Is(err, internaltls.ErrCipherUnsupported) { - secure, insecure := internaltls.Ciphers() + if errors.Is(err, common_tls.ErrCipherUnsupported) { + secure, insecure := common_tls.Ciphers() c.Log.Info("Supported secure ciphers:") for _, name := range secure { c.Log.Infof(" %s", name) @@ -310,18 +310,18 @@ func (c *GNMI) Start(acc telegraf.Accumulator) error { return nil } -func (s *Subscription) buildSubscription() (*gnmiLib.Subscription, error) { +func (s *Subscription) buildSubscription() (*gnmi.Subscription, error) { gnmiPath, err := parsePath(s.Origin, s.Path, "") if err != nil { return nil, err } - mode, ok := gnmiLib.SubscriptionMode_value[strings.ToUpper(s.SubscriptionMode)] + mode, ok := gnmi.SubscriptionMode_value[strings.ToUpper(s.SubscriptionMode)] if !ok { return nil, fmt.Errorf("invalid subscription mode %s", s.SubscriptionMode) } - return &gnmiLib.Subscription{ + return &gnmi.Subscription{ Path: gnmiPath, - Mode: gnmiLib.SubscriptionMode(mode), + Mode: gnmi.SubscriptionMode(mode), HeartbeatInterval: uint64(time.Duration(s.HeartbeatInterval).Nanoseconds()), SampleInterval: uint64(time.Duration(s.SampleInterval).Nanoseconds()), SuppressRedundant: s.SuppressRedundant, @@ -329,9 +329,9 @@ func (s *Subscription) buildSubscription() (*gnmiLib.Subscription, error) { } // Create a new gNMI SubscribeRequest -func (c *GNMI) newSubscribeRequest() (*gnmiLib.SubscribeRequest, error) { +func (c *GNMI) newSubscribeRequest() (*gnmi.SubscribeRequest, error) { // Create subscription objects - subscriptions := make([]*gnmiLib.Subscription, 0, len(c.Subscriptions)+len(c.TagSubscriptions)) + subscriptions := make([]*gnmi.Subscription, 0, len(c.Subscriptions)+len(c.TagSubscriptions)) for _, subscription := range c.TagSubscriptions { sub, err := subscription.buildSubscription() if err != nil { @@ -363,12 +363,12 @@ func (c *GNMI) newSubscribeRequest() (*gnmiLib.SubscribeRequest, error) { return nil, fmt.Errorf("unsupported encoding %s", c.Encoding) } - return &gnmiLib.SubscribeRequest{ - Request: &gnmiLib.SubscribeRequest_Subscribe{ - Subscribe: &gnmiLib.SubscriptionList{ + return &gnmi.SubscribeRequest{ + Request: &gnmi.SubscribeRequest_Subscribe{ + Subscribe: &gnmi.SubscriptionList{ Prefix: gnmiPath, - Mode: gnmiLib.SubscriptionList_STREAM, - Encoding: gnmiLib.Encoding(gnmiLib.Encoding_value[strings.ToUpper(c.Encoding)]), + Mode: gnmi.SubscriptionList_STREAM, + Encoding: gnmi.Encoding(gnmi.Encoding_value[strings.ToUpper(c.Encoding)]), Subscription: subscriptions, UpdatesOnly: c.UpdatesOnly, }, @@ -377,7 +377,7 @@ func (c *GNMI) newSubscribeRequest() (*gnmiLib.SubscribeRequest, error) { } // ParsePath from XPath-like string to gNMI path structure -func parsePath(origin string, pathToParse string, target string) (*gnmiLib.Path, error) { +func parsePath(origin string, pathToParse string, target string) (*gnmi.Path, error) { gnmiPath, err := xpath.ToGNMIPath(pathToParse) if err != nil { return nil, err diff --git a/plugins/inputs/gnmi/gnmi_test.go b/plugins/inputs/gnmi/gnmi_test.go index 041f06c6274ae..ba66c9763b69b 100644 --- a/plugins/inputs/gnmi/gnmi_test.go +++ b/plugins/inputs/gnmi/gnmi_test.go @@ -11,8 +11,8 @@ import ( "testing" "time" - gnmiLib "github.com/openconfig/gnmi/proto/gnmi" - gnmiExt "github.com/openconfig/gnmi/proto/gnmi_ext" + "github.com/openconfig/gnmi/proto/gnmi" + "github.com/openconfig/gnmi/proto/gnmi_ext" "github.com/stretchr/testify/require" "google.golang.org/grpc" "google.golang.org/grpc/metadata" @@ -22,7 +22,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/plugins/inputs" - jnprHeader "github.com/influxdata/telegraf/plugins/inputs/gnmi/extensions/jnpr_gnmi_extention" + "github.com/influxdata/telegraf/plugins/inputs/gnmi/extensions/jnpr_gnmi_extention" "github.com/influxdata/telegraf/plugins/parsers/influx" "github.com/influxdata/telegraf/testutil" ) @@ -34,12 +34,12 @@ func TestParsePath(t *testing.T) { require.NoError(t, err) require.Equal(t, "theorigin", parsed.Origin) require.Equal(t, "thetarget", parsed.Target) - require.Equal(t, []*gnmiLib.PathElem{{Name: "foo"}, {Name: "bar"}, + require.Equal(t, []*gnmi.PathElem{{Name: "foo"}, {Name: "bar"}, {Name: "bla", Key: map[string]string{"shoo": "woo", "shoop": "/woop/"}}, {Name: "z"}}, parsed.Elem) parsed, err = parsePath("", "", "") require.NoError(t, err) - require.Equal(t, &gnmiLib.Path{}, parsed) + require.Equal(t, &gnmi.Path{}, parsed) parsed, err = parsePath("", "/foo[[", "") require.Nil(t, parsed) @@ -47,23 +47,23 @@ func TestParsePath(t *testing.T) { } type MockServer struct { - SubscribeF func(gnmiLib.GNMI_SubscribeServer) error + SubscribeF func(gnmi.GNMI_SubscribeServer) error GRPCServer *grpc.Server } -func (s *MockServer) Capabilities(context.Context, *gnmiLib.CapabilityRequest) (*gnmiLib.CapabilityResponse, error) { +func (s *MockServer) Capabilities(context.Context, *gnmi.CapabilityRequest) (*gnmi.CapabilityResponse, error) { return nil, nil } -func (s *MockServer) Get(context.Context, *gnmiLib.GetRequest) (*gnmiLib.GetResponse, error) { +func (s *MockServer) Get(context.Context, *gnmi.GetRequest) (*gnmi.GetResponse, error) { return nil, nil } -func (s *MockServer) Set(context.Context, *gnmiLib.SetRequest) (*gnmiLib.SetResponse, error) { +func (s *MockServer) Set(context.Context, *gnmi.SetRequest) (*gnmi.SetResponse, error) { return nil, nil } -func (s *MockServer) Subscribe(server gnmiLib.GNMI_SubscribeServer) error { +func (s *MockServer) Subscribe(server gnmi.GNMI_SubscribeServer) error { return s.SubscribeF(server) } @@ -73,12 +73,12 @@ func TestWaitError(t *testing.T) { grpcServer := grpc.NewServer() gnmiServer := &MockServer{ - SubscribeF: func(gnmiLib.GNMI_SubscribeServer) error { + SubscribeF: func(gnmi.GNMI_SubscribeServer) error { return errors.New("testerror") }, GRPCServer: grpcServer, } - gnmiLib.RegisterGNMIServer(grpcServer, gnmiServer) + gnmi.RegisterGNMIServer(grpcServer, gnmiServer) plugin := &GNMI{ Log: testutil.Logger{}, @@ -115,7 +115,7 @@ func TestUsernamePassword(t *testing.T) { grpcServer := grpc.NewServer() gnmiServer := &MockServer{ - SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error { + SubscribeF: func(server gnmi.GNMI_SubscribeServer) error { metadata, ok := metadata.FromIncomingContext(server.Context()) if !ok { return errors.New("failed to get metadata") @@ -135,7 +135,7 @@ func TestUsernamePassword(t *testing.T) { }, GRPCServer: grpcServer, } - gnmiLib.RegisterGNMIServer(grpcServer, gnmiServer) + gnmi.RegisterGNMIServer(grpcServer, gnmiServer) plugin := &GNMI{ Log: testutil.Logger{}, @@ -168,12 +168,12 @@ func TestUsernamePassword(t *testing.T) { require.ErrorContains(t, acc.Errors[0], "aborted gNMI subscription: rpc error: code = Unknown desc = success") } -func mockGNMINotification() *gnmiLib.Notification { - return &gnmiLib.Notification{ +func mockGNMINotification() *gnmi.Notification { + return &gnmi.Notification{ Timestamp: 1543236572000000000, - Prefix: &gnmiLib.Path{ + Prefix: &gnmi.Path{ Origin: "type", - Elem: []*gnmiLib.PathElem{ + Elem: []*gnmi.PathElem{ { Name: "model", Key: map[string]string{"foo": "bar"}, @@ -181,35 +181,35 @@ func mockGNMINotification() *gnmiLib.Notification { }, Target: "subscription", }, - Update: []*gnmiLib.Update{ + Update: []*gnmi.Update{ { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "some"}, { Name: "path", Key: map[string]string{"name": "str", "uint64": "1234"}}, }, }, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_IntVal{IntVal: 5678}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_IntVal{IntVal: 5678}}, }, { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "other"}, {Name: "path"}, }, }, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_StringVal{StringVal: "foobar"}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_StringVal{StringVal: "foobar"}}, }, { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "other"}, {Name: "this"}, }, }, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_StringVal{StringVal: "that"}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_StringVal{StringVal: "that"}}, }, }, } @@ -238,20 +238,20 @@ func TestNotification(t *testing.T) { }, }, server: &MockServer{ - SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error { + SubscribeF: func(server gnmi.GNMI_SubscribeServer) error { notification := mockGNMINotification() - err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_Update{Update: notification}}) + err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_Update{Update: notification}}) if err != nil { return err } - err = server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}) + err = server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}) if err != nil { return err } notification.Prefix.Elem[0].Key["foo"] = "bar2" notification.Update[0].Path.Elem[1].Key["name"] = "str2" - notification.Update[0].Val = &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_JsonVal{JsonVal: []byte{'"', '1', '2', '3', '"'}}} - return server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_Update{Update: notification}}) + notification.Update[0].Val = &gnmi.TypedValue{Value: &gnmi.TypedValue_JsonVal{JsonVal: []byte{'"', '1', '2', '3', '"'}}} + return server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_Update{Update: notification}}) }, }, expected: []telegraf.Metric{ @@ -327,14 +327,14 @@ func TestNotification(t *testing.T) { }, }, server: &MockServer{ - SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error { - response := &gnmiLib.SubscribeResponse{ - Response: &gnmiLib.SubscribeResponse_Update{ - Update: &gnmiLib.Notification{ + SubscribeF: func(server gnmi.GNMI_SubscribeServer) error { + response := &gnmi.SubscribeResponse{ + Response: &gnmi.SubscribeResponse_Update{ + Update: &gnmi.Notification{ Timestamp: 1543236572000000000, - Prefix: &gnmiLib.Path{ + Prefix: &gnmi.Path{ Origin: "type", - Elem: []*gnmiLib.PathElem{ + Elem: []*gnmi.PathElem{ { Name: "state", }, @@ -351,11 +351,11 @@ func TestNotification(t *testing.T) { }, Target: "subscription", }, - Update: []*gnmiLib.Update{ + Update: []*gnmi.Update{ { - Path: &gnmiLib.Path{}, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_IntVal{IntVal: 42}, + Path: &gnmi.Path{}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_IntVal{IntVal: 42}, }, }, }, @@ -403,17 +403,17 @@ func TestNotification(t *testing.T) { }, }, server: &MockServer{ - SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error { - tagResponse := &gnmiLib.SubscribeResponse{ - Response: &gnmiLib.SubscribeResponse_Update{ - Update: &gnmiLib.Notification{ + SubscribeF: func(server gnmi.GNMI_SubscribeServer) error { + tagResponse := &gnmi.SubscribeResponse{ + Response: &gnmi.SubscribeResponse_Update{ + Update: &gnmi.Notification{ Timestamp: 1543236571000000000, - Prefix: &gnmiLib.Path{}, - Update: []*gnmiLib.Update{ + Prefix: &gnmi.Path{}, + Update: []*gnmi.Update{ { - Path: &gnmiLib.Path{ + Path: &gnmi.Path{ Origin: "", - Elem: []*gnmiLib.PathElem{ + Elem: []*gnmi.PathElem{ { Name: "interfaces", }, @@ -430,8 +430,8 @@ func TestNotification(t *testing.T) { }, Target: "", }, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_StringVal{StringVal: "foo"}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_StringVal{StringVal: "foo"}, }, }, }, @@ -441,19 +441,19 @@ func TestNotification(t *testing.T) { if err := server.Send(tagResponse); err != nil { return err } - if err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil { + if err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil { return err } - taggedResponse := &gnmiLib.SubscribeResponse{ - Response: &gnmiLib.SubscribeResponse_Update{ - Update: &gnmiLib.Notification{ + taggedResponse := &gnmi.SubscribeResponse{ + Response: &gnmi.SubscribeResponse_Update{ + Update: &gnmi.Notification{ Timestamp: 1543236572000000000, - Prefix: &gnmiLib.Path{}, - Update: []*gnmiLib.Update{ + Prefix: &gnmi.Path{}, + Update: []*gnmi.Update{ { - Path: &gnmiLib.Path{ + Path: &gnmi.Path{ Origin: "", - Elem: []*gnmiLib.PathElem{ + Elem: []*gnmi.PathElem{ { Name: "interfaces", }, @@ -473,8 +473,8 @@ func TestNotification(t *testing.T) { }, Target: "", }, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_IntVal{IntVal: 42}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_IntVal{IntVal: 42}, }, }, }, @@ -526,17 +526,17 @@ func TestNotification(t *testing.T) { }, }, server: &MockServer{ - SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error { - tagResponse := &gnmiLib.SubscribeResponse{ - Response: &gnmiLib.SubscribeResponse_Update{ - Update: &gnmiLib.Notification{ + SubscribeF: func(server gnmi.GNMI_SubscribeServer) error { + tagResponse := &gnmi.SubscribeResponse{ + Response: &gnmi.SubscribeResponse_Update{ + Update: &gnmi.Notification{ Timestamp: 1543236571000000000, - Prefix: &gnmiLib.Path{}, - Update: []*gnmiLib.Update{ + Prefix: &gnmi.Path{}, + Update: []*gnmi.Update{ { - Path: &gnmiLib.Path{ + Path: &gnmi.Path{ Origin: "", - Elem: []*gnmiLib.PathElem{ + Elem: []*gnmi.PathElem{ { Name: "network-instances", }, @@ -570,8 +570,8 @@ func TestNotification(t *testing.T) { }, Target: "", }, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_StringVal{StringVal: "EXAMPLE-PEER"}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_StringVal{StringVal: "EXAMPLE-PEER"}, }, }, }, @@ -581,19 +581,19 @@ func TestNotification(t *testing.T) { if err := server.Send(tagResponse); err != nil { return err } - if err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil { + if err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil { return err } - taggedResponse := &gnmiLib.SubscribeResponse{ - Response: &gnmiLib.SubscribeResponse_Update{ - Update: &gnmiLib.Notification{ + taggedResponse := &gnmi.SubscribeResponse{ + Response: &gnmi.SubscribeResponse_Update{ + Update: &gnmi.Notification{ Timestamp: 1543236572000000000, - Prefix: &gnmiLib.Path{}, - Update: []*gnmiLib.Update{ + Prefix: &gnmi.Path{}, + Update: []*gnmi.Update{ { - Path: &gnmiLib.Path{ + Path: &gnmi.Path{ Origin: "", - Elem: []*gnmiLib.PathElem{ + Elem: []*gnmi.PathElem{ { Name: "network-instances", }, @@ -627,8 +627,8 @@ func TestNotification(t *testing.T) { }, Target: "", }, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_StringVal{StringVal: "ESTABLISHED"}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_StringVal{StringVal: "ESTABLISHED"}, }, }, }, @@ -674,17 +674,17 @@ func TestNotification(t *testing.T) { }, }, server: &MockServer{ - SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error { - if err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil { + SubscribeF: func(server gnmi.GNMI_SubscribeServer) error { + if err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil { return err } - response := &gnmiLib.SubscribeResponse{ - Response: &gnmiLib.SubscribeResponse_Update{ - Update: &gnmiLib.Notification{ + response := &gnmi.SubscribeResponse{ + Response: &gnmi.SubscribeResponse_Update{ + Update: &gnmi.Notification{ Timestamp: 1668762813698611837, - Prefix: &gnmiLib.Path{ + Prefix: &gnmi.Path{ Origin: "openconfig", - Elem: []*gnmiLib.PathElem{ + Elem: []*gnmi.PathElem{ {Name: "interfaces"}, {Name: "interface", Key: map[string]string{"name": "Ethernet1"}}, {Name: "state"}, @@ -692,54 +692,54 @@ func TestNotification(t *testing.T) { }, Target: "OC-YANG", }, - Update: []*gnmiLib.Update{ + Update: []*gnmi.Update{ { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "in-broadcast-pkts"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "in-broadcast-pkts"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "in-discards"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "in-discards"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "in-errors"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "in-errors"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "in-fcs-errors"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "in-fcs-errors"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "in-unicast-pkts"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "in-unicast-pkts"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-broadcast-pkts"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-broadcast-pkts"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-discards"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-discards"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-errors"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-errors"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-multicast-pkts"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-multicast-pkts"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-octets"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-octets"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-pkts"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-pkts"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, { - Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-unicast-pkts"}}}, - Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}}, + Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-unicast-pkts"}}}, + Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}}, }, }, }, @@ -791,90 +791,90 @@ func TestNotification(t *testing.T) { }, }, server: &MockServer{ - SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error { - if err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil { + SubscribeF: func(server gnmi.GNMI_SubscribeServer) error { + if err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil { return err } - response := &gnmiLib.SubscribeResponse{ - Response: &gnmiLib.SubscribeResponse_Update{ - Update: &gnmiLib.Notification{ + response := &gnmi.SubscribeResponse{ + Response: &gnmi.SubscribeResponse_Update{ + Update: &gnmi.Notification{ Timestamp: 1668771585733542546, - Prefix: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Prefix: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "openconfig-platform:components"}, {Name: "component", Key: map[string]string{"name": "TEMP 1"}}, {Name: "state"}, }, Target: "OC-YANG", }, - Update: []*gnmiLib.Update{ + Update: []*gnmi.Update{ { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "temperature"}, {Name: "low-threshold"}, }}, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_FloatVal{FloatVal: 0}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_FloatVal{FloatVal: 0}, }, }, { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "temperature"}, {Name: "timestamp"}, }}, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_StringVal{StringVal: "2022-11-18T11:39:26Z"}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_StringVal{StringVal: "2022-11-18T11:39:26Z"}, }, }, { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "temperature"}, {Name: "warning-status"}, }}, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_BoolVal{BoolVal: false}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_BoolVal{BoolVal: false}, }, }, { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "name"}, }}, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_StringVal{StringVal: "CPU On-board"}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_StringVal{StringVal: "CPU On-board"}, }, }, { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "temperature"}, {Name: "critical-high-threshold"}, }}, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_FloatVal{FloatVal: 94}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_FloatVal{FloatVal: 94}, }, }, { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "temperature"}, {Name: "current"}, }}, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_FloatVal{FloatVal: 29}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_FloatVal{FloatVal: 29}, }, }, { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "temperature"}, {Name: "high-threshold"}, }}, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_FloatVal{FloatVal: 90}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_FloatVal{FloatVal: 90}, }, }, }, @@ -923,48 +923,48 @@ func TestNotification(t *testing.T) { }, }, server: &MockServer{ - SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error { - if err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil { + SubscribeF: func(server gnmi.GNMI_SubscribeServer) error { + if err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil { return err } - response := &gnmiLib.SubscribeResponse{ - Response: &gnmiLib.SubscribeResponse_Update{ - Update: &gnmiLib.Notification{ + response := &gnmi.SubscribeResponse{ + Response: &gnmi.SubscribeResponse_Update{ + Update: &gnmi.Notification{ Timestamp: 1668771585733542546, - Prefix: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Prefix: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "openconfig-platform:components"}, {Name: "component", Key: map[string]string{"name": "CHASSIS0:FPC0"}}, {Name: "state"}, }, Target: "OC-YANG", }, - Update: []*gnmiLib.Update{ + Update: []*gnmi.Update{ { - Path: &gnmiLib.Path{ - Elem: []*gnmiLib.PathElem{ + Path: &gnmi.Path{ + Elem: []*gnmi.PathElem{ {Name: "type"}, }}, - Val: &gnmiLib.TypedValue{ - Value: &gnmiLib.TypedValue_StringVal{StringVal: "LINECARD"}, + Val: &gnmi.TypedValue{ + Value: &gnmi.TypedValue_StringVal{StringVal: "LINECARD"}, }, }, }, }, }, - Extension: []*gnmiExt.Extension{{ - Ext: &gnmiExt.Extension_RegisteredExt{ - RegisteredExt: &gnmiExt.RegisteredExtension{ + Extension: []*gnmi_ext.Extension{{ + Ext: &gnmi_ext.Extension_RegisteredExt{ + RegisteredExt: &gnmi_ext.RegisteredExtension{ // Juniper Header Extension //EID_JUNIPER_TELEMETRY_HEADER = 1; Id: 1, - Msg: func(jnprExt *jnprHeader.GnmiJuniperTelemetryHeaderExtension) []byte { + Msg: func(jnprExt *jnpr_gnmi_extention.GnmiJuniperTelemetryHeaderExtension) []byte { b, err := proto.Marshal(jnprExt) if err != nil { return nil } return b - }(&jnprHeader.GnmiJuniperTelemetryHeaderExtension{ComponentId: 15, SubComponentId: 1, Component: "PICD"}), + }(&jnpr_gnmi_extention.GnmiJuniperTelemetryHeaderExtension{ComponentId: 15, SubComponentId: 1, Component: "PICD"}), }, }, }}, @@ -1001,7 +1001,7 @@ func TestNotification(t *testing.T) { grpcServer := grpc.NewServer() tt.server.GRPCServer = grpcServer - gnmiLib.RegisterGNMIServer(grpcServer, tt.server) + gnmi.RegisterGNMIServer(grpcServer, tt.server) var acc testutil.Accumulator require.NoError(t, tt.plugin.Init()) @@ -1051,13 +1051,13 @@ func TestRedial(t *testing.T) { grpcServer := grpc.NewServer() gnmiServer := &MockServer{ - SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error { + SubscribeF: func(server gnmi.GNMI_SubscribeServer) error { notification := mockGNMINotification() - return server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_Update{Update: notification}}) + return server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_Update{Update: notification}}) }, GRPCServer: grpcServer, } - gnmiLib.RegisterGNMIServer(grpcServer, gnmiServer) + gnmi.RegisterGNMIServer(grpcServer, gnmiServer) var wg sync.WaitGroup wg.Add(1) @@ -1081,16 +1081,16 @@ func TestRedial(t *testing.T) { grpcServer = grpc.NewServer() gnmiServer = &MockServer{ - SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error { + SubscribeF: func(server gnmi.GNMI_SubscribeServer) error { notification := mockGNMINotification() notification.Prefix.Elem[0].Key["foo"] = "bar2" notification.Update[0].Path.Elem[1].Key["name"] = "str2" - notification.Update[0].Val = &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_BoolVal{BoolVal: false}} - return server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_Update{Update: notification}}) + notification.Update[0].Val = &gnmi.TypedValue{Value: &gnmi.TypedValue_BoolVal{BoolVal: false}} + return server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_Update{Update: notification}}) }, GRPCServer: grpcServer, } - gnmiLib.RegisterGNMIServer(grpcServer, gnmiServer) + gnmi.RegisterGNMIServer(grpcServer, gnmiServer) wg.Add(1) go func() { @@ -1131,7 +1131,7 @@ func TestCases(t *testing.T) { require.NoError(t, err) var entries []json.RawMessage require.NoError(t, json.Unmarshal(buf, &entries)) - responses := make([]gnmiLib.SubscribeResponse, len(entries)) + responses := make([]gnmi.SubscribeResponse, len(entries)) for i, entry := range entries { require.NoError(t, protojson.Unmarshal(entry, &responses[i])) } @@ -1163,9 +1163,9 @@ func TestCases(t *testing.T) { require.Len(t, cfg.Inputs, 1) // Prepare the server response - responseFunction := func(server gnmiLib.GNMI_SubscribeServer) error { - sync := &gnmiLib.SubscribeResponse{ - Response: &gnmiLib.SubscribeResponse_SyncResponse{ + responseFunction := func(server gnmi.GNMI_SubscribeServer) error { + sync := &gnmi.SubscribeResponse{ + Response: &gnmi.SubscribeResponse_SyncResponse{ SyncResponse: true, }, } @@ -1187,7 +1187,7 @@ func TestCases(t *testing.T) { SubscribeF: responseFunction, GRPCServer: grpcServer, } - gnmiLib.RegisterGNMIServer(grpcServer, gnmiServer) + gnmi.RegisterGNMIServer(grpcServer, gnmiServer) // Setup the plugin plugin := cfg.Inputs[0].Input.(*GNMI) diff --git a/plugins/inputs/gnmi/handler.go b/plugins/inputs/gnmi/handler.go index 0b420e857e67f..7ff683e8e444b 100644 --- a/plugins/inputs/gnmi/handler.go +++ b/plugins/inputs/gnmi/handler.go @@ -13,8 +13,8 @@ import ( "strings" "time" - gnmiLib "github.com/openconfig/gnmi/proto/gnmi" - gnmiExt "github.com/openconfig/gnmi/proto/gnmi_ext" + "github.com/openconfig/gnmi/proto/gnmi" + "github.com/openconfig/gnmi/proto/gnmi_ext" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" @@ -26,7 +26,7 @@ import ( "github.com/influxdata/telegraf/internal/choice" "github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/plugins/common/yangmodel" - jnprHeader "github.com/influxdata/telegraf/plugins/inputs/gnmi/extensions/jnpr_gnmi_extention" + "github.com/influxdata/telegraf/plugins/inputs/gnmi/extensions/jnpr_gnmi_extention" "github.com/influxdata/telegraf/selfstat" ) @@ -51,7 +51,7 @@ type handler struct { } // SubscribeGNMI and extract telemetry data -func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, tlscfg *tls.Config, request *gnmiLib.SubscribeRequest) error { +func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, tlscfg *tls.Config, request *gnmi.SubscribeRequest) error { var creds credentials.TransportCredentials if tlscfg != nil { creds = credentials.NewTLS(tlscfg) @@ -78,7 +78,7 @@ func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, t } defer client.Close() - subscribeClient, err := gnmiLib.NewGNMIClient(client).Subscribe(ctx) + subscribeClient, err := gnmi.NewGNMIClient(client).Subscribe(ctx) if err != nil { return fmt.Errorf("failed to setup subscription: %w", err) } @@ -99,7 +99,7 @@ func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, t defer h.log.Debugf("Connection to gNMI device %s closed", h.address) for ctx.Err() == nil { - var reply *gnmiLib.SubscribeResponse + var reply *gnmi.SubscribeResponse if reply, err = subscribeClient.Recv(); err != nil { if !errors.Is(err, io.EOF) && ctx.Err() == nil { connectStat.Set(0) @@ -117,7 +117,7 @@ func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, t h.log.Debugf("Got update_%v: %s", t, string(buf)) } } - if response, ok := reply.Response.(*gnmiLib.SubscribeResponse_Update); ok { + if response, ok := reply.Response.(*gnmi.SubscribeResponse_Update); ok { h.handleSubscribeResponseUpdate(acc, response, reply.GetExtension()) } } @@ -127,7 +127,7 @@ func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, t } // Handle SubscribeResponse_Update message from gNMI and parse contained telemetry data -func (h *handler) handleSubscribeResponseUpdate(acc telegraf.Accumulator, response *gnmiLib.SubscribeResponse_Update, extension []*gnmiExt.Extension) { +func (h *handler) handleSubscribeResponseUpdate(acc telegraf.Accumulator, response *gnmi.SubscribeResponse_Update, extension []*gnmi_ext.Extension) { grouper := metric.NewSeriesGrouper() timestamp := time.Unix(0, response.Update.Timestamp) @@ -144,7 +144,7 @@ func (h *handler) handleSubscribeResponseUpdate(acc telegraf.Accumulator, respon // Juniper Header extension // Decode it only if user requested it if choice.Contains("juniper_header", h.vendorExt) { - juniperHeader := &jnprHeader.GnmiJuniperTelemetryHeaderExtension{} + juniperHeader := &jnpr_gnmi_extention.GnmiJuniperTelemetryHeaderExtension{} if err := proto.Unmarshal(currentExt, juniperHeader); err != nil { h.log.Errorf("unmarshal gnmi Juniper Header extension failed: %v", err) } else { diff --git a/plugins/inputs/gnmi/path.go b/plugins/inputs/gnmi/path.go index cdb074be9bba1..8f2f782243c32 100644 --- a/plugins/inputs/gnmi/path.go +++ b/plugins/inputs/gnmi/path.go @@ -3,7 +3,7 @@ package gnmi import ( "strings" - gnmiLib "github.com/openconfig/gnmi/proto/gnmi" + "github.com/openconfig/gnmi/proto/gnmi" ) type keySegment struct { @@ -41,7 +41,7 @@ func newInfoFromString(path string) *pathInfo { return info } -func newInfoFromPathWithoutKeys(path *gnmiLib.Path) *pathInfo { +func newInfoFromPathWithoutKeys(path *gnmi.Path) *pathInfo { info := &pathInfo{ origin: path.Origin, segments: make([]segment, 0, len(path.Elem)), @@ -57,7 +57,7 @@ func newInfoFromPathWithoutKeys(path *gnmiLib.Path) *pathInfo { return info } -func newInfoFromPath(paths ...*gnmiLib.Path) *pathInfo { +func newInfoFromPath(paths ...*gnmi.Path) *pathInfo { if len(paths) == 0 { return nil } @@ -101,7 +101,7 @@ func (pi *pathInfo) empty() bool { return len(pi.segments) == 0 } -func (pi *pathInfo) append(paths ...*gnmiLib.Path) *pathInfo { +func (pi *pathInfo) append(paths ...*gnmi.Path) *pathInfo { // Copy the existing info path := &pathInfo{ origin: pi.origin, @@ -209,7 +209,7 @@ func (pi *pathInfo) normalize() { pi.segments = segments } -func (pi *pathInfo) equalsPathNoKeys(path *gnmiLib.Path) bool { +func (pi *pathInfo) equalsPathNoKeys(path *gnmi.Path) bool { if len(pi.segments) != len(path.Elem) { return false } diff --git a/plugins/inputs/gnmi/update_fields.go b/plugins/inputs/gnmi/update_fields.go index a4298b6d84d56..90036a81f87f5 100644 --- a/plugins/inputs/gnmi/update_fields.go +++ b/plugins/inputs/gnmi/update_fields.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - gnmiLib "github.com/openconfig/gnmi/proto/gnmi" - gnmiValue "github.com/openconfig/gnmi/value" + "github.com/openconfig/gnmi/proto/gnmi" + gnmi_value "github.com/openconfig/gnmi/value" ) type keyValuePair struct { @@ -20,23 +20,23 @@ type updateField struct { value interface{} } -func (h *handler) newFieldsFromUpdate(path *pathInfo, update *gnmiLib.Update) ([]updateField, error) { +func (h *handler) newFieldsFromUpdate(path *pathInfo, update *gnmi.Update) ([]updateField, error) { if update.Val == nil || update.Val.Value == nil { return []updateField{{path: path}}, nil } // Apply some special handling for special types switch v := update.Val.Value.(type) { - case *gnmiLib.TypedValue_AsciiVal: // not handled in ToScalar + case *gnmi.TypedValue_AsciiVal: // not handled in ToScalar return []updateField{{path, v.AsciiVal}}, nil - case *gnmiLib.TypedValue_JsonVal: // requires special path handling + case *gnmi.TypedValue_JsonVal: // requires special path handling return processJSON(path, v.JsonVal) - case *gnmiLib.TypedValue_JsonIetfVal: // requires special path handling + case *gnmi.TypedValue_JsonIetfVal: // requires special path handling return h.processJSONIETF(path, v.JsonIetfVal) } // Convert the protobuf "oneof" data to a Golang type. - value, err := gnmiValue.ToScalar(update.Val) + value, err := gnmi_value.ToScalar(update.Val) if err != nil { return nil, err } diff --git a/plugins/inputs/http/http.go b/plugins/inputs/http/http.go index c2b74e77c870a..3853f676cd4eb 100644 --- a/plugins/inputs/http/http.go +++ b/plugins/inputs/http/http.go @@ -16,7 +16,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -44,7 +44,7 @@ type HTTP struct { SuccessStatusCodes []int `toml:"success_status_codes"` Log telegraf.Logger `toml:"-"` - httpconfig.HTTPClientConfig + common_http.HTTPClientConfig client *http.Client parserFunc telegraf.ParserFunc diff --git a/plugins/inputs/http/http_test.go b/plugins/inputs/http/http_test.go index 2848228a066d5..19a500ce38151 100644 --- a/plugins/inputs/http/http_test.go +++ b/plugins/inputs/http/http_test.go @@ -19,7 +19,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/common/oauth" httpplugin "github.com/influxdata/telegraf/plugins/inputs/http" "github.com/influxdata/telegraf/plugins/parsers/csv" @@ -349,7 +349,7 @@ func TestOAuthClientCredentialsGrant(t *testing.T) { name: "success", plugin: &httpplugin.HTTP{ URLs: []string{u.String() + "/write"}, - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ OAuth2Config: oauth.OAuth2Config{ ClientID: "howdy", ClientSecret: "secret", diff --git a/plugins/inputs/http_listener_v2/http_listener_v2.go b/plugins/inputs/http_listener_v2/http_listener_v2.go index 78d9dbfdf8a0b..0f68a4cb0c1f4 100644 --- a/plugins/inputs/http_listener_v2/http_listener_v2.go +++ b/plugins/inputs/http_listener_v2/http_listener_v2.go @@ -21,7 +21,7 @@ import ( "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/internal/choice" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -62,7 +62,7 @@ type HTTPListenerV2 struct { BasicPassword string `toml:"basic_password"` HTTPHeaderTags map[string]string `toml:"http_header_tags"` - tlsint.ServerConfig + common_tls.ServerConfig tlsConf *tls.Config TimeFunc diff --git a/plugins/inputs/influxdb_listener/influxdb_listener.go b/plugins/inputs/influxdb_listener/influxdb_listener.go index 30225ea1395b5..2c54088b34fce 100644 --- a/plugins/inputs/influxdb_listener/influxdb_listener.go +++ b/plugins/inputs/influxdb_listener/influxdb_listener.go @@ -16,7 +16,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/parsers/influx" "github.com/influxdata/telegraf/plugins/parsers/influx/influx_upstream" @@ -35,7 +35,7 @@ const ( type InfluxDBListener struct { ServiceAddress string `toml:"service_address"` port int - tlsint.ServerConfig + common_tls.ServerConfig ReadTimeout config.Duration `toml:"read_timeout"` WriteTimeout config.Duration `toml:"write_timeout"` diff --git a/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go b/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go index f53fa437ddcf1..612521f97b4bc 100644 --- a/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go +++ b/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go @@ -20,7 +20,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/parsers/influx" "github.com/influxdata/telegraf/plugins/parsers/influx/influx_upstream" @@ -52,7 +52,7 @@ const ( type InfluxDBV2Listener struct { ServiceAddress string `toml:"service_address"` port int - tlsint.ServerConfig + common_tls.ServerConfig MaxUndeliveredMetrics int `toml:"max_undelivered_metrics"` ReadTimeout config.Duration `toml:"read_timeout"` diff --git a/plugins/inputs/intel_powerstat/intel_powerstat.go b/plugins/inputs/intel_powerstat/intel_powerstat.go index d4ddc7b7b3049..bd1ffe6566750 100644 --- a/plugins/inputs/intel_powerstat/intel_powerstat.go +++ b/plugins/inputs/intel_powerstat/intel_powerstat.go @@ -13,8 +13,8 @@ import ( "strings" "time" - ptel "github.com/intel/powertelemetry" - cpuUtil "github.com/shirou/gopsutil/v3/cpu" + "github.com/intel/powertelemetry" + "github.com/shirou/gopsutil/v3/cpu" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" @@ -90,8 +90,8 @@ func (p *PowerStat) Start(_ telegraf.Accumulator) error { }) var err error - var initErr *ptel.MultiError - p.fetcher, err = ptel.New(opts...) + var initErr *powertelemetry.MultiError + p.fetcher, err = powertelemetry.New(opts...) if err != nil { if !errors.As(err, &initErr) { // Error caused by failing to get information about the CPU, or CPU is not supported. @@ -441,7 +441,7 @@ func (p *PowerStat) addPerCPUMsrMetrics(acc telegraf.Accumulator, cpuID, coreID, } // Read several time-related MSR offsets. - var moduleErr *ptel.ModuleNotInitializedError + var moduleErr *powertelemetry.ModuleNotInitializedError err := p.fetcher.UpdatePerCPUMetrics(cpuID) if err == nil { // Add time-related MSR offset metrics to the accumulator @@ -490,7 +490,7 @@ func (p *PowerStat) addCPUTimeRelatedMsrMetrics(acc telegraf.Accumulator, cpuID, // addCPUPerfMetrics takes an accumulator, and adds to it enabled metrics which rely on perf. func (p *PowerStat) addCPUPerfMetrics(acc telegraf.Accumulator) { - var moduleErr *ptel.ModuleNotInitializedError + var moduleErr *powertelemetry.ModuleNotInitializedError // Read events related to perf-related metrics. err := p.fetcher.ReadPerfEvents() @@ -921,7 +921,7 @@ func (p *PowerStat) addUncoreFrequencyInitialLimits(acc telegraf.Accumulator, pa } // Always add to the accumulator errors not related to module not initialized. - var moduleErr *ptel.ModuleNotInitializedError + var moduleErr *powertelemetry.ModuleNotInitializedError if !errors.As(err, &moduleErr) { acc.AddError(fmt.Errorf("failed to get initial uncore frequency limits for package ID %v and die ID %v: %w", packageID, dieID, err)) return @@ -961,7 +961,7 @@ func (p *PowerStat) addUncoreFrequencyCurrentValues(acc telegraf.Accumulator, pa } // Always add to the accumulator errors not related to module not initialized. - var moduleErr *ptel.ModuleNotInitializedError + var moduleErr *powertelemetry.ModuleNotInitializedError if !errors.As(err, &moduleErr) { acc.AddError(fmt.Errorf("failed to get current uncore frequency values for package ID %v and die ID %v: %w", packageID, dieID, err)) return @@ -1024,7 +1024,7 @@ func getUncoreFreqCurrentValues(fetcher metricFetcher, packageID, dieID int) (un // addMaxTurboFreqLimits fetches the max turbo frequency limits metric for a given package ID, and adds it to the accumulator. func (p *PowerStat) addMaxTurboFreqLimits(acc telegraf.Accumulator, packageID int) { - var moduleErr *ptel.ModuleNotInitializedError + var moduleErr *powertelemetry.ModuleNotInitializedError turboFreqList, err := p.fetcher.GetMaxTurboFreqList(packageID) if err != nil { @@ -1076,7 +1076,7 @@ func (p *PowerStat) addMaxTurboFreqLimits(acc telegraf.Accumulator, packageID in // isHybridCPU is a helper function that takes a slice of MaxTurboFreq structs and returns true if the CPU where these values belong to, // is a hybrid CPU. Otherwise, returns false. -func isHybridCPU(turboFreqList []ptel.MaxTurboFreq) bool { +func isHybridCPU(turboFreqList []powertelemetry.MaxTurboFreq) bool { for _, v := range turboFreqList { if v.Secondary { return true @@ -1089,7 +1089,7 @@ func isHybridCPU(turboFreqList []ptel.MaxTurboFreq) bool { // In case it is not, disableUnsupportedMetrics will disable the option to gather those metrics. // Error is returned if there is an issue with retrieving processor information. func (p *PowerStat) disableUnsupportedMetrics() error { - cpus, err := cpuUtil.Info() + cpus, err := cpu.Info() if err != nil { return fmt.Errorf("error occurred while parsing CPU information: %w", err) } @@ -1104,27 +1104,27 @@ func (p *PowerStat) disableUnsupportedMetrics() error { return fmt.Errorf("error occurred while parsing CPU model: %w", err) } - if err := ptel.CheckIfCPUC1StateResidencySupported(cpuModel); err != nil { + if err := powertelemetry.CheckIfCPUC1StateResidencySupported(cpuModel); err != nil { p.disableCPUMetric(cpuC1StateResidency) } - if err := ptel.CheckIfCPUC3StateResidencySupported(cpuModel); err != nil { + if err := powertelemetry.CheckIfCPUC3StateResidencySupported(cpuModel); err != nil { p.disableCPUMetric(cpuC3StateResidency) } - if err := ptel.CheckIfCPUC6StateResidencySupported(cpuModel); err != nil { + if err := powertelemetry.CheckIfCPUC6StateResidencySupported(cpuModel); err != nil { p.disableCPUMetric(cpuC6StateResidency) } - if err := ptel.CheckIfCPUC7StateResidencySupported(cpuModel); err != nil { + if err := powertelemetry.CheckIfCPUC7StateResidencySupported(cpuModel); err != nil { p.disableCPUMetric(cpuC7StateResidency) } - if err := ptel.CheckIfCPUTemperatureSupported(cpuModel); err != nil { + if err := powertelemetry.CheckIfCPUTemperatureSupported(cpuModel); err != nil { p.disableCPUMetric(cpuTemperature) } - if err := ptel.CheckIfCPUBaseFrequencySupported(cpuModel); err != nil { + if err := powertelemetry.CheckIfCPUBaseFrequencySupported(cpuModel); err != nil { p.disablePackageMetric(packageCPUBaseFrequency) } diff --git a/plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry.go b/plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry.go index 19d8c151063ab..f8859f627c5f5 100644 --- a/plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry.go +++ b/plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry.go @@ -22,10 +22,10 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - internaltls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" - authentication "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/auth" - telemetry "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/oc" + "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/auth" + "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/oc" ) //go:embed sample.conf @@ -43,7 +43,7 @@ type OpenConfigTelemetry struct { RetryDelay config.Duration `toml:"retry_delay"` EnableTLS bool `toml:"enable_tls"` KeepAlivePeriod config.Duration `toml:"keep_alive_period"` - internaltls.ClientConfig + common_tls.ClientConfig Log telegraf.Logger diff --git a/plugins/inputs/kafka_consumer/kafka_consumer_test.go b/plugins/inputs/kafka_consumer/kafka_consumer_test.go index 0b18dea497638..577f469144929 100644 --- a/plugins/inputs/kafka_consumer/kafka_consumer_test.go +++ b/plugins/inputs/kafka_consumer/kafka_consumer_test.go @@ -18,10 +18,10 @@ import ( "github.com/influxdata/telegraf/plugins/common/kafka" "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/outputs" - kafkaOutput "github.com/influxdata/telegraf/plugins/outputs/kafka" + kafka_output "github.com/influxdata/telegraf/plugins/outputs/kafka" "github.com/influxdata/telegraf/plugins/parsers/influx" "github.com/influxdata/telegraf/plugins/parsers/value" - influxSerializer "github.com/influxdata/telegraf/plugins/serializers/influx" + influx_serializer "github.com/influxdata/telegraf/plugins/serializers/influx" "github.com/influxdata/telegraf/testutil" ) @@ -500,10 +500,10 @@ func TestKafkaRoundTripIntegration(t *testing.T) { // Make kafka output t.Logf("rt: starting output plugin") creator := outputs.Outputs["kafka"] - output, ok := creator().(*kafkaOutput.Kafka) + output, ok := creator().(*kafka_output.Kafka) require.True(t, ok) - s := &influxSerializer.Serializer{} + s := &influx_serializer.Serializer{} require.NoError(t, s.Init()) output.SetSerializer(s) output.Brokers = brokers @@ -576,10 +576,10 @@ func TestKafkaTimestampSourceIntegration(t *testing.T) { // Make kafka output creator := outputs.Outputs["kafka"] - output, ok := creator().(*kafkaOutput.Kafka) + output, ok := creator().(*kafka_output.Kafka) require.True(t, ok) - s := &influxSerializer.Serializer{} + s := &influx_serializer.Serializer{} require.NoError(t, s.Init()) output.SetSerializer(s) output.Brokers = brokers diff --git a/plugins/inputs/kibana/kibana.go b/plugins/inputs/kibana/kibana.go index 5b8220a4187f5..0ecbe4bd6f3a0 100644 --- a/plugins/inputs/kibana/kibana.go +++ b/plugins/inputs/kibana/kibana.go @@ -15,7 +15,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -95,12 +95,12 @@ type Kibana struct { Log telegraf.Logger `toml:"-"` client *http.Client - httpconfig.HTTPClientConfig + common_http.HTTPClientConfig } func NewKibana() *Kibana { return &Kibana{ - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ Timeout: config.Duration(5 * time.Second), }, } diff --git a/plugins/inputs/kinesis_consumer/kinesis_consumer.go b/plugins/inputs/kinesis_consumer/kinesis_consumer.go index a9b9a160f9a05..b75a7c7d58ea0 100644 --- a/plugins/inputs/kinesis_consumer/kinesis_consumer.go +++ b/plugins/inputs/kinesis_consumer/kinesis_consumer.go @@ -22,7 +22,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/internal" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" + common_aws "github.com/influxdata/telegraf/plugins/common/aws" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -63,7 +63,7 @@ type ( lastSeqNum *big.Int - internalaws.CredentialConfig + common_aws.CredentialConfig } checkpoint struct { diff --git a/plugins/inputs/kube_inventory/daemonset.go b/plugins/inputs/kube_inventory/daemonset.go index 33f13f5c988d1..f7dcf04e7048e 100644 --- a/plugins/inputs/kube_inventory/daemonset.go +++ b/plugins/inputs/kube_inventory/daemonset.go @@ -3,7 +3,7 @@ package kube_inventory import ( "context" - v1 "k8s.io/api/apps/v1" + "k8s.io/api/apps/v1" "github.com/influxdata/telegraf" ) diff --git a/plugins/inputs/kube_inventory/daemonset_test.go b/plugins/inputs/kube_inventory/daemonset_test.go index 0c6cc87a9a5f0..703e646705d1f 100644 --- a/plugins/inputs/kube_inventory/daemonset_test.go +++ b/plugins/inputs/kube_inventory/daemonset_test.go @@ -6,7 +6,7 @@ import ( "time" "github.com/stretchr/testify/require" - v1 "k8s.io/api/apps/v1" + "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/influxdata/telegraf" diff --git a/plugins/inputs/kube_inventory/deployment.go b/plugins/inputs/kube_inventory/deployment.go index 4d4a938db1f32..68d33e852d875 100644 --- a/plugins/inputs/kube_inventory/deployment.go +++ b/plugins/inputs/kube_inventory/deployment.go @@ -3,7 +3,7 @@ package kube_inventory import ( "context" - v1 "k8s.io/api/apps/v1" + "k8s.io/api/apps/v1" "github.com/influxdata/telegraf" ) diff --git a/plugins/inputs/kube_inventory/deployment_test.go b/plugins/inputs/kube_inventory/deployment_test.go index ccd7c0d60078b..b854a6d397658 100644 --- a/plugins/inputs/kube_inventory/deployment_test.go +++ b/plugins/inputs/kube_inventory/deployment_test.go @@ -6,7 +6,7 @@ import ( "time" "github.com/stretchr/testify/require" - v1 "k8s.io/api/apps/v1" + "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" diff --git a/plugins/inputs/kube_inventory/endpoint_test.go b/plugins/inputs/kube_inventory/endpoint_test.go index 936a64b72544b..f5be722c925bc 100644 --- a/plugins/inputs/kube_inventory/endpoint_test.go +++ b/plugins/inputs/kube_inventory/endpoint_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - v1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/influxdata/telegraf" diff --git a/plugins/inputs/kube_inventory/statefulset.go b/plugins/inputs/kube_inventory/statefulset.go index ee61d728fdad0..77b2a56bb0b6e 100644 --- a/plugins/inputs/kube_inventory/statefulset.go +++ b/plugins/inputs/kube_inventory/statefulset.go @@ -3,7 +3,7 @@ package kube_inventory import ( "context" - v1 "k8s.io/api/apps/v1" + "k8s.io/api/apps/v1" "github.com/influxdata/telegraf" ) diff --git a/plugins/inputs/kube_inventory/statefulset_test.go b/plugins/inputs/kube_inventory/statefulset_test.go index 8caa0b14a1253..139d308249930 100644 --- a/plugins/inputs/kube_inventory/statefulset_test.go +++ b/plugins/inputs/kube_inventory/statefulset_test.go @@ -6,7 +6,7 @@ import ( "time" "github.com/stretchr/testify/require" - v1 "k8s.io/api/apps/v1" + "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/influxdata/telegraf" diff --git a/plugins/inputs/kubernetes/kubernetes.go b/plugins/inputs/kubernetes/kubernetes.go index 82a352a7683f5..7b0bd9248852d 100644 --- a/plugins/inputs/kubernetes/kubernetes.go +++ b/plugins/inputs/kubernetes/kubernetes.go @@ -12,7 +12,7 @@ import ( "sync" "time" - v1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" diff --git a/plugins/inputs/ldap/ldap.go b/plugins/inputs/ldap/ldap.go index eb1e61fbfe637..7a69871ca5bd6 100644 --- a/plugins/inputs/ldap/ldap.go +++ b/plugins/inputs/ldap/ldap.go @@ -13,7 +13,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - commontls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -26,7 +26,7 @@ type LDAP struct { BindDn string `toml:"bind_dn"` BindPassword config.Secret `toml:"bind_password"` ReverseFieldNames bool `toml:"reverse_field_names"` - commontls.ClientConfig + common_tls.ClientConfig tlsCfg *tls.Config requests []request diff --git a/plugins/inputs/ldap/ldap_test.go b/plugins/inputs/ldap/ldap_test.go index c512ac25c7a80..c67c57f56e39e 100644 --- a/plugins/inputs/ldap/ldap_test.go +++ b/plugins/inputs/ldap/ldap_test.go @@ -12,7 +12,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/metric" - commontls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/testutil" ) @@ -272,7 +272,7 @@ func TestOpenLDAPReverseDNIntegration(t *testing.T) { testutil.RequireMetricsStructureEqual(t, expected, actual, testutil.IgnoreTime()) } -func TestOpenLDAPStartTLSIntegration(t *testing.T) { +func TestOpenLDAPStarttls_internalegration(t *testing.T) { if testing.Short() { t.Skip("Skipping integration test in short mode") } @@ -312,7 +312,7 @@ func TestOpenLDAPStartTLSIntegration(t *testing.T) { Server: "starttls://" + container.Address + ":" + port, BindDn: "CN=manager,DC=example,DC=org", BindPassword: config.NewSecret([]byte("secret")), - ClientConfig: commontls.ClientConfig{ + ClientConfig: common_tls.ClientConfig{ TLSCA: pkiPaths.ClientCert, InsecureSkipVerify: true, }, @@ -420,7 +420,7 @@ func TestOpenLDAPLDAPSIntegration(t *testing.T) { Server: "ldaps://" + container.Address + ":" + port, BindDn: "CN=manager,DC=example,DC=org", BindPassword: config.NewSecret([]byte("secret")), - ClientConfig: commontls.ClientConfig{ + ClientConfig: common_tls.ClientConfig{ InsecureSkipVerify: true, }, } diff --git a/plugins/inputs/logstash/logstash.go b/plugins/inputs/logstash/logstash.go index ea9d401801eba..85026f2c8567a 100644 --- a/plugins/inputs/logstash/logstash.go +++ b/plugins/inputs/logstash/logstash.go @@ -15,9 +15,9 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal/choice" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/inputs" - jsonParser "github.com/influxdata/telegraf/plugins/parsers/json" + jsonparser "github.com/influxdata/telegraf/plugins/parsers/json" ) //go:embed sample.conf @@ -36,7 +36,7 @@ type Logstash struct { Log telegraf.Logger `toml:"-"` client *http.Client - httpconfig.HTTPClientConfig + common_http.HTTPClientConfig } // NewLogstash create an instance of the plugin with default settings @@ -46,7 +46,7 @@ func NewLogstash() *Logstash { SinglePipeline: false, Collect: []string{"pipelines", "process", "jvm"}, Headers: make(map[string]string), - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ Timeout: config.Duration(5 * time.Second), }, } @@ -194,7 +194,7 @@ func (logstash *Logstash) gatherJVMStats(address string, accumulator telegraf.Ac "source": jvmStats.Host, } - flattener := jsonParser.JSONFlattener{} + flattener := jsonparser.JSONFlattener{} err = flattener.FlattenJSON("", jvmStats.JVM) if err != nil { return err @@ -220,7 +220,7 @@ func (logstash *Logstash) gatherProcessStats(address string, accumulator telegra "source": processStats.Host, } - flattener := jsonParser.JSONFlattener{} + flattener := jsonparser.JSONFlattener{} err = flattener.FlattenJSON("", processStats.Process) if err != nil { return err @@ -246,7 +246,7 @@ func (logstash *Logstash) gatherPluginsStats( for tag, value := range tags { pluginTags[tag] = value } - flattener := jsonParser.JSONFlattener{} + flattener := jsonparser.JSONFlattener{} err := flattener.FlattenJSON("", plugin.Events) if err != nil { return err @@ -275,7 +275,7 @@ func (logstash *Logstash) gatherPluginsStats( "with_errors": 9089 }, */ - flattener := jsonParser.JSONFlattener{} + flattener := jsonparser.JSONFlattener{} err := flattener.FlattenJSON("", plugin.BulkRequests) if err != nil { return err @@ -298,7 +298,7 @@ func (logstash *Logstash) gatherPluginsStats( "retryable_failures": 13733 } */ - flattener = jsonParser.JSONFlattener{} + flattener = jsonparser.JSONFlattener{} err = flattener.FlattenJSON("", plugin.Documents) if err != nil { return err @@ -336,7 +336,7 @@ func (logstash *Logstash) gatherQueueStats(queue PipelineQueue, tags map[string] } if queue.Type != "memory" { - flattener := jsonParser.JSONFlattener{} + flattener := jsonparser.JSONFlattener{} err := flattener.FlattenJSON("", queue.Capacity) if err != nil { return err @@ -379,7 +379,7 @@ func (logstash *Logstash) gatherPipelineStats(address string, accumulator telegr "source": pipelineStats.Host, } - flattener := jsonParser.JSONFlattener{} + flattener := jsonparser.JSONFlattener{} err = flattener.FlattenJSON("", pipelineStats.Pipeline.Events) if err != nil { return err @@ -425,7 +425,7 @@ func (logstash *Logstash) gatherPipelinesStats(address string, accumulator teleg "source": pipelinesStats.Host, } - flattener := jsonParser.JSONFlattener{} + flattener := jsonparser.JSONFlattener{} err := flattener.FlattenJSON("", pipeline.Events) if err != nil { return err diff --git a/plugins/inputs/memcached/memcached.go b/plugins/inputs/memcached/memcached.go index 2175e8fb7d94c..5819b1f9e6437 100644 --- a/plugins/inputs/memcached/memcached.go +++ b/plugins/inputs/memcached/memcached.go @@ -15,7 +15,7 @@ import ( "golang.org/x/net/proxy" "github.com/influxdata/telegraf" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -27,7 +27,7 @@ type Memcached struct { Servers []string `toml:"servers"` UnixSockets []string `toml:"unix_sockets"` EnableTLS bool `toml:"enable_tls"` - tlsint.ClientConfig + common_tls.ClientConfig } var defaultTimeout = 5 * time.Second diff --git a/plugins/inputs/mongodb/mongodb.go b/plugins/inputs/mongodb/mongodb.go index 06b98d039e95e..65c323c18e3ee 100644 --- a/plugins/inputs/mongodb/mongodb.go +++ b/plugins/inputs/mongodb/mongodb.go @@ -19,7 +19,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/internal/choice" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -37,7 +37,7 @@ type MongoDB struct { GatherTopStat bool DisconnectedServersBehavior string ColStatsDbs []string - tlsint.ClientConfig + common_tls.ClientConfig Log telegraf.Logger `toml:"-"` diff --git a/plugins/inputs/mysql/mysql.go b/plugins/inputs/mysql/mysql.go index be3b3e85b8243..0c648184b790d 100644 --- a/plugins/inputs/mysql/mysql.go +++ b/plugins/inputs/mysql/mysql.go @@ -20,8 +20,8 @@ import ( "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" - v1 "github.com/influxdata/telegraf/plugins/inputs/mysql/v1" - v2 "github.com/influxdata/telegraf/plugins/inputs/mysql/v2" + "github.com/influxdata/telegraf/plugins/inputs/mysql/v1" + "github.com/influxdata/telegraf/plugins/inputs/mysql/v2" ) //go:embed sample.conf diff --git a/plugins/inputs/opensearch_query/opensearch_query.go b/plugins/inputs/opensearch_query/opensearch_query.go index 51926f1f7256c..7951072fa0a0a 100644 --- a/plugins/inputs/opensearch_query/opensearch_query.go +++ b/plugins/inputs/opensearch_query/opensearch_query.go @@ -18,7 +18,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - influxtls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -37,7 +37,7 @@ type OpensearchQuery struct { Log telegraf.Logger `toml:"-"` - influxtls.ClientConfig + common_tls.ClientConfig osClient *opensearch.Client } diff --git a/plugins/inputs/openstack/openstack.go b/plugins/inputs/openstack/openstack.go index 35fd1a5d0dfaa..c4217ec34b058 100644 --- a/plugins/inputs/openstack/openstack.go +++ b/plugins/inputs/openstack/openstack.go @@ -44,7 +44,7 @@ import ( "github.com/gophercloud/gophercloud/v2/openstack/orchestration/v1/stacks" "github.com/influxdata/telegraf" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -74,7 +74,7 @@ type OpenStack struct { MeasureRequest bool `toml:"measure_openstack_requests"` AllTenants bool `toml:"query_all_tenants"` Log telegraf.Logger `toml:"-"` - httpconfig.HTTPClientConfig + common_http.HTTPClientConfig client *http.Client diff --git a/plugins/inputs/opentelemetry/opentelemetry_test.go b/plugins/inputs/opentelemetry/opentelemetry_test.go index f4492e941d541..06143958dd90d 100644 --- a/plugins/inputs/opentelemetry/opentelemetry_test.go +++ b/plugins/inputs/opentelemetry/opentelemetry_test.go @@ -27,7 +27,7 @@ import ( "github.com/influxdata/influxdb-observability/otel2influx" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - tmetric "github.com/influxdata/telegraf/metric" + telegraf_metric "github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/parsers/influx" "github.com/influxdata/telegraf/testutil" @@ -86,7 +86,7 @@ func TestOpenTelemetry(t *testing.T) { exesuffix = ".exe" } expected := []telegraf.Metric{ - tmetric.New( + telegraf_metric.New( "measurement-counter", map[string]string{ "otel.library.name": "library-name", diff --git a/plugins/inputs/p4runtime/p4runtime.go b/plugins/inputs/p4runtime/p4runtime.go index f1dd9f4dcf0cf..6f4f8df56554d 100644 --- a/plugins/inputs/p4runtime/p4runtime.go +++ b/plugins/inputs/p4runtime/p4runtime.go @@ -11,14 +11,14 @@ import ( "slices" "sync" - p4ConfigV1 "github.com/p4lang/p4runtime/go/p4/config/v1" - p4v1 "github.com/p4lang/p4runtime/go/p4/v1" + p4_config_v1 "github.com/p4lang/p4runtime/go/p4/config/v1" + p4_v1 "github.com/p4lang/p4runtime/go/p4/v1" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" "github.com/influxdata/telegraf" - internaltls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -36,10 +36,10 @@ type P4runtime struct { CounterNamesInclude []string `toml:"counter_names_include"` Log telegraf.Logger `toml:"-"` EnableTLS bool `toml:"enable_tls"` - internaltls.ClientConfig + common_tls.ClientConfig conn *grpc.ClientConn - client p4v1.P4RuntimeClient + client p4_v1.P4RuntimeClient wg sync.WaitGroup } @@ -75,7 +75,7 @@ func (p *P4runtime) Gather(acc telegraf.Accumulator) error { for _, counter := range filteredCounters { p.wg.Add(1) - go func(counter *p4ConfigV1.Counter) { + go func(counter *p4_config_v1.Counter) { defer p.wg.Done() entries, err := p.readAllEntries(counter.Preamble.Id) if err != nil { @@ -136,10 +136,10 @@ func initConnection(endpoint string, tlscfg *tls.Config) (*grpc.ClientConn, erro return grpc.NewClient(endpoint, grpc.WithTransportCredentials(creds)) } -func (p *P4runtime) getP4Info() (*p4ConfigV1.P4Info, error) { - req := &p4v1.GetForwardingPipelineConfigRequest{ +func (p *P4runtime) getP4Info() (*p4_config_v1.P4Info, error) { + req := &p4_v1.GetForwardingPipelineConfigRequest{ DeviceId: p.DeviceID, - ResponseType: p4v1.GetForwardingPipelineConfigRequest_ALL, + ResponseType: p4_v1.GetForwardingPipelineConfigRequest_ALL, } resp, err := p.client.GetForwardingPipelineConfig(context.Background(), req) if err != nil { @@ -165,12 +165,12 @@ func (p *P4runtime) getP4Info() (*p4ConfigV1.P4Info, error) { return p4info, nil } -func filterCounters(counters []*p4ConfigV1.Counter, counterNamesInclude []string) []*p4ConfigV1.Counter { +func filterCounters(counters []*p4_config_v1.Counter, counterNamesInclude []string) []*p4_config_v1.Counter { if len(counterNamesInclude) == 0 { return counters } - var filteredCounters []*p4ConfigV1.Counter + var filteredCounters []*p4_config_v1.Counter for _, counter := range counters { if counter == nil { continue @@ -197,16 +197,16 @@ func (p *P4runtime) newP4RuntimeClient() error { return fmt.Errorf("cannot connect to the server: %w", err) } p.conn = conn - p.client = p4v1.NewP4RuntimeClient(conn) + p.client = p4_v1.NewP4RuntimeClient(conn) return nil } -func (p *P4runtime) readAllEntries(counterID uint32) ([]*p4v1.Entity, error) { - readRequest := &p4v1.ReadRequest{ +func (p *P4runtime) readAllEntries(counterID uint32) ([]*p4_v1.Entity, error) { + readRequest := &p4_v1.ReadRequest{ DeviceId: p.DeviceID, - Entities: []*p4v1.Entity{{ - Entity: &p4v1.Entity_CounterEntry{ - CounterEntry: &p4v1.CounterEntry{ + Entities: []*p4_v1.Entity{{ + Entity: &p4_v1.Entity_CounterEntry{ + CounterEntry: &p4_v1.CounterEntry{ CounterId: counterID}}}}} stream, err := p.client.Read(context.Background(), readRequest) diff --git a/plugins/inputs/p4runtime/p4runtime_test.go b/plugins/inputs/p4runtime/p4runtime_test.go index 330787ca68944..734c320d4bb40 100644 --- a/plugins/inputs/p4runtime/p4runtime_test.go +++ b/plugins/inputs/p4runtime/p4runtime_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - p4ConfigV1 "github.com/p4lang/p4runtime/go/p4/config/v1" - p4v1 "github.com/p4lang/p4runtime/go/p4/v1" + p4_config_v1 "github.com/p4lang/p4runtime/go/p4/config/v1" + p4_v1 "github.com/p4lang/p4runtime/go/p4/v1" "github.com/stretchr/testify/require" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -21,23 +21,23 @@ import ( func createCounter( name string, id uint32, - unit p4ConfigV1.CounterSpec_Unit, -) *p4ConfigV1.Counter { - return &p4ConfigV1.Counter{ - Preamble: &p4ConfigV1.Preamble{Name: name, Id: id}, - Spec: &p4ConfigV1.CounterSpec{Unit: unit}, + unit p4_config_v1.CounterSpec_Unit, +) *p4_config_v1.Counter { + return &p4_config_v1.Counter{ + Preamble: &p4_config_v1.Preamble{Name: name, Id: id}, + Spec: &p4_config_v1.CounterSpec{Unit: unit}, } } func createEntityCounterEntry( counterID uint32, index int64, - data *p4v1.CounterData, -) *p4v1.Entity_CounterEntry { - return &p4v1.Entity_CounterEntry{ - CounterEntry: &p4v1.CounterEntry{ + data *p4_v1.CounterData, +) *p4_v1.Entity_CounterEntry { + return &p4_v1.Entity_CounterEntry{ + CounterEntry: &p4_v1.CounterEntry{ CounterId: counterID, - Index: &p4v1.Index{Index: index}, + Index: &p4_v1.Index{Index: index}, Data: data, }, } @@ -73,20 +73,20 @@ func TestInitDefault(t *testing.T) { func TestErrorGetP4Info(t *testing.T) { responses := []struct { - getForwardingPipelineConfigResponse *p4v1.GetForwardingPipelineConfigResponse + getForwardingPipelineConfigResponse *p4_v1.GetForwardingPipelineConfigResponse getForwardingPipelineConfigResponseError error }{ { getForwardingPipelineConfigResponse: nil, getForwardingPipelineConfigResponseError: errors.New("error when retrieving forwarding pipeline config"), }, { - getForwardingPipelineConfigResponse: &p4v1.GetForwardingPipelineConfigResponse{ + getForwardingPipelineConfigResponse: &p4_v1.GetForwardingPipelineConfigResponse{ Config: nil, }, getForwardingPipelineConfigResponseError: nil, }, { - getForwardingPipelineConfigResponse: &p4v1.GetForwardingPipelineConfigResponse{ - Config: &p4v1.ForwardingPipelineConfig{P4Info: nil}, + getForwardingPipelineConfigResponse: &p4_v1.GetForwardingPipelineConfigResponse{ + Config: &p4_v1.ForwardingPipelineConfig{P4Info: nil}, }, getForwardingPipelineConfigResponseError: nil, }, @@ -94,7 +94,7 @@ func TestErrorGetP4Info(t *testing.T) { for _, response := range responses { p4RtClient := &fakeP4RuntimeClient{ - getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) { + getForwardingPipelineConfigFn: func() (*p4_v1.GetForwardingPipelineConfigResponse, error) { return response.getForwardingPipelineConfigResponse, response.getForwardingPipelineConfigResponseError }, } @@ -111,23 +111,23 @@ func TestErrorGetP4Info(t *testing.T) { func TestOneCounterRead(t *testing.T) { tests := []struct { - forwardingPipelineConfig *p4v1.ForwardingPipelineConfig - EntityCounterEntry *p4v1.Entity_CounterEntry + forwardingPipelineConfig *p4_v1.ForwardingPipelineConfig + EntityCounterEntry *p4_v1.Entity_CounterEntry expected []telegraf.Metric }{ { - forwardingPipelineConfig: &p4v1.ForwardingPipelineConfig{ - P4Info: &p4ConfigV1.P4Info{ - Counters: []*p4ConfigV1.Counter{ - createCounter("foo", 1111, p4ConfigV1.CounterSpec_BOTH), + forwardingPipelineConfig: &p4_v1.ForwardingPipelineConfig{ + P4Info: &p4_config_v1.P4Info{ + Counters: []*p4_config_v1.Counter{ + createCounter("foo", 1111, p4_config_v1.CounterSpec_BOTH), }, - PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"}, + PkgInfo: &p4_config_v1.PkgInfo{Name: "P4Program"}, }, }, EntityCounterEntry: createEntityCounterEntry( 1111, 5, - &p4v1.CounterData{ByteCount: 5, PacketCount: 1}, + &p4_v1.CounterData{ByteCount: 5, PacketCount: 1}, ), expected: []telegraf.Metric{testutil.MustMetric( "p4_runtime", @@ -143,22 +143,22 @@ func TestOneCounterRead(t *testing.T) { time.Unix(0, 0)), }, }, { - forwardingPipelineConfig: &p4v1.ForwardingPipelineConfig{ - P4Info: &p4ConfigV1.P4Info{ - Counters: []*p4ConfigV1.Counter{ + forwardingPipelineConfig: &p4_v1.ForwardingPipelineConfig{ + P4Info: &p4_config_v1.P4Info{ + Counters: []*p4_config_v1.Counter{ createCounter( "foo", 2222, - p4ConfigV1.CounterSpec_BYTES, + p4_config_v1.CounterSpec_BYTES, ), }, - PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"}, + PkgInfo: &p4_config_v1.PkgInfo{Name: "P4Program"}, }, }, EntityCounterEntry: createEntityCounterEntry( 2222, 5, - &p4v1.CounterData{ByteCount: 5}, + &p4_v1.CounterData{ByteCount: 5}, ), expected: []telegraf.Metric{testutil.MustMetric( "p4_runtime", @@ -174,22 +174,22 @@ func TestOneCounterRead(t *testing.T) { time.Unix(0, 0)), }, }, { - forwardingPipelineConfig: &p4v1.ForwardingPipelineConfig{ - P4Info: &p4ConfigV1.P4Info{ - Counters: []*p4ConfigV1.Counter{ + forwardingPipelineConfig: &p4_v1.ForwardingPipelineConfig{ + P4Info: &p4_config_v1.P4Info{ + Counters: []*p4_config_v1.Counter{ createCounter( "foo", 3333, - p4ConfigV1.CounterSpec_PACKETS, + p4_config_v1.CounterSpec_PACKETS, ), }, - PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"}, + PkgInfo: &p4_config_v1.PkgInfo{Name: "P4Program"}, }, }, EntityCounterEntry: createEntityCounterEntry( 3333, 5, - &p4v1.CounterData{PacketCount: 1}, + &p4_v1.CounterData{PacketCount: 1}, ), expected: []telegraf.Metric{testutil.MustMetric( "p4_runtime", @@ -205,18 +205,18 @@ func TestOneCounterRead(t *testing.T) { time.Unix(0, 0)), }, }, { - forwardingPipelineConfig: &p4v1.ForwardingPipelineConfig{ - P4Info: &p4ConfigV1.P4Info{ - Counters: []*p4ConfigV1.Counter{ - createCounter("foo", 4444, p4ConfigV1.CounterSpec_BOTH), + forwardingPipelineConfig: &p4_v1.ForwardingPipelineConfig{ + P4Info: &p4_config_v1.P4Info{ + Counters: []*p4_config_v1.Counter{ + createCounter("foo", 4444, p4_config_v1.CounterSpec_BOTH), }, - PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"}, + PkgInfo: &p4_config_v1.PkgInfo{Name: "P4Program"}, }, }, EntityCounterEntry: createEntityCounterEntry( 4444, 5, - &p4v1.CounterData{}, + &p4_v1.CounterData{}, ), expected: nil, }, @@ -224,19 +224,19 @@ func TestOneCounterRead(t *testing.T) { for _, tt := range tests { p4RtReadClient := &fakeP4RuntimeReadClient{ - recvFn: func() (*p4v1.ReadResponse, error) { - return &p4v1.ReadResponse{ - Entities: []*p4v1.Entity{{Entity: tt.EntityCounterEntry}}, + recvFn: func() (*p4_v1.ReadResponse, error) { + return &p4_v1.ReadResponse{ + Entities: []*p4_v1.Entity{{Entity: tt.EntityCounterEntry}}, }, nil }, } p4RtClient := &fakeP4RuntimeClient{ - readFn: func(*p4v1.ReadRequest) (p4v1.P4Runtime_ReadClient, error) { + readFn: func(*p4_v1.ReadRequest) (p4_v1.P4Runtime_ReadClient, error) { return p4RtReadClient, nil }, - getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) { - return &p4v1.GetForwardingPipelineConfigResponse{ + getForwardingPipelineConfigFn: func() (*p4_v1.GetForwardingPipelineConfigResponse, error) { + return &p4_v1.GetForwardingPipelineConfigResponse{ Config: tt.forwardingPipelineConfig, }, nil }, @@ -270,19 +270,19 @@ func TestMultipleEntitiesSingleCounterRead(t *testing.T) { totalNumOfEntries, "totalNumOfCounters", ) - entities := make([]*p4v1.Entity, 0, totalNumOfEntries) - p4InfoCounters := make([]*p4ConfigV1.Counter, 0, totalNumOfEntries) + entities := make([]*p4_v1.Entity, 0, totalNumOfEntries) + p4InfoCounters := make([]*p4_config_v1.Counter, 0, totalNumOfEntries) p4InfoCounters = append( p4InfoCounters, - createCounter("foo", 0, p4ConfigV1.CounterSpec_BOTH), + createCounter("foo", 0, p4_config_v1.CounterSpec_BOTH), ) for i := 0; i < totalNumOfEntries; i++ { - counterEntry := &p4v1.Entity{ + counterEntry := &p4_v1.Entity{ Entity: createEntityCounterEntry( 0, int64(i), - &p4v1.CounterData{ + &p4_v1.CounterData{ ByteCount: int64(10), PacketCount: int64(10), }, @@ -306,25 +306,25 @@ func TestMultipleEntitiesSingleCounterRead(t *testing.T) { )) } - forwardingPipelineConfig := &p4v1.ForwardingPipelineConfig{ - P4Info: &p4ConfigV1.P4Info{ + forwardingPipelineConfig := &p4_v1.ForwardingPipelineConfig{ + P4Info: &p4_config_v1.P4Info{ Counters: p4InfoCounters, - PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"}, + PkgInfo: &p4_config_v1.PkgInfo{Name: "P4Program"}, }, } p4RtReadClient := &fakeP4RuntimeReadClient{ - recvFn: func() (*p4v1.ReadResponse, error) { - return &p4v1.ReadResponse{Entities: entities}, nil + recvFn: func() (*p4_v1.ReadResponse, error) { + return &p4_v1.ReadResponse{Entities: entities}, nil }, } p4RtClient := &fakeP4RuntimeClient{ - readFn: func(*p4v1.ReadRequest) (p4v1.P4Runtime_ReadClient, error) { + readFn: func(*p4_v1.ReadRequest) (p4_v1.P4Runtime_ReadClient, error) { return p4RtReadClient, nil }, - getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) { - return &p4v1.GetForwardingPipelineConfigResponse{ + getForwardingPipelineConfigFn: func() (*p4_v1.GetForwardingPipelineConfigResponse, error) { + return &p4_v1.GetForwardingPipelineConfigResponse{ Config: forwardingPipelineConfig, }, nil }, @@ -359,7 +359,7 @@ func TestSingleEntitiesMultipleCounterRead(t *testing.T) { totalNumOfCounters, "totalNumOfCounters", ) - p4InfoCounters := make([]*p4ConfigV1.Counter, 0, totalNumOfCounters) + p4InfoCounters := make([]*p4_config_v1.Counter, 0, totalNumOfCounters) for i := 1; i <= totalNumOfCounters; i++ { counterName := fmt.Sprintf("foo%v", i) @@ -368,7 +368,7 @@ func TestSingleEntitiesMultipleCounterRead(t *testing.T) { createCounter( counterName, uint32(i), - p4ConfigV1.CounterSpec_BOTH, + p4_config_v1.CounterSpec_BOTH, ), ) @@ -388,24 +388,24 @@ func TestSingleEntitiesMultipleCounterRead(t *testing.T) { )) } - forwardingPipelineConfig := &p4v1.ForwardingPipelineConfig{ - P4Info: &p4ConfigV1.P4Info{ + forwardingPipelineConfig := &p4_v1.ForwardingPipelineConfig{ + P4Info: &p4_config_v1.P4Info{ Counters: p4InfoCounters, - PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"}, + PkgInfo: &p4_config_v1.PkgInfo{Name: "P4Program"}, }, } p4RtClient := &fakeP4RuntimeClient{ - readFn: func(in *p4v1.ReadRequest) (p4v1.P4Runtime_ReadClient, error) { + readFn: func(in *p4_v1.ReadRequest) (p4_v1.P4Runtime_ReadClient, error) { counterID := in.Entities[0].GetCounterEntry().CounterId return &fakeP4RuntimeReadClient{ - recvFn: func() (*p4v1.ReadResponse, error) { - return &p4v1.ReadResponse{ - Entities: []*p4v1.Entity{{ + recvFn: func() (*p4_v1.ReadResponse, error) { + return &p4_v1.ReadResponse{ + Entities: []*p4_v1.Entity{{ Entity: createEntityCounterEntry( counterID, 1, - &p4v1.CounterData{ + &p4_v1.CounterData{ ByteCount: 10, PacketCount: 10, }, @@ -415,8 +415,8 @@ func TestSingleEntitiesMultipleCounterRead(t *testing.T) { }, }, nil }, - getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) { - return &p4v1.GetForwardingPipelineConfigResponse{ + getForwardingPipelineConfigFn: func() (*p4_v1.GetForwardingPipelineConfigResponse, error) { + return &p4_v1.GetForwardingPipelineConfigResponse{ Config: forwardingPipelineConfig, }, nil }, @@ -442,13 +442,13 @@ func TestSingleEntitiesMultipleCounterRead(t *testing.T) { } func TestNoCountersAvailable(t *testing.T) { - forwardingPipelineConfig := &p4v1.ForwardingPipelineConfig{ - P4Info: &p4ConfigV1.P4Info{Counters: []*p4ConfigV1.Counter{}}, + forwardingPipelineConfig := &p4_v1.ForwardingPipelineConfig{ + P4Info: &p4_config_v1.P4Info{Counters: []*p4_config_v1.Counter{}}, } p4RtClient := &fakeP4RuntimeClient{ - getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) { - return &p4v1.GetForwardingPipelineConfigResponse{ + getForwardingPipelineConfigFn: func() (*p4_v1.GetForwardingPipelineConfigResponse, error) { + return &p4_v1.GetForwardingPipelineConfigResponse{ Config: forwardingPipelineConfig, }, nil }, @@ -464,18 +464,18 @@ func TestNoCountersAvailable(t *testing.T) { } func TestFilterCounters(t *testing.T) { - forwardingPipelineConfig := &p4v1.ForwardingPipelineConfig{ - P4Info: &p4ConfigV1.P4Info{ - Counters: []*p4ConfigV1.Counter{ - createCounter("foo", 1, p4ConfigV1.CounterSpec_BOTH), + forwardingPipelineConfig := &p4_v1.ForwardingPipelineConfig{ + P4Info: &p4_config_v1.P4Info{ + Counters: []*p4_config_v1.Counter{ + createCounter("foo", 1, p4_config_v1.CounterSpec_BOTH), }, - PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"}, + PkgInfo: &p4_config_v1.PkgInfo{Name: "P4Program"}, }, } p4RtClient := &fakeP4RuntimeClient{ - getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) { - return &p4v1.GetForwardingPipelineConfigResponse{ + getForwardingPipelineConfigFn: func() (*p4_v1.GetForwardingPipelineConfigResponse, error) { + return &p4_v1.GetForwardingPipelineConfigResponse{ Config: forwardingPipelineConfig, }, nil }, @@ -500,31 +500,31 @@ func TestFilterCounters(t *testing.T) { func TestFailReadCounterEntryFromEntry(t *testing.T) { p4RtReadClient := &fakeP4RuntimeReadClient{ - recvFn: func() (*p4v1.ReadResponse, error) { - return &p4v1.ReadResponse{ - Entities: []*p4v1.Entity{{ - Entity: &p4v1.Entity_TableEntry{ - TableEntry: &p4v1.TableEntry{}, + recvFn: func() (*p4_v1.ReadResponse, error) { + return &p4_v1.ReadResponse{ + Entities: []*p4_v1.Entity{{ + Entity: &p4_v1.Entity_TableEntry{ + TableEntry: &p4_v1.TableEntry{}, }}}}, nil }, } p4RtClient := &fakeP4RuntimeClient{ - readFn: func(*p4v1.ReadRequest) (p4v1.P4Runtime_ReadClient, error) { + readFn: func(*p4_v1.ReadRequest) (p4_v1.P4Runtime_ReadClient, error) { return p4RtReadClient, nil }, - getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) { - return &p4v1.GetForwardingPipelineConfigResponse{ - Config: &p4v1.ForwardingPipelineConfig{ - P4Info: &p4ConfigV1.P4Info{ - Counters: []*p4ConfigV1.Counter{ + getForwardingPipelineConfigFn: func() (*p4_v1.GetForwardingPipelineConfigResponse, error) { + return &p4_v1.GetForwardingPipelineConfigResponse{ + Config: &p4_v1.ForwardingPipelineConfig{ + P4Info: &p4_config_v1.P4Info{ + Counters: []*p4_config_v1.Counter{ createCounter( "foo", 1111, - p4ConfigV1.CounterSpec_BOTH, + p4_config_v1.CounterSpec_BOTH, ), }, - PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"}, + PkgInfo: &p4_config_v1.PkgInfo{Name: "P4Program"}, }, }, }, nil @@ -553,21 +553,21 @@ func TestFailReadCounterEntryFromEntry(t *testing.T) { func TestFailReadAllEntries(t *testing.T) { p4RtClient := &fakeP4RuntimeClient{ - readFn: func(*p4v1.ReadRequest) (p4v1.P4Runtime_ReadClient, error) { + readFn: func(*p4_v1.ReadRequest) (p4_v1.P4Runtime_ReadClient, error) { return nil, errors.New("connection error") }, - getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) { - return &p4v1.GetForwardingPipelineConfigResponse{ - Config: &p4v1.ForwardingPipelineConfig{ - P4Info: &p4ConfigV1.P4Info{ - Counters: []*p4ConfigV1.Counter{ + getForwardingPipelineConfigFn: func() (*p4_v1.GetForwardingPipelineConfigResponse, error) { + return &p4_v1.GetForwardingPipelineConfigResponse{ + Config: &p4_v1.ForwardingPipelineConfig{ + P4Info: &p4_config_v1.P4Info{ + Counters: []*p4_config_v1.Counter{ createCounter( "foo", 1111, - p4ConfigV1.CounterSpec_BOTH, + p4_config_v1.CounterSpec_BOTH, ), }, - PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"}, + PkgInfo: &p4_config_v1.PkgInfo{Name: "P4Program"}, }, }, }, nil @@ -595,11 +595,11 @@ func TestFailReadAllEntries(t *testing.T) { } func TestFilterCounterNamesInclude(t *testing.T) { - counters := []*p4ConfigV1.Counter{ - createCounter("foo", 1, p4ConfigV1.CounterSpec_BOTH), - createCounter("bar", 2, p4ConfigV1.CounterSpec_BOTH), + counters := []*p4_config_v1.Counter{ + createCounter("foo", 1, p4_config_v1.CounterSpec_BOTH), + createCounter("bar", 2, p4_config_v1.CounterSpec_BOTH), nil, - createCounter("", 3, p4ConfigV1.CounterSpec_BOTH), + createCounter("", 3, p4_config_v1.CounterSpec_BOTH), } counterNamesInclude := []string{"bar"} @@ -607,8 +607,8 @@ func TestFilterCounterNamesInclude(t *testing.T) { filteredCounters := filterCounters(counters, counterNamesInclude) require.Equal( t, - []*p4ConfigV1.Counter{ - createCounter("bar", 2, p4ConfigV1.CounterSpec_BOTH), + []*p4_config_v1.Counter{ + createCounter("bar", 2, p4_config_v1.CounterSpec_BOTH), }, filteredCounters, ) } diff --git a/plugins/inputs/prometheus/prometheus.go b/plugins/inputs/prometheus/prometheus.go index 5dfc6e629b6b3..264d381d3b0b0 100644 --- a/plugins/inputs/prometheus/prometheus.go +++ b/plugins/inputs/prometheus/prometheus.go @@ -25,7 +25,7 @@ import ( "github.com/influxdata/telegraf/filter" "github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/models" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/parsers/openmetrics" parser "github.com/influxdata/telegraf/plugins/parsers/prometheus" @@ -88,7 +88,7 @@ type Prometheus struct { ConsulConfig ConsulConfig `toml:"consul"` Log telegraf.Logger `toml:"-"` - httpconfig.HTTPClientConfig + common_http.HTTPClientConfig client *http.Client headers map[string]string diff --git a/plugins/inputs/riemann_listener/riemann_listener.go b/plugins/inputs/riemann_listener/riemann_listener.go index da654eaee53a9..5777668a65396 100644 --- a/plugins/inputs/riemann_listener/riemann_listener.go +++ b/plugins/inputs/riemann_listener/riemann_listener.go @@ -16,14 +16,14 @@ import ( "sync" "time" - riemanngo "github.com/riemann/riemann-go-client" - riemangoProto "github.com/riemann/riemann-go-client/proto" + "github.com/riemann/riemann-go-client" + riemango_proto "github.com/riemann/riemann-go-client/proto" "google.golang.org/protobuf/proto" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/metric" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -37,7 +37,7 @@ type RiemannSocketListener struct { ReadTimeout *config.Duration `toml:"read_timeout"` KeepAlivePeriod *config.Duration `toml:"keep_alive_period"` SocketMode string `toml:"socket_mode"` - tlsint.ServerConfig + common_tls.ServerConfig wg sync.WaitGroup @@ -178,7 +178,7 @@ func (rsl *riemannListener) read(conn net.Conn) { } } - messagePb := &riemangoProto.Msg{} + messagePb := &riemango_proto.Msg{} var header uint32 // First obtain the size of the riemann event from client and acknowledge if err = binary.Read(conn, binary.BigEndian, &header); err != nil { @@ -227,7 +227,7 @@ func (rsl *riemannListener) read(conn net.Conn) { func (rsl *riemannListener) riemannReturnResponse(conn net.Conn) { t := true - message := new(riemangoProto.Msg) + message := new(riemango_proto.Msg) message.Ok = &t returnData, err := proto.Marshal(message) if err != nil { @@ -249,7 +249,7 @@ func (rsl *riemannListener) riemannReturnResponse(conn net.Conn) { func (rsl *riemannListener) riemannReturnErrorResponse(conn net.Conn, errorMessage string) { t := false - message := new(riemangoProto.Msg) + message := new(riemango_proto.Msg) message.Ok = &t message.Error = &errorMessage returnData, err := proto.Marshal(message) diff --git a/plugins/inputs/vault/vault.go b/plugins/inputs/vault/vault.go index f80b3d6b4305e..c80e1fd6645cb 100644 --- a/plugins/inputs/vault/vault.go +++ b/plugins/inputs/vault/vault.go @@ -15,7 +15,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" - httpcommon "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -28,7 +28,7 @@ type Vault struct { TokenFile string `toml:"token_file"` Token string `toml:"token"` Log telegraf.Logger `toml:"-"` - httpcommon.HTTPClientConfig + common_http.HTTPClientConfig client *http.Client } @@ -192,7 +192,7 @@ func buildVaultMetrics(acc telegraf.Accumulator, sysMetrics *SysMetrics) error { func init() { inputs.Add("vault", func() telegraf.Input { return &Vault{ - HTTPClientConfig: httpcommon.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ ResponseHeaderTimeout: config.Duration(5 * time.Second), }, } diff --git a/plugins/inputs/vault/vault_test.go b/plugins/inputs/vault/vault_test.go index 26f64461bbf1f..46abf1f328cc7 100644 --- a/plugins/inputs/vault/vault_test.go +++ b/plugins/inputs/vault/vault_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - dockercontainer "github.com/docker/docker/api/types/container" + docker_container "github.com/docker/docker/api/types/container" "github.com/docker/go-connections/nat" "github.com/influxdata/telegraf" @@ -189,7 +189,7 @@ func TestIntegration(t *testing.T) { Env: map[string]string{ "VAULT_DEV_ROOT_TOKEN_ID": "root", }, - HostConfigModifier: func(hc *dockercontainer.HostConfig) { + HostConfigModifier: func(hc *docker_container.HostConfig) { hc.CapAdd = []string{"IPC_LOCK"} }, WaitingFor: wait.ForAll( diff --git a/plugins/inputs/vsphere/vsphere_test.go b/plugins/inputs/vsphere/vsphere_test.go index fe9ed6166e1a6..7eefa88e527b3 100644 --- a/plugins/inputs/vsphere/vsphere_test.go +++ b/plugins/inputs/vsphere/vsphere_test.go @@ -17,7 +17,7 @@ import ( "github.com/vmware/govmomi/vim25/types" "github.com/influxdata/telegraf/config" - itls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/testutil" ) @@ -130,7 +130,7 @@ func defaultVSphere() *VSphere { DatacenterMetricInclude: nil, DatacenterMetricExclude: nil, DatacenterInclude: []string{"/**"}, - ClientConfig: itls.ClientConfig{InsecureSkipVerify: true}, + ClientConfig: common_tls.ClientConfig{InsecureSkipVerify: true}, MaxQueryObjects: 256, MaxQueryMetrics: 256, diff --git a/plugins/inputs/x509_cert/x509_cert.go b/plugins/inputs/x509_cert/x509_cert.go index dfd8b28b531e6..97097ded3d80f 100644 --- a/plugins/inputs/x509_cert/x509_cert.go +++ b/plugins/inputs/x509_cert/x509_cert.go @@ -28,7 +28,7 @@ import ( "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal/globpath" "github.com/influxdata/telegraf/plugins/common/proxy" - commontls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -45,7 +45,7 @@ type X509Cert struct { ServerName string `toml:"server_name"` ExcludeRootCerts bool `toml:"exclude_root_certs"` Log telegraf.Logger `toml:"-"` - commontls.ClientConfig + common_tls.ClientConfig proxy.TCPProxy tlsCfg *tls.Config diff --git a/plugins/inputs/x509_cert/x509_cert_test.go b/plugins/inputs/x509_cert/x509_cert_test.go index d0e2c0ade4322..fbe35dfc94dcb 100644 --- a/plugins/inputs/x509_cert/x509_cert_test.go +++ b/plugins/inputs/x509_cert/x509_cert_test.go @@ -27,7 +27,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/metric" - _tls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/testutil" ) @@ -457,7 +457,7 @@ func TestServerName(t *testing.T) { sc := &X509Cert{ Sources: []string{test.url}, ServerName: test.fromCfg, - ClientConfig: _tls.ClientConfig{ServerName: test.fromTLS}, + ClientConfig: common_tls.ClientConfig{ServerName: test.fromTLS}, Log: testutil.Logger{}, } err := sc.Init() @@ -569,7 +569,7 @@ func TestClassification(t *testing.T) { certURI := "file://" + filepath.Join(tmpDir, "cert.pem") plugin := &X509Cert{ Sources: []string{certURI}, - ClientConfig: _tls.ClientConfig{ + ClientConfig: common_tls.ClientConfig{ TLSCA: filepath.Join(tmpDir, "ca.pem"), }, Log: testutil.Logger{}, diff --git a/plugins/inputs/zookeeper/zookeeper.go b/plugins/inputs/zookeeper/zookeeper.go index 2ab54ec7a29a1..6f48a012ab436 100644 --- a/plugins/inputs/zookeeper/zookeeper.go +++ b/plugins/inputs/zookeeper/zookeeper.go @@ -15,7 +15,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -32,7 +32,7 @@ type Zookeeper struct { EnableTLS bool `toml:"enable_tls"` EnableSSL bool `toml:"enable_ssl" deprecated:"1.7.0;1.35.0;use 'enable_tls' instead"` - tlsint.ClientConfig + common_tls.ClientConfig initialized bool tlsConfig *tls.Config diff --git a/plugins/outputs/application_insights/mocks/diagnostics_message_listener.go b/plugins/outputs/application_insights/mocks/diagnostics_message_listener.go index 65747c10ccfca..2a9bd344e8cec 100644 --- a/plugins/outputs/application_insights/mocks/diagnostics_message_listener.go +++ b/plugins/outputs/application_insights/mocks/diagnostics_message_listener.go @@ -1,6 +1,6 @@ package mocks -import mock "github.com/stretchr/testify/mock" +import "github.com/stretchr/testify/mock" // DiagnosticsMessageSubscriber is an autogenerated mock type for the DiagnosticsMessageSubscriber type type DiagnosticsMessageListener struct { diff --git a/plugins/outputs/azure_data_explorer/azure_data_explorer_test.go b/plugins/outputs/azure_data_explorer/azure_data_explorer_test.go index a39f09b8cdb8b..6582d5d6aad5c 100644 --- a/plugins/outputs/azure_data_explorer/azure_data_explorer_test.go +++ b/plugins/outputs/azure_data_explorer/azure_data_explorer_test.go @@ -17,7 +17,7 @@ import ( "github.com/stretchr/testify/require" "github.com/influxdata/telegraf" - telegrafJson "github.com/influxdata/telegraf/plugins/serializers/json" + telegraf_json "github.com/influxdata/telegraf/plugins/serializers/json" "github.com/influxdata/telegraf/testutil" ) @@ -105,7 +105,7 @@ func TestWrite(t *testing.T) { for _, tC := range testCases { t.Run(tC.name, func(t *testing.T) { - serializer := &telegrafJson.Serializer{} + serializer := &telegraf_json.Serializer{} require.NoError(t, serializer.Init()) ingestionType := "queued" @@ -156,7 +156,7 @@ func TestWrite(t *testing.T) { } func TestCreateAzureDataExplorerTable(t *testing.T) { - serializer := &telegrafJson.Serializer{} + serializer := &telegraf_json.Serializer{} require.NoError(t, serializer.Init()) plugin := AzureDataExplorer{ Endpoint: "someendpoint", @@ -251,7 +251,7 @@ func TestWriteWithType(t *testing.T) { } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - serializer := &telegrafJson.Serializer{} + serializer := &telegraf_json.Serializer{} require.NoError(t, serializer.Init()) for tableName, jsonValue := range testCase.tableNameToExpectedResult { ingestionType := "queued" diff --git a/plugins/outputs/cloud_pubsub/topic_stubbed.go b/plugins/outputs/cloud_pubsub/topic_stubbed.go index 05429d509ec37..6f31e7e0b1de1 100644 --- a/plugins/outputs/cloud_pubsub/topic_stubbed.go +++ b/plugins/outputs/cloud_pubsub/topic_stubbed.go @@ -17,7 +17,7 @@ import ( "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/plugins/parsers/influx" - serializer "github.com/influxdata/telegraf/plugins/serializers/influx" + influx_serializer "github.com/influxdata/telegraf/plugins/serializers/influx" ) const ( @@ -64,7 +64,7 @@ type ( func getTestResources(tT *testing.T, settings pubsub.PublishSettings, testM []testMetric) (*PubSub, *stubTopic, []telegraf.Metric) { // Instantiate a Influx line-protocol serializer - s := &serializer.Serializer{} + s := &influx_serializer.Serializer{} require.NoError(tT, s.Init()) metrics := make([]telegraf.Metric, 0, len(testM)) diff --git a/plugins/outputs/cloudwatch/cloudwatch.go b/plugins/outputs/cloudwatch/cloudwatch.go index 077ac70d92bcb..b57dc677f35ce 100644 --- a/plugins/outputs/cloudwatch/cloudwatch.go +++ b/plugins/outputs/cloudwatch/cloudwatch.go @@ -15,8 +15,8 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" "github.com/influxdata/telegraf" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_aws "github.com/influxdata/telegraf/plugins/common/aws" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/outputs" ) @@ -29,8 +29,8 @@ type CloudWatch struct { svc *cloudwatch.Client WriteStatistics bool `toml:"write_statistics"` Log telegraf.Logger `toml:"-"` - internalaws.CredentialConfig - httpconfig.HTTPClientConfig + common_aws.CredentialConfig + common_http.HTTPClientConfig client *http.Client } diff --git a/plugins/outputs/cloudwatch_logs/cloudwatch_logs.go b/plugins/outputs/cloudwatch_logs/cloudwatch_logs.go index 8487d072d59bc..5f8481ac6a794 100644 --- a/plugins/outputs/cloudwatch_logs/cloudwatch_logs.go +++ b/plugins/outputs/cloudwatch_logs/cloudwatch_logs.go @@ -15,7 +15,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types" "github.com/influxdata/telegraf" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" + common_aws "github.com/influxdata/telegraf/plugins/common/aws" "github.com/influxdata/telegraf/plugins/outputs" ) @@ -73,7 +73,7 @@ type CloudWatchLogs struct { Log telegraf.Logger `toml:"-"` - internalaws.CredentialConfig + common_aws.CredentialConfig } const ( diff --git a/plugins/outputs/cloudwatch_logs/cloudwatch_logs_test.go b/plugins/outputs/cloudwatch_logs/cloudwatch_logs_test.go index ba3b42af1d204..8a4dc9b11d125 100644 --- a/plugins/outputs/cloudwatch_logs/cloudwatch_logs_test.go +++ b/plugins/outputs/cloudwatch_logs/cloudwatch_logs_test.go @@ -9,12 +9,12 @@ import ( "testing" "time" - cloudwatchlogsV2 "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs" + "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs" "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types" "github.com/stretchr/testify/require" "github.com/influxdata/telegraf" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" + "github.com/influxdata/telegraf/plugins/common/aws" "github.com/influxdata/telegraf/testutil" ) @@ -30,21 +30,21 @@ func (c *mockCloudWatchLogs) Init(lsName string) { func (c *mockCloudWatchLogs) DescribeLogGroups( context.Context, - *cloudwatchlogsV2.DescribeLogGroupsInput, - ...func(options *cloudwatchlogsV2.Options), -) (*cloudwatchlogsV2.DescribeLogGroupsOutput, error) { + *cloudwatchlogs.DescribeLogGroupsInput, + ...func(options *cloudwatchlogs.Options), +) (*cloudwatchlogs.DescribeLogGroupsOutput, error) { return nil, nil } func (c *mockCloudWatchLogs) DescribeLogStreams( context.Context, - *cloudwatchlogsV2.DescribeLogStreamsInput, - ...func(options *cloudwatchlogsV2.Options), -) (*cloudwatchlogsV2.DescribeLogStreamsOutput, error) { + *cloudwatchlogs.DescribeLogStreamsInput, + ...func(options *cloudwatchlogs.Options), +) (*cloudwatchlogs.DescribeLogStreamsOutput, error) { arn := "arn" creationTime := time.Now().Unix() sequenceToken := "arbitraryToken" - output := &cloudwatchlogsV2.DescribeLogStreamsOutput{ + output := &cloudwatchlogs.DescribeLogStreamsOutput{ LogStreams: []types.LogStream{ { Arn: &arn, @@ -62,19 +62,19 @@ func (c *mockCloudWatchLogs) DescribeLogStreams( func (c *mockCloudWatchLogs) CreateLogStream( context.Context, - *cloudwatchlogsV2.CreateLogStreamInput, - ...func(options *cloudwatchlogsV2.Options), -) (*cloudwatchlogsV2.CreateLogStreamOutput, error) { + *cloudwatchlogs.CreateLogStreamInput, + ...func(options *cloudwatchlogs.Options), +) (*cloudwatchlogs.CreateLogStreamOutput, error) { return nil, nil } func (c *mockCloudWatchLogs) PutLogEvents( _ context.Context, - input *cloudwatchlogsV2.PutLogEventsInput, - _ ...func(options *cloudwatchlogsV2.Options), -) (*cloudwatchlogsV2.PutLogEventsOutput, error) { + input *cloudwatchlogs.PutLogEventsInput, + _ ...func(options *cloudwatchlogs.Options), +) (*cloudwatchlogs.PutLogEventsOutput, error) { sequenceToken := "arbitraryToken" - output := &cloudwatchlogsV2.PutLogEventsOutput{NextSequenceToken: &sequenceToken} + output := &cloudwatchlogs.PutLogEventsOutput{NextSequenceToken: &sequenceToken} //Saving messages c.pushedLogEvents = append(c.pushedLogEvents, input.LogEvents...) @@ -102,7 +102,7 @@ func TestInit(t *testing.T) { name: "log group is not set", expectedErrorString: "log group is not set", plugin: &CloudWatchLogs{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: aws.CredentialConfig{ Region: "eu-central-1", AccessKey: "dummy", SecretKey: "dummy", @@ -120,7 +120,7 @@ func TestInit(t *testing.T) { name: "log stream is not set", expectedErrorString: "log stream is not set", plugin: &CloudWatchLogs{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: aws.CredentialConfig{ Region: "eu-central-1", AccessKey: "dummy", SecretKey: "dummy", @@ -138,7 +138,7 @@ func TestInit(t *testing.T) { name: "log data metrics name is not set", expectedErrorString: "log data metrics name is not set", plugin: &CloudWatchLogs{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: aws.CredentialConfig{ Region: "eu-central-1", AccessKey: "dummy", SecretKey: "dummy", @@ -156,7 +156,7 @@ func TestInit(t *testing.T) { name: "log data source is not set", expectedErrorString: "log data source is not set", plugin: &CloudWatchLogs{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: aws.CredentialConfig{ Region: "eu-central-1", AccessKey: "dummy", SecretKey: "dummy", @@ -175,7 +175,7 @@ func TestInit(t *testing.T) { expectedErrorString: "log data source is not properly formatted, ':' is missed.\n" + "Should be 'tag:' or 'field:'", plugin: &CloudWatchLogs{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: aws.CredentialConfig{ Region: "eu-central-1", AccessKey: "dummy", SecretKey: "dummy", @@ -194,7 +194,7 @@ func TestInit(t *testing.T) { expectedErrorString: "log data source is not properly formatted.\n" + "Should be 'tag:' or 'field:'", plugin: &CloudWatchLogs{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: aws.CredentialConfig{ Region: "eu-central-1", AccessKey: "dummy", SecretKey: "dummy", @@ -211,7 +211,7 @@ func TestInit(t *testing.T) { { name: "valid config", plugin: &CloudWatchLogs{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: aws.CredentialConfig{ Region: "eu-central-1", AccessKey: "dummy", SecretKey: "dummy", @@ -228,7 +228,7 @@ func TestInit(t *testing.T) { { name: "valid config with EndpointURL", plugin: &CloudWatchLogs{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: aws.CredentialConfig{ Region: "eu-central-1", AccessKey: "dummy", SecretKey: "dummy", @@ -277,7 +277,7 @@ func TestConnect(t *testing.T) { defer ts.Close() plugin := &CloudWatchLogs{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: aws.CredentialConfig{ Region: "eu-central-1", AccessKey: "dummy", SecretKey: "dummy", @@ -317,7 +317,7 @@ func TestWrite(t *testing.T) { defer ts.Close() plugin := &CloudWatchLogs{ - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: aws.CredentialConfig{ Region: "eu-central-1", AccessKey: "dummy", SecretKey: "dummy", diff --git a/plugins/outputs/dynatrace/dynatrace.go b/plugins/outputs/dynatrace/dynatrace.go index 357e9299a4e39..be1c0764d7ddb 100644 --- a/plugins/outputs/dynatrace/dynatrace.go +++ b/plugins/outputs/dynatrace/dynatrace.go @@ -12,7 +12,7 @@ import ( "strings" "time" - dtMetric "github.com/dynatrace-oss/dynatrace-metric-utils-go/metric" + dt_metric "github.com/dynatrace-oss/dynatrace-metric-utils-go/metric" "github.com/dynatrace-oss/dynatrace-metric-utils-go/metric/apiconstants" "github.com/dynatrace-oss/dynatrace-metric-utils-go/metric/dimensions" @@ -101,17 +101,17 @@ func (d *Dynatrace) Write(metrics []telegraf.Metric) error { } name := tm.Name() + "." + field.Key - dm, err := dtMetric.NewMetric( + dm, err := dt_metric.NewMetric( name, - dtMetric.WithPrefix(d.Prefix), - dtMetric.WithDimensions( + dt_metric.WithPrefix(d.Prefix), + dt_metric.WithDimensions( dimensions.MergeLists( d.normalizedDefaultDimensions, dimensions.NewNormalizedDimensionList(dims...), d.normalizedStaticDimensions, ), ), - dtMetric.WithTimestamp(tm.Time()), + dt_metric.WithTimestamp(tm.Time()), typeOpt, ) @@ -230,33 +230,33 @@ func init() { }) } -func (d *Dynatrace) getTypeOption(metric telegraf.Metric, field *telegraf.Field) dtMetric.MetricOption { +func (d *Dynatrace) getTypeOption(metric telegraf.Metric, field *telegraf.Field) dt_metric.MetricOption { metricName := metric.Name() + "." + field.Key if d.isCounterMetricsMatch(d.AddCounterMetrics, metricName) || d.isCounterMetricsPatternsMatch(d.AddCounterMetricsPatterns, metricName) { switch v := field.Value.(type) { case float64: - return dtMetric.WithFloatCounterValueDelta(v) + return dt_metric.WithFloatCounterValueDelta(v) case uint64: - return dtMetric.WithIntCounterValueDelta(int64(v)) + return dt_metric.WithIntCounterValueDelta(int64(v)) case int64: - return dtMetric.WithIntCounterValueDelta(v) + return dt_metric.WithIntCounterValueDelta(v) default: return nil } } switch v := field.Value.(type) { case float64: - return dtMetric.WithFloatGaugeValue(v) + return dt_metric.WithFloatGaugeValue(v) case uint64: - return dtMetric.WithIntGaugeValue(int64(v)) + return dt_metric.WithIntGaugeValue(int64(v)) case int64: - return dtMetric.WithIntGaugeValue(v) + return dt_metric.WithIntGaugeValue(v) case bool: if v { - return dtMetric.WithIntGaugeValue(1) + return dt_metric.WithIntGaugeValue(1) } - return dtMetric.WithIntGaugeValue(0) + return dt_metric.WithIntGaugeValue(0) } return nil diff --git a/plugins/outputs/exec/exec_test.go b/plugins/outputs/exec/exec_test.go index c6b3c1fe9c6ef..7b4e779bc2915 100644 --- a/plugins/outputs/exec/exec_test.go +++ b/plugins/outputs/exec/exec_test.go @@ -13,7 +13,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/metric" - influxParser "github.com/influxdata/telegraf/plugins/parsers/influx" + influx_parser "github.com/influxdata/telegraf/plugins/parsers/influx" "github.com/influxdata/telegraf/plugins/serializers/influx" "github.com/influxdata/telegraf/testutil" ) @@ -26,13 +26,13 @@ type MockRunner struct { // Run runs the command. func (c *MockRunner) Run(_ time.Duration, _ []string, _ []string, buffer io.Reader) error { - parser := influxParser.NewStreamParser(buffer) + parser := influx_parser.NewStreamParser(buffer) numMetrics := 0 for { _, err := parser.Next() if err != nil { - if errors.Is(err, influxParser.EOF) { + if errors.Is(err, influx_parser.EOF) { break // stream ended } continue diff --git a/plugins/outputs/execd/execd_test.go b/plugins/outputs/execd/execd_test.go index eae28d19c1d90..11ab676690dd2 100644 --- a/plugins/outputs/execd/execd_test.go +++ b/plugins/outputs/execd/execd_test.go @@ -19,14 +19,14 @@ import ( "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/plugins/parsers/influx" - influxSerializer "github.com/influxdata/telegraf/plugins/serializers/influx" + influx_serializer "github.com/influxdata/telegraf/plugins/serializers/influx" "github.com/influxdata/telegraf/testutil" ) var now = time.Date(2020, 6, 30, 16, 16, 0, 0, time.UTC) func TestExternalOutputWorks(t *testing.T) { - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) exe, err := os.Executable() @@ -73,7 +73,7 @@ func TestExternalOutputWorks(t *testing.T) { } func TestBatchOutputWorks(t *testing.T) { - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) exe, err := os.Executable() @@ -128,7 +128,7 @@ func TestBatchOutputWorks(t *testing.T) { } func TestPartiallyUnserializableThrowError(t *testing.T) { - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) exe, err := os.Executable() @@ -165,7 +165,7 @@ func TestPartiallyUnserializableThrowError(t *testing.T) { } func TestPartiallyUnserializableCanBeSkipped(t *testing.T) { - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) exe, err := os.Executable() diff --git a/plugins/outputs/graphite/graphite.go b/plugins/outputs/graphite/graphite.go index 05b92785f9309..c0d83e18092bf 100644 --- a/plugins/outputs/graphite/graphite.go +++ b/plugins/outputs/graphite/graphite.go @@ -15,7 +15,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/serializers/graphite" ) @@ -44,7 +44,7 @@ type Graphite struct { Templates []string `toml:"templates"` Timeout config.Duration `toml:"timeout"` Log telegraf.Logger `toml:"-"` - tlsint.ClientConfig + common_tls.ClientConfig connections []connection serializer *graphite.GraphiteSerializer diff --git a/plugins/outputs/graylog/graylog.go b/plugins/outputs/graylog/graylog.go index 39606368260e3..a74b79614767d 100644 --- a/plugins/outputs/graylog/graylog.go +++ b/plugins/outputs/graylog/graylog.go @@ -20,7 +20,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/outputs" ) @@ -321,7 +321,7 @@ type Graylog struct { Reconnection bool `toml:"connection_retry"` ReconnectionTime config.Duration `toml:"connection_retry_wait_time"` Log telegraf.Logger `toml:"-"` - tlsint.ClientConfig + common_tls.ClientConfig writer io.Writer closers []io.WriteCloser diff --git a/plugins/outputs/graylog/graylog_test_linux.go b/plugins/outputs/graylog/graylog_test_linux.go index 0023aab787160..fd55491025d60 100644 --- a/plugins/outputs/graylog/graylog_test_linux.go +++ b/plugins/outputs/graylog/graylog_test_linux.go @@ -19,7 +19,7 @@ import ( "github.com/stretchr/testify/require" "github.com/influxdata/telegraf/config" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/testutil" ) @@ -72,14 +72,14 @@ func TestWriteTCP(t *testing.T) { tests := []struct { name string - tlsClientCfg tlsint.ClientConfig + tlsClientCfg common_tls.ClientConfig }{ { name: "TCP", }, { name: "TLS", - tlsClientCfg: tlsint.ClientConfig{ + tlsClientCfg: common_tls.ClientConfig{ ServerName: "localhost", TLSCA: tlsClientConfig.TLSCA, TLSKey: tlsClientConfig.TLSKey, @@ -88,7 +88,7 @@ func TestWriteTCP(t *testing.T) { }, { name: "TLS no validation", - tlsClientCfg: tlsint.ClientConfig{ + tlsClientCfg: common_tls.ClientConfig{ InsecureSkipVerify: true, ServerName: "localhost", TLSKey: tlsClientConfig.TLSKey, @@ -104,7 +104,7 @@ func TestWriteTCP(t *testing.T) { address := TCPServer(t, &wg, tlsServerConfig, errs) plugin := Graylog{ - ClientConfig: tlsint.ClientConfig{ + ClientConfig: common_tls.ClientConfig{ InsecureSkipVerify: true, ServerName: "localhost", TLSKey: tlsClientConfig.TLSKey, diff --git a/plugins/outputs/health/health.go b/plugins/outputs/health/health.go index 419044d4cb183..e99da404452ee 100644 --- a/plugins/outputs/health/health.go +++ b/plugins/outputs/health/health.go @@ -15,7 +15,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/outputs" ) @@ -39,7 +39,7 @@ type Health struct { WriteTimeout config.Duration `toml:"write_timeout"` BasicUsername string `toml:"basic_username"` BasicPassword string `toml:"basic_password"` - tlsint.ServerConfig + common_tls.ServerConfig Compares []*Compares `toml:"compares"` Contains []*Contains `toml:"contains"` diff --git a/plugins/outputs/http/http.go b/plugins/outputs/http/http.go index 8e15020d198d4..9da5f62e48566 100644 --- a/plugins/outputs/http/http.go +++ b/plugins/outputs/http/http.go @@ -14,16 +14,16 @@ import ( "strings" "time" - awsV2 "github.com/aws/aws-sdk-go-v2/aws" - v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "golang.org/x/oauth2" "google.golang.org/api/idtoken" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_aws "github.com/influxdata/telegraf/plugins/common/aws" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/serializers" ) @@ -52,14 +52,14 @@ type HTTP struct { UseBatchFormat bool `toml:"use_batch_format"` AwsService string `toml:"aws_service"` NonRetryableStatusCodes []int `toml:"non_retryable_statuscodes"` - httpconfig.HTTPClientConfig + common_http.HTTPClientConfig Log telegraf.Logger `toml:"-"` client *http.Client serializer serializers.Serializer - awsCfg *awsV2.Config - internalaws.CredentialConfig + awsCfg *aws.Config + common_aws.CredentialConfig // Google API Auth CredentialsFile string `toml:"google_application_credentials"` diff --git a/plugins/outputs/http/http_test.go b/plugins/outputs/http/http_test.go index 2293ee545bafb..b2a81cc2777d2 100644 --- a/plugins/outputs/http/http_test.go +++ b/plugins/outputs/http/http_test.go @@ -17,8 +17,8 @@ import ( "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/metric" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_aws "github.com/influxdata/telegraf/plugins/common/aws" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/common/oauth" "github.com/influxdata/telegraf/plugins/serializers" "github.com/influxdata/telegraf/plugins/serializers/influx" @@ -147,7 +147,7 @@ func TestHTTPClientConfig(t *testing.T) { plugin: &HTTP{ URL: u.String(), Method: defaultMethod, - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ IdleConnTimeout: config.Duration(5 * time.Second), }, }, @@ -159,7 +159,7 @@ func TestHTTPClientConfig(t *testing.T) { plugin: &HTTP{ URL: u.String(), Method: defaultMethod, - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ MaxIdleConns: 100, MaxIdleConnsPerHost: 100, IdleConnTimeout: config.Duration(5 * time.Second), @@ -477,7 +477,7 @@ func TestOAuthClientCredentialsGrant(t *testing.T) { name: "success", plugin: &HTTP{ URL: u.String() + "/write", - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ OAuth2Config: oauth.OAuth2Config{ ClientID: "howdy", ClientSecret: "secret", @@ -504,7 +504,7 @@ func TestOAuthClientCredentialsGrant(t *testing.T) { name: "audience", plugin: &HTTP{ URL: u.String() + "/write", - HTTPClientConfig: httpconfig.HTTPClientConfig{ + HTTPClientConfig: common_http.HTTPClientConfig{ OAuth2Config: oauth.OAuth2Config{ ClientID: "howdy", ClientSecret: "secret", @@ -749,7 +749,7 @@ func TestAwsCredentials(t *testing.T) { plugin: &HTTP{ URL: u.String(), AwsService: "aps", - CredentialConfig: internalaws.CredentialConfig{ + CredentialConfig: common_aws.CredentialConfig{ Region: "us-east-1", AccessKey: "dummy", SecretKey: "dummy", diff --git a/plugins/outputs/kinesis/kinesis.go b/plugins/outputs/kinesis/kinesis.go index 24b36220471a7..816da77d571a3 100644 --- a/plugins/outputs/kinesis/kinesis.go +++ b/plugins/outputs/kinesis/kinesis.go @@ -12,7 +12,7 @@ import ( "github.com/gofrs/uuid/v5" "github.com/influxdata/telegraf" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" + common_aws "github.com/influxdata/telegraf/plugins/common/aws" "github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/serializers" ) @@ -35,7 +35,7 @@ type ( serializer serializers.Serializer svc kinesisClient - internalaws.CredentialConfig + common_aws.CredentialConfig } Partition struct { diff --git a/plugins/outputs/mqtt/mqtt_test.go b/plugins/outputs/mqtt/mqtt_test.go index 74ebd6eb9f855..8d2a81270978c 100644 --- a/plugins/outputs/mqtt/mqtt_test.go +++ b/plugins/outputs/mqtt/mqtt_test.go @@ -16,7 +16,7 @@ import ( "github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/plugins/common/mqtt" "github.com/influxdata/telegraf/plugins/parsers/influx" - influxSerializer "github.com/influxdata/telegraf/plugins/serializers/influx" + influx_serializer "github.com/influxdata/telegraf/plugins/serializers/influx" "github.com/influxdata/telegraf/testutil" ) @@ -48,7 +48,7 @@ func TestConnectAndWriteIntegration(t *testing.T) { container := launchTestContainer(t) defer container.Terminate() var url = fmt.Sprintf("%s:%s", container.Address, container.Ports[servicePort]) - s := &influxSerializer.Serializer{} + s := &influx_serializer.Serializer{} require.NoError(t, s.Init()) m := &MQTT{ MqttConfig: mqtt.MqttConfig{ @@ -79,7 +79,7 @@ func TestConnectAndWriteIntegrationMQTTv3(t *testing.T) { defer container.Terminate() var url = fmt.Sprintf("%s:%s", container.Address, container.Ports[servicePort]) - s := &influxSerializer.Serializer{} + s := &influx_serializer.Serializer{} require.NoError(t, s.Init()) m := &MQTT{ @@ -112,7 +112,7 @@ func TestConnectAndWriteIntegrationMQTTv5(t *testing.T) { defer container.Terminate() url := fmt.Sprintf("%s:%s", container.Address, container.Ports[servicePort]) - s := &influxSerializer.Serializer{} + s := &influx_serializer.Serializer{} require.NoError(t, s.Init()) m := &MQTT{ @@ -156,7 +156,7 @@ func TestIntegrationMQTTv3(t *testing.T) { // Setup the parser / serializer pair parser := &influx.Parser{} require.NoError(t, parser.Init()) - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) // Setup the plugin @@ -271,7 +271,7 @@ func TestMQTTv5Properties(t *testing.T) { } // Setup the metric serializer - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) plugin.SetSerializer(serializer) @@ -308,7 +308,7 @@ func TestIntegrationMQTTLayoutNonBatch(t *testing.T) { // Setup the parser / serializer pair parser := &influx.Parser{} require.NoError(t, parser.Init()) - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) // Setup the plugin @@ -395,7 +395,7 @@ func TestIntegrationMQTTLayoutBatch(t *testing.T) { // Setup the parser / serializer pair parser := &influx.Parser{} require.NoError(t, parser.Init()) - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) // Setup the plugin @@ -861,7 +861,7 @@ func TestMQTTTopicGenerationTemplateIsValid(t *testing.T) { } func TestGenerateTopicName(t *testing.T) { - s := &influxSerializer.Serializer{} + s := &influx_serializer.Serializer{} require.NoError(t, s.Init()) m := &MQTT{ diff --git a/plugins/outputs/prometheus_client/prometheus_client.go b/plugins/outputs/prometheus_client/prometheus_client.go index 152b23465b280..086b327331d97 100644 --- a/plugins/outputs/prometheus_client/prometheus_client.go +++ b/plugins/outputs/prometheus_client/prometheus_client.go @@ -22,10 +22,10 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/outputs" - v1 "github.com/influxdata/telegraf/plugins/outputs/prometheus_client/v1" - v2 "github.com/influxdata/telegraf/plugins/outputs/prometheus_client/v2" + "github.com/influxdata/telegraf/plugins/outputs/prometheus_client/v1" + "github.com/influxdata/telegraf/plugins/outputs/prometheus_client/v2" serializer "github.com/influxdata/telegraf/plugins/serializers/prometheus" ) @@ -62,7 +62,7 @@ type PrometheusClient struct { TypeMappings serializer.MetricTypes `toml:"metric_types"` Log telegraf.Logger `toml:"-"` - tlsint.ServerConfig + common_tls.ServerConfig server *http.Server url *url.URL diff --git a/plugins/outputs/socket_writer/socket_writer.go b/plugins/outputs/socket_writer/socket_writer.go index 80d6657bf9b93..89e83fb47f873 100644 --- a/plugins/outputs/socket_writer/socket_writer.go +++ b/plugins/outputs/socket_writer/socket_writer.go @@ -17,7 +17,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/serializers" ) @@ -29,7 +29,7 @@ type SocketWriter struct { ContentEncoding string `toml:"content_encoding"` Address string KeepAlivePeriod *config.Duration - tlsint.ClientConfig + common_tls.ClientConfig Log telegraf.Logger `toml:"-"` serializers.Serializer diff --git a/plugins/outputs/stomp/stomp.go b/plugins/outputs/stomp/stomp.go index 5ca8e95387df5..7e12762d0b600 100644 --- a/plugins/outputs/stomp/stomp.go +++ b/plugins/outputs/stomp/stomp.go @@ -12,7 +12,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - commontls "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/serializers" ) @@ -30,7 +30,7 @@ type STOMP struct { HeartBeatSend config.Duration `toml:"heartbeat_timeout_send"` HeartBeatRec config.Duration `toml:"heartbeat_timeout_receive"` - commontls.ClientConfig + common_tls.ClientConfig conn net.Conn stomp *stomp.Conn diff --git a/plugins/outputs/syslog/syslog.go b/plugins/outputs/syslog/syslog.go index 681d771f354dc..fc599fce8a413 100644 --- a/plugins/outputs/syslog/syslog.go +++ b/plugins/outputs/syslog/syslog.go @@ -17,7 +17,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/internal" - tlsint "github.com/influxdata/telegraf/plugins/common/tls" + common_tls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/outputs" ) @@ -37,7 +37,7 @@ type Syslog struct { Trailer nontransparent.TrailerType Log telegraf.Logger `toml:"-"` net.Conn - tlsint.ClientConfig + common_tls.ClientConfig mapper *SyslogMapper } diff --git a/plugins/outputs/timestream/timestream.go b/plugins/outputs/timestream/timestream.go index 7fd27cbab9c7b..04d8322e9896b 100644 --- a/plugins/outputs/timestream/timestream.go +++ b/plugins/outputs/timestream/timestream.go @@ -19,7 +19,7 @@ import ( "github.com/aws/smithy-go" "github.com/influxdata/telegraf" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" + common_aws "github.com/influxdata/telegraf/plugins/common/aws" "github.com/influxdata/telegraf/plugins/outputs" ) @@ -47,7 +47,7 @@ type ( Log telegraf.Logger svc WriteClient - internalaws.CredentialConfig + common_aws.CredentialConfig } WriteClient interface { @@ -76,7 +76,7 @@ const MaxRecordsPerCall = 100 const MaxWriteRoutinesDefault = 1 // WriteFactory function provides a way to mock the client instantiation for testing purposes. -var WriteFactory = func(credentialConfig *internalaws.CredentialConfig) (WriteClient, error) { +var WriteFactory = func(credentialConfig *common_aws.CredentialConfig) (WriteClient, error) { awsCreds, awsErr := credentialConfig.Credentials() if awsErr != nil { panic("Unable to load credentials config " + awsErr.Error()) diff --git a/plugins/outputs/timestream/timestream_test.go b/plugins/outputs/timestream/timestream_test.go index 34239bfc53d47..b8c0e15769cf8 100644 --- a/plugins/outputs/timestream/timestream_test.go +++ b/plugins/outputs/timestream/timestream_test.go @@ -18,7 +18,7 @@ import ( "github.com/stretchr/testify/require" "github.com/influxdata/telegraf" - internalaws "github.com/influxdata/telegraf/plugins/common/aws" + common_aws "github.com/influxdata/telegraf/plugins/common/aws" "github.com/influxdata/telegraf/testutil" ) @@ -69,7 +69,7 @@ func (m *mockTimestreamClient) DescribeDatabase( } func TestConnectValidatesConfigParameters(t *testing.T) { - WriteFactory = func(*internalaws.CredentialConfig) (WriteClient, error) { + WriteFactory = func(*common_aws.CredentialConfig) (WriteClient, error) { return &mockTimestreamClient{}, nil } // checking base arguments @@ -227,7 +227,7 @@ func TestWriteMultiMeasuresSingleTableMode(t *testing.T) { const recordCount = 100 mockClient := &mockTimestreamClient{0} - WriteFactory = func(*internalaws.CredentialConfig) (WriteClient, error) { + WriteFactory = func(*common_aws.CredentialConfig) (WriteClient, error) { return mockClient, nil } @@ -285,7 +285,7 @@ func TestWriteMultiMeasuresMultiTableMode(t *testing.T) { const recordCount = 100 mockClient := &mockTimestreamClient{0} - WriteFactory = func(*internalaws.CredentialConfig) (WriteClient, error) { + WriteFactory = func(*common_aws.CredentialConfig) (WriteClient, error) { return mockClient, nil } @@ -555,7 +555,7 @@ func (m *mockTimestreamErrorClient) DescribeDatabase( } func TestThrottlingErrorIsReturnedToTelegraf(t *testing.T) { - WriteFactory = func(*internalaws.CredentialConfig) (WriteClient, error) { + WriteFactory = func(*common_aws.CredentialConfig) (WriteClient, error) { return &mockTimestreamErrorClient{ ErrorToReturnOnWriteRecords: &types.ThrottlingException{Message: aws.String("Throttling Test")}, }, nil @@ -581,7 +581,7 @@ func TestThrottlingErrorIsReturnedToTelegraf(t *testing.T) { } func TestRejectedRecordsErrorResultsInMetricsBeingSkipped(t *testing.T) { - WriteFactory = func(*internalaws.CredentialConfig) (WriteClient, error) { + WriteFactory = func(*common_aws.CredentialConfig) (WriteClient, error) { return &mockTimestreamErrorClient{ ErrorToReturnOnWriteRecords: &types.RejectedRecordsException{Message: aws.String("RejectedRecords Test")}, }, nil @@ -612,7 +612,7 @@ func TestWriteWhenRequestsGreaterThanMaxWriteGoRoutinesCount(t *testing.T) { const totalRecords = maxWriteRecordsCalls * maxRecordsInWriteRecordsCall mockClient := &mockTimestreamClient{0} - WriteFactory = func(*internalaws.CredentialConfig) (WriteClient, error) { + WriteFactory = func(*common_aws.CredentialConfig) (WriteClient, error) { return mockClient, nil } @@ -651,7 +651,7 @@ func TestWriteWhenRequestsLesserThanMaxWriteGoRoutinesCount(t *testing.T) { const totalRecords = maxWriteRecordsCalls * maxRecordsInWriteRecordsCall mockClient := &mockTimestreamClient{0} - WriteFactory = func(*internalaws.CredentialConfig) (WriteClient, error) { + WriteFactory = func(*common_aws.CredentialConfig) (WriteClient, error) { return mockClient, nil } @@ -1221,7 +1221,7 @@ func TestCustomEndpoint(t *testing.T) { MappingMode: MappingModeMultiTable, DatabaseName: tsDbName, Log: testutil.Logger{}, - CredentialConfig: internalaws.CredentialConfig{EndpointURL: customEndpoint}, + CredentialConfig: common_aws.CredentialConfig{EndpointURL: customEndpoint}, } // validate config correctness diff --git a/plugins/outputs/wavefront/wavefront.go b/plugins/outputs/wavefront/wavefront.go index 17a658544af81..78cb076ff863a 100644 --- a/plugins/outputs/wavefront/wavefront.go +++ b/plugins/outputs/wavefront/wavefront.go @@ -15,7 +15,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - httpconfig "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/outputs" serializer "github.com/influxdata/telegraf/plugins/serializers/wavefront" ) @@ -53,7 +53,7 @@ type Wavefront struct { SourceOverride []string `toml:"source_override"` StringToNumber map[string][]map[string]float64 `toml:"string_to_number" deprecated:"1.9.0;1.35.0;use the enum processor instead"` - httpconfig.HTTPClientConfig + common_http.HTTPClientConfig sender wavefront.Sender Log telegraf.Logger `toml:"-"` @@ -382,7 +382,7 @@ func init() { ImmediateFlush: true, SendInternalMetrics: true, HTTPMaximumBatchSize: 10000, - HTTPClientConfig: httpconfig.HTTPClientConfig{Timeout: config.Duration(10 * time.Second)}, + HTTPClientConfig: common_http.HTTPClientConfig{Timeout: config.Duration(10 * time.Second)}, CSPBaseURL: "https://console.cloud.vmware.com", } }) diff --git a/plugins/processors/dedup/dedup.go b/plugins/processors/dedup/dedup.go index 35dd1c467e57c..baab6b888f0dc 100644 --- a/plugins/processors/dedup/dedup.go +++ b/plugins/processors/dedup/dedup.go @@ -10,7 +10,7 @@ import ( "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/plugins/parsers/influx" "github.com/influxdata/telegraf/plugins/processors" - influxSerializer "github.com/influxdata/telegraf/plugins/serializers/influx" + influx_serializer "github.com/influxdata/telegraf/plugins/serializers/influx" ) //go:embed sample.conf @@ -122,7 +122,7 @@ func (d *Dedup) Apply(metrics ...telegraf.Metric) []telegraf.Metric { } func (d *Dedup) GetState() interface{} { - s := &influxSerializer.Serializer{} + s := &influx_serializer.Serializer{} v := make([]telegraf.Metric, 0, len(d.Cache)) for _, value := range d.Cache { v = append(v, value) diff --git a/plugins/processors/execd/execd_test.go b/plugins/processors/execd/execd_test.go index fe57dacf7db00..9991087cdf485 100644 --- a/plugins/processors/execd/execd_test.go +++ b/plugins/processors/execd/execd_test.go @@ -19,7 +19,7 @@ import ( "github.com/influxdata/telegraf/plugins/parsers/influx" "github.com/influxdata/telegraf/plugins/processors" _ "github.com/influxdata/telegraf/plugins/serializers/all" - influxSerializer "github.com/influxdata/telegraf/plugins/serializers/influx" + influx_serializer "github.com/influxdata/telegraf/plugins/serializers/influx" "github.com/influxdata/telegraf/testutil" ) @@ -31,7 +31,7 @@ func TestExternalProcessorWorks(t *testing.T) { require.NoError(t, parser.Init()) e.SetParser(parser) - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) e.SetSerializer(serializer) @@ -100,7 +100,7 @@ func TestParseLinesWithNewLines(t *testing.T) { require.NoError(t, parser.Init()) e.SetParser(parser) - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) e.SetSerializer(serializer) @@ -166,7 +166,7 @@ func TestMain(m *testing.M) { func runCountMultiplierProgram() { fieldName := os.Getenv("FIELD_NAME") parser := influx.NewStreamParser(os.Stdin) - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} //nolint:errcheck // this should always succeed serializer.Init() @@ -364,7 +364,7 @@ func TestTracking(t *testing.T) { require.NoError(t, parser.Init()) plugin.SetParser(parser) - serializer := &influxSerializer.Serializer{} + serializer := &influx_serializer.Serializer{} require.NoError(t, serializer.Init()) plugin.SetSerializer(serializer) diff --git a/plugins/secretstores/http/http.go b/plugins/secretstores/http/http.go index 47e49ea827c2d..9dbe028b6826c 100644 --- a/plugins/secretstores/http/http.go +++ b/plugins/secretstores/http/http.go @@ -17,7 +17,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - chttp "github.com/influxdata/telegraf/plugins/common/http" + common_http "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/secretstores" ) @@ -35,7 +35,7 @@ type HTTP struct { SuccessStatusCodes []int `toml:"success_status_codes"` Transformation string `toml:"transformation"` Log telegraf.Logger `toml:"-"` - chttp.HTTPClientConfig + common_http.HTTPClientConfig DecryptionConfig client *http.Client diff --git a/testutil/container.go b/testutil/container.go index 7c51cbde1af89..e7bd89a90d137 100644 --- a/testutil/container.go +++ b/testutil/container.go @@ -8,7 +8,7 @@ import ( "io" "strings" - dockercontainer "github.com/docker/docker/api/types/container" + docker_container "github.com/docker/docker/api/types/container" "github.com/docker/go-connections/nat" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" @@ -26,7 +26,7 @@ type Container struct { Entrypoint []string Env map[string]string Files map[string]string - HostConfigModifier func(*dockercontainer.HostConfig) + HostConfigModifier func(*docker_container.HostConfig) ExposedPorts []string Cmd []string Image string diff --git a/testutil/metric.go b/testutil/metric.go index 45f6ff524d54b..069c44795969a 100644 --- a/testutil/metric.go +++ b/testutil/metric.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/influxdata/telegraf" - telegrafMetric "github.com/influxdata/telegraf/metric" + telegraf_metric "github.com/influxdata/telegraf/metric" ) type metricDiff struct { @@ -364,12 +364,12 @@ func MustMetric( tm time.Time, tp ...telegraf.ValueType, ) telegraf.Metric { - m := telegrafMetric.New(name, tags, fields, tm, tp...) + m := telegraf_metric.New(name, tags, fields, tm, tp...) return m } func FromTestMetric(met *Metric) telegraf.Metric { - m := telegrafMetric.New(met.Measurement, met.Tags, met.Fields, met.Time, met.Type) + m := telegraf_metric.New(met.Measurement, met.Tags, met.Fields, met.Time, met.Type) return m }