mirror of
https://github.com/minio/minio.git
synced 2025-11-22 10:37:42 -05:00
lifecycle: Support old BucketLifecycleConfiguration tag (#11828)
Some old AWS SDKs send BucketLifecycleConfiguration as the root tag in the bucket lifecycle document. This PR will support both LifecycleConfiguration and BucketLifecycleConfiguration.
This commit is contained in:
@@ -66,6 +66,40 @@ type Lifecycle struct {
|
||||
Rules []Rule `xml:"Rule"`
|
||||
}
|
||||
|
||||
// UnmarshalXML - decodes XML data.
|
||||
func (lc *Lifecycle) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error) {
|
||||
switch start.Name.Local {
|
||||
case "LifecycleConfiguration", "BucketLifecycleConfiguration":
|
||||
default:
|
||||
return errUnknownXMLTag
|
||||
}
|
||||
for {
|
||||
// Read tokens from the XML document in a stream.
|
||||
t, err := d.Token()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
switch se := t.(type) {
|
||||
case xml.StartElement:
|
||||
switch se.Name.Local {
|
||||
case "Rule":
|
||||
var r Rule
|
||||
if err = d.DecodeElement(&r, &se); err != nil {
|
||||
return err
|
||||
}
|
||||
lc.Rules = append(lc.Rules, r)
|
||||
default:
|
||||
return errUnknownXMLTag
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// HasActiveRules - returns whether policy has active rules for.
|
||||
// Optionally a prefix can be supplied.
|
||||
// If recursive is specified the function will also return true if any level below the
|
||||
|
||||
Reference in New Issue
Block a user