mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Add tags to NewerNoncurrentVersions audit event (#17110)
This commit is contained in:
committed by
GitHub
parent
4640b13c66
commit
0ec722bc54
@@ -287,10 +287,12 @@ func (o ObjectOpts) ExpiredObjectDeleteMarker() bool {
|
||||
|
||||
// Event contains a lifecycle action with associated info
|
||||
type Event struct {
|
||||
Action Action
|
||||
RuleID string
|
||||
Due time.Time
|
||||
StorageClass string
|
||||
Action Action
|
||||
RuleID string
|
||||
Due time.Time
|
||||
NoncurrentDays int
|
||||
NewerNoncurrentVersions int
|
||||
StorageClass string
|
||||
}
|
||||
|
||||
// Eval returns the lifecycle event applicable now.
|
||||
@@ -480,15 +482,17 @@ func (lc Lifecycle) SetPredictionHeaders(w http.ResponseWriter, obj ObjectOpts)
|
||||
|
||||
// NoncurrentVersionsExpirationLimit returns the number of noncurrent versions
|
||||
// to be retained from the first applicable rule per S3 behavior.
|
||||
func (lc Lifecycle) NoncurrentVersionsExpirationLimit(obj ObjectOpts) (string, int, int) {
|
||||
var lim int
|
||||
var days int
|
||||
var ruleID string
|
||||
func (lc Lifecycle) NoncurrentVersionsExpirationLimit(obj ObjectOpts) Event {
|
||||
for _, rule := range lc.FilterRules(obj) {
|
||||
if rule.NoncurrentVersionExpiration.NewerNoncurrentVersions == 0 {
|
||||
continue
|
||||
}
|
||||
return rule.ID, int(rule.NoncurrentVersionExpiration.NoncurrentDays), rule.NoncurrentVersionExpiration.NewerNoncurrentVersions
|
||||
return Event{
|
||||
Action: DeleteVersionAction,
|
||||
RuleID: rule.ID,
|
||||
NoncurrentDays: int(rule.NoncurrentVersionExpiration.NoncurrentDays),
|
||||
NewerNoncurrentVersions: rule.NoncurrentVersionExpiration.NewerNoncurrentVersions,
|
||||
}
|
||||
}
|
||||
return ruleID, days, lim
|
||||
return Event{}
|
||||
}
|
||||
|
||||
@@ -854,8 +854,8 @@ func TestNoncurrentVersionsLimit(t *testing.T) {
|
||||
lc := Lifecycle{
|
||||
Rules: rules,
|
||||
}
|
||||
if ruleID, days, lim := lc.NoncurrentVersionsExpirationLimit(ObjectOpts{Name: "obj"}); ruleID != "1" || days != 1 || lim != 1 {
|
||||
t.Fatalf("Expected (ruleID, days, lim) to be (\"1\", 1, 1) but got (%s, %d, %d)", ruleID, days, lim)
|
||||
if event := lc.NoncurrentVersionsExpirationLimit(ObjectOpts{Name: "obj"}); event.RuleID != "1" || event.NoncurrentDays != 1 || event.NewerNoncurrentVersions != 1 {
|
||||
t.Fatalf("Expected (ruleID, days, lim) to be (\"1\", 1, 1) but got (%s, %d, %d)", event.RuleID, event.NoncurrentDays, event.NewerNoncurrentVersions)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user