From 8b1054cbdb0a0b6c85c439c813223eb587ccf544 Mon Sep 17 00:00:00 2001 From: adfost Date: Fri, 4 Nov 2022 11:31:27 -0700 Subject: [PATCH] Handling newerNoncurrentVersions Expiry and Transition in validation (#4348) --- cmd/ilm/parse.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/ilm/parse.go b/cmd/ilm/parse.go index d97296a1..9e89b671 100644 --- a/cmd/ilm/parse.go +++ b/cmd/ilm/parse.go @@ -81,8 +81,10 @@ func validateRuleAction(rule lifecycle.Rule) error { expirySet := !rule.Expiration.IsNull() transitionSet := !rule.Transition.IsNull() noncurrentExpirySet := !rule.NoncurrentVersionExpiration.IsDaysNull() + newerNoncurrentVersionsExpiry := rule.NoncurrentVersionExpiration.NewerNoncurrentVersions > 0 noncurrentTransitionSet := rule.NoncurrentVersionTransition.StorageClass != "" - if !expirySet && !transitionSet && !noncurrentExpirySet && !noncurrentTransitionSet { + newerNoncurrentVersionsTransition := rule.NoncurrentVersionTransition.NewerNoncurrentVersions > 0 + if !expirySet && !transitionSet && !noncurrentExpirySet && !noncurrentTransitionSet && !newerNoncurrentVersionsExpiry && !newerNoncurrentVersionsTransition { return errors.New("at least one of Expiry, Transition, NoncurrentExpiry, NoncurrentVersionTransition actions should be specified in a rule") } return nil