Skip to content

Commit

Permalink
Amend pagination to avoid nil pointer dereference (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribbybibby authored Apr 26, 2021
1 parent 44d5e40 commit bdf0932
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions s3_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {

// Continue making requests until we've listed and compared the date of every object
startList := time.Now()
truncated := true
for truncated {
for {
resp, err := e.svc.ListObjectsV2(query)
if err != nil {
log.Errorln(err)
Expand All @@ -113,8 +112,10 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
biggestObjectSize = *item.Size
}
}
if resp.NextContinuationToken == nil {
break
}
query.ContinuationToken = resp.NextContinuationToken
truncated = *resp.IsTruncated
}
listDuration := time.Now().Sub(startList).Seconds()

Expand Down

0 comments on commit bdf0932

Please sign in to comment.