mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Replicate Expiry ILM configs while site replication (#18130)
Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
@@ -97,8 +97,9 @@ func (a Action) Delete() bool {
|
||||
|
||||
// Lifecycle - Configuration for bucket lifecycle.
|
||||
type Lifecycle struct {
|
||||
XMLName xml.Name `xml:"LifecycleConfiguration"`
|
||||
Rules []Rule `xml:"Rule"`
|
||||
XMLName xml.Name `xml:"LifecycleConfiguration"`
|
||||
Rules []Rule `xml:"Rule"`
|
||||
ExpiryUpdatedAt *time.Time `xml:"ExpiryUpdatedAt,omitempty"`
|
||||
}
|
||||
|
||||
// HasTransition returns 'true' if lifecycle document has Transition enabled.
|
||||
@@ -111,6 +112,16 @@ func (lc Lifecycle) HasTransition() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// HasExpiry returns 'true' if lifecycle document has Expiry enabled.
|
||||
func (lc Lifecycle) HasExpiry() bool {
|
||||
for _, rule := range lc.Rules {
|
||||
if !rule.Expiration.IsNull() || !rule.NoncurrentVersionExpiration.IsNull() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// UnmarshalXML - decodes XML data.
|
||||
func (lc *Lifecycle) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error) {
|
||||
switch start.Name.Local {
|
||||
@@ -137,6 +148,12 @@ func (lc *Lifecycle) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err e
|
||||
return err
|
||||
}
|
||||
lc.Rules = append(lc.Rules, r)
|
||||
case "ExpiryUpdatedAt":
|
||||
var t time.Time
|
||||
if err = d.DecodeElement(&t, &start); err != nil {
|
||||
return err
|
||||
}
|
||||
lc.ExpiryUpdatedAt = &t
|
||||
default:
|
||||
return xml.UnmarshalError(fmt.Sprintf("expected element type <Rule> but have <%s>", se.Name.Local))
|
||||
}
|
||||
|
||||
@@ -163,3 +163,16 @@ func (r Rule) Validate() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CloneNonTransition - returns a clone of the object containing non transition rules
|
||||
func (r Rule) CloneNonTransition() Rule {
|
||||
return Rule{
|
||||
XMLName: r.XMLName,
|
||||
ID: r.ID,
|
||||
Status: r.Status,
|
||||
Filter: r.Filter,
|
||||
Prefix: r.Prefix,
|
||||
Expiration: r.Expiration,
|
||||
NoncurrentVersionExpiration: r.NoncurrentVersionExpiration,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user