fix: return Range errors after If-Matches (#10045)

closes #7292
This commit is contained in:
Harshavardhana
2020-07-17 13:01:22 -07:00
committed by GitHub
parent d84fc58cac
commit 14b1c9f8e4
15 changed files with 208 additions and 183 deletions

View File

@@ -48,6 +48,19 @@ type FilterRule struct {
Value string `xml:"Value"`
}
func (filter FilterRule) isEmpty() bool {
return filter.Name == "" && filter.Value == ""
}
// MarshalXML implements a custom marshaller to support `omitempty` feature.
func (filter FilterRule) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if filter.isEmpty() {
return nil
}
type filterRuleWrapper FilterRule
return e.EncodeElement(filterRuleWrapper(filter), start)
}
// UnmarshalXML - decodes XML data.
func (filter *FilterRule) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// Make subtype to avoid recursive UnmarshalXML().
@@ -102,6 +115,10 @@ func (ruleList *FilterRuleList) UnmarshalXML(d *xml.Decoder, start xml.StartElem
return nil
}
func (ruleList FilterRuleList) isEmpty() bool {
return len(ruleList.Rules) == 0
}
// Pattern - returns pattern using prefix and suffix values.
func (ruleList FilterRuleList) Pattern() string {
var prefix string
@@ -124,6 +141,15 @@ type S3Key struct {
RuleList FilterRuleList `xml:"S3Key,omitempty" json:"S3Key,omitempty"`
}
// MarshalXML implements a custom marshaller to support `omitempty` feature.
func (s3Key S3Key) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if s3Key.RuleList.isEmpty() {
return nil
}
type s3KeyWrapper S3Key
return e.EncodeElement(s3KeyWrapper(s3Key), start)
}
// common - represents common elements inside <QueueConfiguration>, <CloudFunctionConfiguration>
// and <TopicConfiguration>
type common struct {