Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chadpatel committed Dec 19, 2024
1 parent 2beb9c5 commit f3918ed
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion extension/entitystore/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (m *mockMetadataProvider) InstanceID(ctx context.Context) (string, error) {
return "MockInstanceID", nil
}

func (m *mockMetadataProvider) InstanceTags(ctx context.Context) ([]string, error) {
func (m *mockMetadataProvider) InstanceTags(_ context.Context) ([]string, error) {
if m.InstanceTagError {
return nil, errors.New("an error occurred for instance tag retrieval")
}
Expand Down
3 changes: 2 additions & 1 deletion extension/entitystore/serviceprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (s *serviceprovider) scrapeImdsServiceNameAndASG() error {
}
}
// case sensitive
if originalCaseKey, _ := lowerTagKeys[strings.ToLower(ec2tagger.Ec2InstanceTagKeyASG)]; originalCaseKey == ec2tagger.Ec2InstanceTagKeyASG {
if originalCaseKey := lowerTagKeys[strings.ToLower(ec2tagger.Ec2InstanceTagKeyASG)]; originalCaseKey == ec2tagger.Ec2InstanceTagKeyASG {
asg, err := s.metadataProvider.InstanceTagValue(context.Background(), ec2tagger.Ec2InstanceTagKeyASG)
if err == nil {
s.logger.Debug("AutoScalingGroup retrieved through IMDS")
Expand All @@ -279,6 +279,7 @@ func (s *serviceprovider) scrapeImdsServiceNameAndASG() error {
s.mutex.Unlock()
}
}

if s.GetIMDSServiceName() == "" {
s.logger.Debug("Service name not found through IMDS")
}
Expand Down
8 changes: 4 additions & 4 deletions internal/ec2metadataprovider/ec2metadataprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ func (c *metadataClient) ClientIAMRole(ctx context.Context) (string, error) {
}

func (c *metadataClient) InstanceTags(ctx context.Context) ([]string, error) {
if tags, err := withMetadataFallbackRetry(ctx, c, func(metadataClient *ec2metadata.EC2Metadata) (string, error) {
tags, err := withMetadataFallbackRetry(ctx, c, func(metadataClient *ec2metadata.EC2Metadata) (string, error) {
return metadataClient.GetMetadataWithContext(ctx, "tags/instance")
}); err != nil {
})
if err != nil {
return nil, err
} else {
return strings.Fields(tags), nil
}
return strings.Fields(tags), nil
}

func (c *metadataClient) InstanceTagValue(ctx context.Context, tagKey string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/processors/ec2tagger/ec2tagger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (m *mockMetadataProvider) InstanceID(ctx context.Context) (string, error) {
return "MockInstanceID", nil
}

func (m *mockMetadataProvider) InstanceTags(ctx context.Context) ([]string, error) {
func (m *mockMetadataProvider) InstanceTags(_ context.Context) ([]string, error) {
return []string{"MockInstanceTag"}, nil
}

Expand Down

0 comments on commit f3918ed

Please sign in to comment.