Skip to content

Commit

Permalink
fix revive errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chouetz committed Nov 12, 2024
1 parent f6e7592 commit 0c4a80d
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 48 deletions.
6 changes: 3 additions & 3 deletions cmd/cluster-agent/api/v1/languagedetection/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ func (ownersLanguages *OwnersLanguages) handleKubeAPIServerUnsetEvents(events []
case workloadmeta.KindKubernetesDeployment:
// extract deployment name and namespace from entity id
deployment := event.Entity.(*workloadmeta.KubernetesDeployment)
deploymentIds := strings.Split(deployment.GetID().ID, "/")
namespace := deploymentIds[0]
deploymentName := deploymentIds[1]
deploymentIDs := strings.Split(deployment.GetID().ID, "/")
namespace := deploymentIDs[0]
deploymentName := deploymentIDs[1]
delete(ownersLanguages.containersLanguages, langUtil.NewNamespacedOwnerReference("apps/v1", langUtil.KindDeployment, deploymentName, namespace))
_ = wlm.Push(workloadmeta.SourceLanguageDetectionServer, workloadmeta.Event{
Type: workloadmeta.EventTypeUnset,
Expand Down
6 changes: 3 additions & 3 deletions pkg/clusteragent/languagedetection/patcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ func (lp *languagePatcher) handleDeploymentEvent(event workloadmeta.Event) {
deploymentID := event.Entity.(*workloadmeta.KubernetesDeployment).ID

// extract deployment name and namespace from entity id
deploymentIds := strings.Split(deploymentID, "/")
namespace := deploymentIds[0]
deploymentName := deploymentIds[1]
deploymentIDs := strings.Split(deploymentID, "/")
namespace := deploymentIDs[0]
deploymentName := deploymentIDs[1]

// get the complete entity
deployment, err := lp.store.GetKubernetesDeployment(deploymentID)
Expand Down
4 changes: 2 additions & 2 deletions pkg/collector/corechecks/ebpf/probe/ebpfcheck/prog.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ type ProgInfo struct {
XlatedProgInsns Pointer
LoadTime uint64
CreatedByUID uint32
NrMapIds uint32
MapIds Pointer
NrMapIDs uint32
MapIDs Pointer
Name ObjName
Ifindex uint32
_ [4]byte /* unsupported bitfield */
Expand Down
36 changes: 18 additions & 18 deletions pkg/collector/corechecks/snmp/internal/checkconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,23 +708,23 @@ func Test_getProfileForSysObjectID(t *testing.T) {
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"},
},
},
"profile2": profile.ProfileConfig{
Definition: profiledefinition.ProfileDefinition{
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.10"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.10"},
},
},
"profile3": profile.ProfileConfig{
Definition: profiledefinition.ProfileDefinition{
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.5.*"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.5.*"},
},
},
}
Expand All @@ -734,7 +734,7 @@ func Test_getProfileForSysObjectID(t *testing.T) {
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.***.*"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.***.*"},
},
},
}
Expand All @@ -744,7 +744,7 @@ func Test_getProfileForSysObjectID(t *testing.T) {
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.[.*"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.[.*"},
},
},
}
Expand All @@ -754,23 +754,23 @@ func Test_getProfileForSysObjectID(t *testing.T) {
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
},
},
"profile2": profile.ProfileConfig{
Definition: profiledefinition.ProfileDefinition{
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
},
},
"profile3": profile.ProfileConfig{
Definition: profiledefinition.ProfileDefinition{
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.4"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.4"},
},
},
}
Expand All @@ -780,7 +780,7 @@ func Test_getProfileForSysObjectID(t *testing.T) {
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "userMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
},
IsUserProfile: true,
},
Expand All @@ -789,7 +789,7 @@ func Test_getProfileForSysObjectID(t *testing.T) {
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "defaultMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
},
},
}
Expand All @@ -799,15 +799,15 @@ func Test_getProfileForSysObjectID(t *testing.T) {
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "defaultMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
},
},
"user-profile": profile.ProfileConfig{
Definition: profiledefinition.ProfileDefinition{
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "userMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
},
IsUserProfile: true,
},
Expand All @@ -818,15 +818,15 @@ func Test_getProfileForSysObjectID(t *testing.T) {
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "defaultMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.*"},
SysObjectIDs: profiledefinition.StringArray{"1.3.*"},
},
},
"user-profile": profile.ProfileConfig{
Definition: profiledefinition.ProfileDefinition{
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "userMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.*"},
SysObjectIDs: profiledefinition.StringArray{"1.*"},
},
IsUserProfile: true,
},
Expand All @@ -837,7 +837,7 @@ func Test_getProfileForSysObjectID(t *testing.T) {
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
},
IsUserProfile: true,
},
Expand All @@ -846,7 +846,7 @@ func Test_getProfileForSysObjectID(t *testing.T) {
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.2.3.4.5", Name: "someMetric"}},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3"},
},
IsUserProfile: true,
},
Expand Down Expand Up @@ -1120,7 +1120,7 @@ func Test_snmpConfig_setProfile(t *testing.T) {
},
},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"},
}
profile2 := profiledefinition.ProfileDefinition{
Device: profiledefinition.DeviceMeta{Vendor: "b-vendor"},
Expand Down Expand Up @@ -1171,7 +1171,7 @@ func Test_snmpConfig_setProfile(t *testing.T) {
},
},
},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"},
}

