Add a generic Walk()'er to list a bucket, optinally prefix (#9026)

This generic Walk() is used by likes of Lifecyle, or
KMS to rotate keys or any other functionality which
relies on this functionality.
This commit is contained in:
Harshavardhana
2020-02-25 21:22:28 +05:30
committed by GitHub
parent ece0d4ac53
commit 23a8411732
24 changed files with 296 additions and 140 deletions

View File

@@ -99,8 +99,11 @@ func (lc Lifecycle) Validate() error {
// FilterRuleActions returns the expiration and transition from the object name
// after evaluating all rules.
func (lc Lifecycle) FilterRuleActions(objName, objTags string) (Expiration, Transition) {
if objName == "" {
return Expiration{}, Transition{}
}
for _, rule := range lc.Rules {
if strings.ToLower(rule.Status) != "enabled" {
if rule.Status == Disabled {
continue
}
tags := rule.Tags()
@@ -121,6 +124,9 @@ func (lc Lifecycle) FilterRuleActions(objName, objTags string) (Expiration, Tran
// against the object name and its modification time.
func (lc Lifecycle) ComputeAction(objName, objTags string, modTime time.Time) Action {
var action = NoneAction
if modTime.IsZero() {
return action
}
exp, _ := lc.FilterRuleActions(objName, objTags)
if !exp.IsDateNull() {
if time.Now().After(exp.Date.Time) {