Fix index out of range when reading snapshots list
continuous-integration/drone/push Build was killed Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
IamTheFij 2023-11-07 11:03:18 -08:00
parent 390074e048
commit d049228980
1 changed files with 4 additions and 2 deletions

6
job.go
View File

@ -280,8 +280,10 @@ func (j Job) Run() {
result.LastError = err
} else {
Metrics.SnapshotCurrentCount.WithLabelValues(j.Name).Set(float64(len(snapshots)))
latestSnapshot := snapshots[len(snapshots)-1]
Metrics.SnapshotLatestTime.WithLabelValues(j.Name).Set(float64(latestSnapshot.Time.Unix()))
if len(snapshots) > 0 {
latestSnapshot := snapshots[len(snapshots)-1]
Metrics.SnapshotLatestTime.WithLabelValues(j.Name).Set(float64(latestSnapshot.Time.Unix()))
}
}
if result.Success {