Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
janboll committed Sep 20, 2022
1 parent ed8345a commit f4a2934
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
10 changes: 0 additions & 10 deletions pkg/awsclient/awsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ type awsClient struct {
serviceQuotasClient servicequotasiface.ServiceQuotasAPI
}

// NewAwsClientInput input for new aws client
type NewAwsClientInput struct {
AwsCredsSecretIDKey string
AwsCredsSecretAccessKey string
AwsToken string
AwsRegion string
SecretName string
NameSpace string
}

func (c *awsClient) DescribeTransitGatewaysWithContext(ctx aws.Context, input *ec2.DescribeTransitGatewaysInput, opts ...request.Option) (*ec2.DescribeTransitGatewaysOutput, error) {
return c.ec2Client.DescribeTransitGatewaysWithContext(ctx, input, opts...)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func getAllTransitGatewaysWithContext(client awsclient.Client, ctx context.Conte
return nil, err
}
results = append(results, describeGatewaysOutput.TransitGateways...)

// TODO: replace with aws-go-sdk pagination method
for describeGatewaysOutput.NextToken != nil {
describeGatewaysInput.SetNextToken(*describeGatewaysOutput.NextToken)
describeGatewaysOutput, err := client.DescribeTransitGatewaysWithContext(ctx, describeGatewaysInput)
Expand Down
4 changes: 2 additions & 2 deletions pkg/ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func TestGetQuotaValueWithContext(t *testing.T) {

mockClient.EXPECT().GetServiceQuotaWithContext(ctx,
createGetServiceQuotaInput(ec2ServiceCode, transitGatewayPerAccountQuotaCode)).Return(
&servicequotas.GetServiceQuotaOutput{Quota: &servicequotas.ServiceQuota{Value: aws.Float64(1337.0)}}, nil,
&servicequotas.GetServiceQuotaOutput{Quota: &servicequotas.ServiceQuota{Value: aws.Float64(123.0)}}, nil,
)

quotaValue, err := getQuotaValueWithContext(mockClient, ec2ServiceCode, transitGatewayPerAccountQuotaCode, ctx)
assert.Nil(t, err)
assert.Equal(t, quotaValue, 1337.0)
assert.Equal(t, quotaValue, 123.0)
}
4 changes: 2 additions & 2 deletions pkg/route53.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (e *Route53Exporter) getHostedZonesPerAccountMetrics(client awsclient.Clien
// CollectLoop runs indefinitely to collect the route53 metrics in a cache. Metrics are only written into the cache once all have been collected to ensure that we don't have a partial collect.
func (e *Route53Exporter) CollectLoop() {
route53Svc := route53.New(e.sess)
awsclient := awsclient.NewClientFromSession(e.sess)
client := awsclient.NewClientFromSession(e.sess)

for {
ctx, ctxCancelFunc := context.WithTimeout(context.Background(), e.timeout)
Expand All @@ -127,7 +127,7 @@ func (e *Route53Exporter) CollectLoop() {
AwsExporterMetrics.IncrementErrors()
}

err = e.getHostedZonesPerAccountMetrics(awsclient, hostedZones, ctx)
err = e.getHostedZonesPerAccountMetrics(client, hostedZones, ctx)
if err != nil {
level.Error(e.logger).Log("msg", "Could not get limits for hosted zone", "error", err.Error())
AwsExporterMetrics.IncrementErrors()
Expand Down

0 comments on commit f4a2934

Please sign in to comment.