pkg/lifecycle: Add SetPredictionHeaders method (#12755)

This method is used to add expected expiration and transition time 
for an object in GET/HEAD Object response headers.

Also fixed bugs in lifecycle.PredictTransitionTime and
getLifecycleTransitionTier in handling current and 
non-current versions.
This commit is contained in:
Krishnan Parthasarathi
2021-07-20 17:36:55 -07:00
committed by GitHub
parent 6ea083d197
commit d0963974a5
8 changed files with 204 additions and 59 deletions

View File

@@ -19,6 +19,7 @@ package lifecycle
import (
"encoding/xml"
"time"
)
// NoncurrentVersionExpiration - an action for lifecycle configuration rule.
@@ -112,3 +113,14 @@ func (n NoncurrentVersionTransition) Validate() error {
}
return nil
}
// NextDue returns upcoming NoncurrentVersionTransition date for obj if
// applicable, returns false otherwise.
func (n NoncurrentVersionTransition) NextDue(obj ObjectOpts) (time.Time, bool) {
switch {
case obj.IsLatest, n.IsDaysNull():
return time.Time{}, false
}
return ExpectedExpiryTime(obj.SuccessorModTime, int(n.NoncurrentDays)), true
}