Skip to content

Commit

Permalink
fix: nil pointer error due to missing aws connection
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra authored and moshloop committed Jun 3, 2024
1 parent ea3b58a commit e3d74b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
14 changes: 7 additions & 7 deletions api/v1/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (

// AWS ...
type AWS struct {
BaseScraper `json:",inline"`
*AWSConnection `json:",inline"`
Compliance bool `json:"compliance,omitempty"`
CloudTrail CloudTrail `json:"cloudtrail,omitempty"`
Include []string `json:"include,omitempty"`
Exclude []string `json:"exclude,omitempty"`
CostReporting CostReporting `json:"costReporting,omitempty"`
BaseScraper `json:",inline"`
AWSConnection `json:",inline"`
Compliance bool `json:"compliance,omitempty"`
CloudTrail CloudTrail `json:"cloudtrail,omitempty"`
Include []string `json:"include,omitempty"`
Exclude []string `json:"exclude,omitempty"`
CostReporting CostReporting `json:"costReporting,omitempty"`
}

type CloudTrail struct {
Expand Down
6 changes: 1 addition & 5 deletions api/v1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion scrapers/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (ctx AWSContext) String() string {
}

func (aws Scraper) getContext(ctx api.ScrapeContext, awsConfig v1.AWS, region string) (*AWSContext, error) {
session, err := NewSession(ctx, *awsConfig.AWSConnection, region)
session, err := NewSession(ctx, awsConfig.AWSConnection, region)
if err != nil {
return nil, fmt.Errorf("failed to create AWS session for region=%q: %w", region, err)
}
Expand Down
4 changes: 2 additions & 2 deletions scrapers/aws/cost.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func getAWSAthenaConfig(ctx api.ScrapeContext, awsConfig v1.AWS) (*athena.Config
return nil, err
}

accessKey, secretKey, err := getAccessAndSecretKey(ctx, *awsConfig.AWSConnection)
accessKey, secretKey, err := getAccessAndSecretKey(ctx, awsConfig.AWSConnection)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -144,7 +144,7 @@ func (awsCost CostScraper) Scrape(ctx api.ScrapeContext) v1.ScrapeResults {
var results v1.ScrapeResults

for _, awsConfig := range ctx.ScrapeConfig().Spec.AWS {
session, err := NewSession(ctx, *awsConfig.AWSConnection, awsConfig.Region[0])
session, err := NewSession(ctx, awsConfig.AWSConnection, awsConfig.Region[0])
if err != nil {
return results.Errorf(err, "failed to create AWS session")
}
Expand Down

0 comments on commit e3d74b8

Please sign in to comment.