mockProfiles := profile.ProfileConfigMap{
Expand Down
2 changes: 1 addition & 1 deletion pkg/collector/corechecks/snmp/internal/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func GetProfileForSysObjectID(profiles ProfileConfigMap, sysObjectID string) (st
var matchedOids []string

for profile, profConfig := range profiles {
for _, oidPattern := range profConfig.Definition.SysObjectIds {
for _, oidPattern := range profConfig.Definition.SysObjectIDs {
found, err := filepath.Match(oidPattern, sysObjectID)
if err != nil {
log.Debugf("pattern error: %s", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func FixtureProfileDefinitionMap() ProfileConfigMap {
Metrics: metrics,
Extends: []string{"_base.yaml", "_generic-if.yaml"},
Device: profiledefinition.DeviceMeta{Vendor: "f5"},
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.3375.2.1.3.4.*"},
StaticTags: []string{"static_tag:from_profile_root", "static_tag:from_base_profile"},
MetricTags: []profiledefinition.MetricTagConfig{
{
Expand Down Expand Up @@ -190,7 +190,7 @@ func FixtureProfileDefinitionMap() ProfileConfigMap {
},
"another_profile": ProfileConfig{
Definition: profiledefinition.ProfileDefinition{
SysObjectIds: profiledefinition.StringArray{"1.3.6.1.4.1.32473.1.1"},
SysObjectIDs: profiledefinition.StringArray{"1.3.6.1.4.1.32473.1.1"},
Metrics: []profiledefinition.MetricsConfig{
{Symbol: profiledefinition.SymbolConfig{OID: "1.3.6.1.2.1.1.999.0", Name: "anotherMetric"}, MetricType: ""},
},
Expand Down
27 changes: 14 additions & 13 deletions pkg/databasemonitoring/aws/aurora_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ package aws
import (
"context"
"errors"
"testing"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/rds"
"github.com/aws/aws-sdk-go-v2/service/rds/types"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"testing"
)

type mockrdsServiceConfigurer func(k *MockrdsService)
Expand All @@ -24,22 +25,22 @@ func TestGetAuroraClusterEndpoints(t *testing.T) {
testCases := []struct {
name string
configureClient mockrdsServiceConfigurer
clusterIds []string
clusterIDs []string
expectedAuroraClusterEndpoints map[string]*AuroraCluster
expectedErr error
}{
{
name: "no cluster ids given",
configureClient: func(k *MockrdsService) {},
clusterIds: nil,
clusterIDs: nil,
expectedErr: errors.New("at least one database cluster identifier is required"),
},
{
name: "single cluster id returns no results from API",
configureClient: func(k *MockrdsService) {
k.EXPECT().DescribeDBInstances(gomock.Any(), gomock.Any()).Return(&rds.DescribeDBInstancesOutput{}, nil).Times(1)
},
clusterIds: []string{"test-cluster"},
clusterIDs: []string{"test-cluster"},
expectedAuroraClusterEndpoints: nil,
expectedErr: errors.New("no endpoints found for aurora clusters with id(s): test-cluster"),
},
Expand All @@ -48,7 +49,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) {
configureClient: func(k *MockrdsService) {
k.EXPECT().DescribeDBInstances(gomock.Any(), gomock.Any()).Return(nil, errors.New("big time error")).Times(1)
},
clusterIds: []string{"test-cluster"},
clusterIDs: []string{"test-cluster"},
expectedAuroraClusterEndpoints: nil,
expectedErr: errors.New("error running GetAuroraClusterEndpoints big time error"),
},
Expand All @@ -71,7 +72,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) {
},
}, nil).Times(1)
},
clusterIds: []string{"test-cluster"},
clusterIDs: []string{"test-cluster"},
expectedAuroraClusterEndpoints: map[string]*AuroraCluster{
"test-cluster": {
Instances: []*Instance{
Expand Down Expand Up @@ -126,7 +127,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) {
},
}, nil).Times(1)
},
clusterIds: []string{"test-cluster"},
clusterIDs: []string{"test-cluster"},
expectedAuroraClusterEndpoints: map[string]*AuroraCluster{
"test-cluster": {
Instances: []*Instance{
Expand Down Expand Up @@ -193,7 +194,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) {
},
}, nil).Times(1)
},
clusterIds: []string{"test-cluster"},
clusterIDs: []string{"test-cluster"},
expectedAuroraClusterEndpoints: map[string]*AuroraCluster{
"test-cluster": {
Instances: []*Instance{
Expand Down Expand Up @@ -226,7 +227,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) {
},
}, nil).Times(1)
},
clusterIds: []string{"test-cluster", "test-cluster-2"},
clusterIDs: []string{"test-cluster", "test-cluster-2"},
expectedAuroraClusterEndpoints: map[string]*AuroraCluster{
"test-cluster": {
Instances: []*Instance{
Expand Down Expand Up @@ -281,7 +282,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) {
},
}, nil).Times(1)
},
clusterIds: []string{"test-cluster", "test-cluster-2"},
clusterIDs: []string{"test-cluster", "test-cluster-2"},
expectedAuroraClusterEndpoints: map[string]*AuroraCluster{
"test-cluster": {
Instances: []*Instance{
Expand Down Expand Up @@ -319,7 +320,7 @@ func TestGetAuroraClusterEndpoints(t *testing.T) {
mockClient := NewMockrdsService(ctrl)
tt.configureClient(mockClient)
client := &Client{client: mockClient}
clusters, err := client.GetAuroraClusterEndpoints(context.Background(), tt.clusterIds)
clusters, err := client.GetAuroraClusterEndpoints(context.Background(), tt.clusterIDs)
if tt.expectedErr != nil {
assert.EqualError(t, err, tt.expectedErr.Error())
return
Expand Down Expand Up @@ -598,12 +599,12 @@ func TestGetAuroraClustersFromTags(t *testing.T) {
}
}

func createDescribeDBInstancesRequest(clusterIds []string) *rds.DescribeDBInstancesInput {
func createDescribeDBInstancesRequest(clusterIDs []string) *rds.DescribeDBInstancesInput {
return &rds.DescribeDBInstancesInput{
Filters: []types.Filter{
{
Name: aws.String("db-cluster-id"),
Values: clusterIds,
Values: clusterIDs,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type DeviceMeta struct {
type ProfileDefinition struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
SysObjectIds StringArray `yaml:"sysobjectid,omitempty" json:"sysobjectid,omitempty"`
SysObjectIDs StringArray `yaml:"sysobjectid,omitempty" json:"sysobjectid,omitempty"`
Extends []string `yaml:"extends,omitempty" json:"extends,omitempty"`
Metadata MetadataConfig `yaml:"metadata,omitempty" json:"metadata,omitempty" jsonschema:"-"`
MetricTags []MetricTagConfig `yaml:"metric_tags,omitempty" json:"metric_tags,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

type MyStringArray struct {
SomeIds StringArray `yaml:"my_field"`
SomeIDs StringArray `yaml:"my_field"`
}

type MySymbolStruct struct {
Expand Down Expand Up @@ -47,7 +47,7 @@ metric_tags:

func TestStringArray_UnmarshalYAML_array(t *testing.T) {
myStruct := MyStringArray{}
expected := MyStringArray{SomeIds: StringArray{"aaa", "bbb"}}
expected := MyStringArray{SomeIDs: StringArray{"aaa", "bbb"}}

yaml.Unmarshal([]byte(`
my_field:
Expand All @@ -60,7 +60,7 @@ my_field:

func TestStringArray_UnmarshalYAML_string(t *testing.T) {
myStruct := MyStringArray{}
expected := MyStringArray{SomeIds: StringArray{"aaa"}}
expected := MyStringArray{SomeIDs: StringArray{"aaa"}}

yaml.Unmarshal([]byte(`
my_field: aaa
Expand Down
4 changes: 2 additions & 2 deletions pkg/security/secl/rules/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (o *Opts) WithEventTypeEnabled(eventTypes map[eval.EventType]bool) *Opts {
}

// WithReservedRuleIDs set reserved rule ids
func (o *Opts) WithReservedRuleIDs(ruleIds []RuleID) *Opts {
o.ReservedRuleIDs = ruleIds
func (o *Opts) WithReservedRuleIDs(ruleIDs []RuleID) *Opts {
o.ReservedRuleIDs = ruleIDs
return o
}

Expand Down

0 comments on commit 0c4a80d

Please sign in to comment.