-
Notifications
You must be signed in to change notification settings - Fork 1
/
lib.go
37 lines (30 loc) · 1.03 KB
/
lib.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package pkg
import (
"time"
"github.com/anchore/ecs-inventory/pkg/connection"
"github.com/anchore/ecs-inventory/pkg/inventory"
"github.com/anchore/ecs-inventory/pkg/logger"
)
var log logger.Logger
// PeriodicallyGetInventoryReport periodically retrieve image results and report/output them according to the configuration.
// Note: Errors do not cause the function to exit, since this is periodically running
func PeriodicallyGetInventoryReport(
pollingIntervalSeconds int,
anchoreDetails connection.AnchoreInfo,
region string,
quiet, dryRun bool,
) {
// Fire off a ticker that reports according to a configurable polling interval
ticker := time.NewTicker(time.Duration(pollingIntervalSeconds) * time.Second)
for {
err := inventory.GetInventoryReportsForRegion(region, anchoreDetails, quiet, dryRun)
if err != nil {
log.Error("Failed to get Inventory Reports for region", err)
}
// Wait at least as long as the ticker
log.Debugf("Start new gather %s", <-ticker.C)
}
}
func SetLogger(logger logger.Logger) {
log = logger
}