From b0f40b4db79db09fdffc9a258fa0a2c8c7189642 Mon Sep 17 00:00:00 2001 From: jinapurapu <65002498+jinapurapu@users.noreply.github.com> Date: Thu, 6 Mar 2025 05:05:05 -0800 Subject: [PATCH] Reject add ILM rule with both day and date parameters (#5155) --- cmd/ilm/parse.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/ilm/parse.go b/cmd/ilm/parse.go index 8bc7832c..4963a7a4 100644 --- a/cmd/ilm/parse.go +++ b/cmd/ilm/parse.go @@ -113,6 +113,13 @@ func validateExpiration(rule lifecycle.Rule) error { return nil } +func validateTransition(rule lifecycle.Rule) error { + if !rule.Transition.IsDaysNull() && !rule.Transition.IsDateNull() { + return errors.New("only one parameter under Transition can be specified") + } + return nil +} + func validateNoncurrentExpiration(rule lifecycle.Rule) error { days := rule.NoncurrentVersionExpiration.NoncurrentDays if days < 0 { @@ -162,6 +169,9 @@ func validateILMRule(rule lifecycle.Rule) *probe.Error { if e := validateExpiration(rule); e != nil { return probe.NewError(e) } + if e := validateTransition(rule); e != nil { + return probe.NewError(e) + } if e := validateTranExpCurdate(rule); e != nil { return probe.NewError(e) } @@ -206,7 +216,8 @@ func parseTransition(storageClass, transitionDateStr, transitionDaysStr *string) return lifecycle.Transition{}, err } transition.Date = transitionDate - } else if transitionDaysStr != nil { + } + if transitionDaysStr != nil { transitionDays, err := parseTransitionDays(*transitionDaysStr) if err != nil { return lifecycle.Transition{}, err