|
|
@ -122,20 +122,10 @@ func (lc Lifecycle) ComputeAction(objName, objTags string, modTime time.Time) (a |
|
|
|
if modTime.IsZero() { |
|
|
|
if modTime.IsZero() { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
rules := lc.FilterActionableRules(objName, objTags) |
|
|
|
|
|
|
|
for _, rule := range rules { |
|
|
|
_, expiryTime := lc.PredictExpiryTime(objName, modTime, objTags) |
|
|
|
if !rule.Expiration.IsDateNull() { |
|
|
|
if !expiryTime.IsZero() && time.Now().After(expiryTime) { |
|
|
|
if time.Now().After(rule.Expiration.Date.Time) { |
|
|
|
return DeleteAction |
|
|
|
action = DeleteAction |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if !rule.Expiration.IsDaysNull() { |
|
|
|
|
|
|
|
if time.Now().After(expectedExpiryTime(modTime, rule.Expiration.Days)) { |
|
|
|
|
|
|
|
action = DeleteAction |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -152,7 +142,7 @@ func expectedExpiryTime(modTime time.Time, days ExpirationDays) time.Time { |
|
|
|
|
|
|
|
|
|
|
|
// PredictExpiryTime returns the expiry date/time of a given object
|
|
|
|
// PredictExpiryTime returns the expiry date/time of a given object
|
|
|
|
// after evaluting the current lifecycle document.
|
|
|
|
// after evaluting the current lifecycle document.
|
|
|
|
func (lc Lifecycle) PredictExpiryTime(objName, objTags string) (string, time.Time) { |
|
|
|
func (lc Lifecycle) PredictExpiryTime(objName string, modTime time.Time, objTags string) (string, time.Time) { |
|
|
|
var finalExpiryDate time.Time |
|
|
|
var finalExpiryDate time.Time |
|
|
|
var finalExpiryRuleID string |
|
|
|
var finalExpiryRuleID string |
|
|
|
|
|
|
|
|
|
|
@ -166,7 +156,7 @@ func (lc Lifecycle) PredictExpiryTime(objName, objTags string) (string, time.Tim |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if !rule.Expiration.IsDaysNull() { |
|
|
|
if !rule.Expiration.IsDaysNull() { |
|
|
|
expectedExpiry := expectedExpiryTime(time.Now(), rule.Expiration.Days) |
|
|
|
expectedExpiry := expectedExpiryTime(modTime, rule.Expiration.Days) |
|
|
|
if finalExpiryDate.IsZero() || finalExpiryDate.After(expectedExpiry) { |
|
|
|
if finalExpiryDate.IsZero() || finalExpiryDate.After(expectedExpiry) { |
|
|
|
finalExpiryRuleID = rule.ID |
|
|
|
finalExpiryRuleID = rule.ID |
|
|
|
finalExpiryDate = expectedExpiry |
|
|
|
finalExpiryDate = expectedExpiry |
|
|
|