2023-11-01 11:16:18 -05:00
|
|
|
package retention
|
|
|
|
|
|
|
|
import (
|
2024-01-31 23:34:07 -05:00
|
|
|
mTypes "zotregistry.dev/zot/pkg/meta/types"
|
|
|
|
"zotregistry.dev/zot/pkg/retention/types"
|
2023-11-01 11:16:18 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func GetCandidates(repoMeta mTypes.RepoMeta) []*types.Candidate {
|
|
|
|
candidates := make([]*types.Candidate, 0)
|
|
|
|
|
|
|
|
// collect all statistic of repo's manifests
|
|
|
|
for tag, desc := range repoMeta.Tags {
|
|
|
|
for digestStr, stats := range repoMeta.Statistics {
|
|
|
|
if digestStr == desc.Digest {
|
|
|
|
candidate := &types.Candidate{
|
|
|
|
MediaType: desc.MediaType,
|
|
|
|
DigestStr: digestStr,
|
|
|
|
Tag: tag,
|
|
|
|
PushTimestamp: stats.PushTimestamp,
|
|
|
|
PullTimestamp: stats.LastPullTimestamp,
|
|
|
|
}
|
|
|
|
|
|
|
|
candidates = append(candidates, candidate)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return candidates
|
|
|
|
}
|