Skip to content

Commit

Permalink
chore(linters): Enable import-alias-naming and `redundant-import-al…
Browse files Browse the repository at this point in the history
…ias` rules for revive
  • Loading branch information
zak-pawel committed Sep 4, 2024
1 parent 93a36f1 commit 9d7a7e5
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 35 deletions.
3 changes: 2 additions & 1 deletion plugins/common/auth/basic_auth_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package auth

import (
"github.com/stretchr/testify/require"
"net/http/httptest"
"testing"

"github.com/stretchr/testify/require"
)

func TestBasicAuth_VerifyWithCredentials(t *testing.T) {
Expand Down
32 changes: 16 additions & 16 deletions plugins/inputs/aerospike/aerospike.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"
"time"

"github.com/aerospike/aerospike-client-go/v5"
as "github.com/aerospike/aerospike-client-go/v5"

"github.com/influxdata/telegraf"
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
Expand Down Expand Up @@ -98,11 +98,11 @@ func (a *Aerospike) Gather(acc telegraf.Accumulator) error {
}

func (a *Aerospike) gatherServer(acc telegraf.Accumulator, hostPort string) error {
policy := aerospike.NewClientPolicy()
policy := as.NewClientPolicy()
policy.User = a.Username
policy.Password = a.Password
policy.TlsConfig = a.tlsConfig
asHosts, err := aerospike.NewHosts(hostPort)
asHosts, err := as.NewHosts(hostPort)
if err != nil {
return err
}
Expand All @@ -111,11 +111,11 @@ func (a *Aerospike) gatherServer(acc telegraf.Accumulator, hostPort string) erro
asHost.TLSName = a.TLSName
}
}
c, err := aerospike.NewClientWithPolicyAndHost(policy, asHosts...)
c, err := as.NewClientWithPolicyAndHost(policy, asHosts...)
if err != nil {
return err
}
asInfoPolicy := aerospike.NewInfoPolicy()
asInfoPolicy := as.NewInfoPolicy()
defer c.Close()

nodes := c.GetNodes()
Expand Down Expand Up @@ -189,7 +189,7 @@ func (a *Aerospike) gatherServer(acc telegraf.Accumulator, hostPort string) erro
return nil
}

