Skip to content
This repository has been archived by the owner on Feb 18, 2020. It is now read-only.

Commit

Permalink
only indexes that start with prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdvir committed Sep 27, 2017
1 parent 25d060b commit fbca859
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,18 @@ func runCommand() {
}

for _, indexName := range indexNames {
date := strings.TrimPrefix(indexName, prefix)
dateArr := strings.Split(date, ".")
nowTime := time.Now()
indexYear, _ := strconv.Atoi(dateArr[0])
indexMonth, _ := strconv.Atoi(dateArr[1])
indexDay, _ := strconv.Atoi(dateArr[2])
incidentTime := time.Date(indexYear, time.Month(indexMonth), indexDay, 0, 0, 0, 0, nowTime.Location())
if daysDiff(nowTime, incidentTime) > olderThanInDays {
wg.Add(1)
go deleteIncident(ctx, client, indexName)
if strings.HasPrefix(indexName, prefix) {
date := strings.TrimPrefix(indexName, prefix)
dateArr := strings.Split(date, ".")
nowTime := time.Now()
indexYear, _ := strconv.Atoi(dateArr[0])
indexMonth, _ := strconv.Atoi(dateArr[1])
indexDay, _ := strconv.Atoi(dateArr[2])
incidentTime := time.Date(indexYear, time.Month(indexMonth), indexDay, 0, 0, 0, 0, nowTime.Location())
if daysDiff(nowTime, incidentTime) > olderThanInDays {
wg.Add(1)
go deleteIncident(ctx, client, indexName)
}
}
}

Expand Down

0 comments on commit fbca859

Please sign in to comment.