unmarshal both LegalHold and ObjectLockLegalHold XML types (#11921)

Because of silly AWS S3 behavior we to handle both types.

fixes #11920
This commit is contained in:
Harshavardhana
2021-03-29 23:52:30 -07:00
committed by GitHub
parent 2623338dc5
commit b8ec365397
3 changed files with 57 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ package lifecycle
import (
"encoding/xml"
"fmt"
"io"
"strings"
"time"
@@ -71,7 +72,8 @@ func (lc *Lifecycle) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err e
switch start.Name.Local {
case "LifecycleConfiguration", "BucketLifecycleConfiguration":
default:
return errUnknownXMLTag
return xml.UnmarshalError(fmt.Sprintf("expected element type <LifecycleConfiguration>/<BucketLifecycleConfiguration> but have <%s>",
start.Name.Local))
}
for {
// Read tokens from the XML document in a stream.
@@ -93,7 +95,7 @@ func (lc *Lifecycle) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err e
}
lc.Rules = append(lc.Rules, r)
default:
return errUnknownXMLTag
return xml.UnmarshalError(fmt.Sprintf("expected element type <Rule> but have <%s>", se.Name.Local))
}
}
}