func (a *Aerospike) getNodeInfo(n *aerospike.Node, infoPolicy *aerospike.InfoPolicy) (map[string]string, error) {
func (a *Aerospike) getNodeInfo(n *as.Node, infoPolicy *as.InfoPolicy) (map[string]string, error) {
stats, err := n.RequestInfo(infoPolicy, "statistics")
if err != nil {
return nil, err
Expand All @@ -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 *aerospike.Node, infoPolicy *aerospike.InfoPolicy) ([]string, error) {
func (a *Aerospike) getNamespaces(n *as.Node, infoPolicy *as.InfoPolicy) ([]string, error) {
var namespaces []string
if len(a.Namespaces) == 0 {
info, err := n.RequestInfo(infoPolicy, "namespaces")
Expand All @@ -231,7 +231,7 @@ func (a *Aerospike) getNamespaces(n *aerospike.Node, infoPolicy *aerospike.InfoP
return namespaces, nil
}

func (a *Aerospike) getNamespaceInfo(namespace string, n *aerospike.Node, infoPolicy *aerospike.InfoPolicy) (map[string]string, error) {
func (a *Aerospike) getNamespaceInfo(namespace string, n *as.Node, infoPolicy *as.InfoPolicy) (map[string]string, error) {
stats, err := n.RequestInfo(infoPolicy, "namespace/"+namespace)
if err != nil {
return nil, err
Expand Down Expand Up @@ -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 *aerospike.Node, infoPolicy *aerospike.InfoPolicy) ([]string, error) {
func (a *Aerospike) getSets(n *as.Node, infoPolicy *as.InfoPolicy) ([]string, error) {
var namespaceSets []string
// Gather all sets
if len(a.Sets) == 0 {
Expand Down Expand Up @@ -296,7 +296,7 @@ func (a *Aerospike) getSets(n *aerospike.Node, infoPolicy *aerospike.InfoPolicy)
return namespaceSets, nil
}

func (a *Aerospike) getSetInfo(namespaceSet string, n *aerospike.Node, infoPolicy *aerospike.InfoPolicy) (map[string]string, error) {
func (a *Aerospike) getSetInfo(namespaceSet string, n *as.Node, infoPolicy *as.InfoPolicy) (map[string]string, error) {
stats, err := n.RequestInfo(infoPolicy, "sets/"+namespaceSet)
if err != nil {
return nil, err
Expand Down Expand Up @@ -331,8 +331,8 @@ func (a *Aerospike) getTTLHistogram(
hostPort string,
namespace string,
set string,
n *aerospike.Node,
infoPolicy *aerospike.InfoPolicy,
n *as.Node,
infoPolicy *as.InfoPolicy,
) error {
stats, err := a.getHistogram(namespace, set, "ttl", n, infoPolicy)
if err != nil {
Expand All @@ -350,8 +350,8 @@ func (a *Aerospike) getObjectSizeLinearHistogram(
hostPort string,
namespace string,
set string,
n *aerospike.Node,
infoPolicy *aerospike.InfoPolicy,
n *as.Node,
infoPolicy *as.InfoPolicy,
) error {
stats, err := a.getHistogram(namespace, set, "object-size-linear", n, infoPolicy)
if err != nil {
Expand All @@ -368,8 +368,8 @@ func (a *Aerospike) getHistogram(
namespace string,
set string,
histogramType string,
n *aerospike.Node,
infoPolicy *aerospike.InfoPolicy,
n *as.Node,
infoPolicy *as.InfoPolicy,
) (map[string]string, error) {
var queryArg string
if len(set) > 0 {
Expand Down
3 changes: 2 additions & 1 deletion plugins/inputs/azure_monitor/azure_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ package azure_monitor
import (
_ "embed"
"fmt"
"sync"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"sync"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/azure_monitor/azure_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
"os"
"testing"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
"github.com/influxdata/toml"
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"sync"
"time"

"github.com/cisco-ie/nx-telemetry-proto/mdt_dialout"
mdtdialout "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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
"time"

"github.com/cisco-ie/nx-telemetry-proto/mdt_dialout"
mdtdialout "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"
Expand Down
3 changes: 2 additions & 1 deletion plugins/inputs/cloud_pubsub/subscription_gcp.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package cloud_pubsub

import (
"cloud.google.com/go/pubsub"
"context"
"time"

"cloud.google.com/go/pubsub"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/eventhub_consumer/eventhub_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"sync"
"time"

"github.com/Azure/azure-event-hubs-go/v3"
eventhub "github.com/Azure/azure-event-hubs-go/v3"
"github.com/Azure/azure-event-hubs-go/v3/persist"

"github.com/influxdata/telegraf"
Expand Down
7 changes: 4 additions & 3 deletions plugins/inputs/exec/run_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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{
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
}
Expand Down
4 changes: 3 additions & 1 deletion plugins/inputs/infiniband/infiniband_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
package infiniband

import (
"testing"

"github.com/Mellanox/rdmamap"

"github.com/influxdata/telegraf/testutil"
"testing"
)

func TestInfiniband(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/intel_baseband/sock_connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/influxdata/telegraf/plugins/inputs/intel_baseband/mock"
mocks "github.com/influxdata/telegraf/plugins/inputs/intel_baseband/mock"
)

func TestWriteCommandToSocket(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/influxdata/telegraf/config"
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/auth"
"github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/oc"
authentication "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/auth"
telemetry "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/oc"
)

//go:embed sample.conf
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/ldap/ldap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func TestOpenLDAPReverseDNIntegration(t *testing.T) {
testutil.RequireMetricsStructureEqual(t, expected, actual, testutil.IgnoreTime())
}

func TestOpenLDAPStarttls_internalegration(t *testing.T) {
func TestOpenLDAPStartTLSIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/riemann_listener/riemann_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"sync"
"time"

"github.com/riemann/riemann-go-client"
riemanngo "github.com/riemann/riemann-go-client"
riemango_proto "github.com/riemann/riemann-go-client/proto"
"google.golang.org/protobuf/proto"

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion plugins/outputs/cloud_pubsub/topic_gcp.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package cloud_pubsub

import (
"cloud.google.com/go/pubsub"
"context"

"cloud.google.com/go/pubsub"
)

type (
Expand Down

0 comments on commit 9d7a7e5

Please sign in to comment.