Skip to content

Commit

Permalink
Remove XMLName field for CompleteMultipartUpload (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Mar 3, 2025
2 parents 879cbd5 + c1ff1f0 commit 04b2c71
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion api/data/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ type (

// CORSConfiguration stores CORS configuration of a request.
CORSConfiguration struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CORSConfiguration" json:"-"`
XMLName xml.Name `xml:"CORSConfiguration" json:"-"`
CORSRules []CORSRule `xml:"CORSRule" json:"CORSRules"`
}

Expand Down
6 changes: 3 additions & 3 deletions api/data/locking.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type (
ObjectLockConfiguration struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ObjectLockConfiguration" json:"-"`
XMLName xml.Name `xml:"ObjectLockConfiguration" json:"-"`
ObjectLockEnabled string `xml:"ObjectLockEnabled" json:"ObjectLockEnabled"`
Rule *ObjectLockRule `xml:"Rule" json:"Rule"`
}
Expand All @@ -23,12 +23,12 @@ type (
}

LegalHold struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ LegalHold" json:"-"`
XMLName xml.Name `xml:"LegalHold" json:"-"`
Status string `xml:"Status" json:"Status"`
}

Retention struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ Retention" json:"-"`
XMLName xml.Name `xml:"Retention" json:"-"`
Mode string `xml:"Mode" json:"Mode"`
RetainUntilDate string `xml:"RetainUntilDate" json:"RetainUntilDate"`
}
Expand Down
6 changes: 3 additions & 3 deletions api/handler/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1525,12 +1525,12 @@ func permissionToOperations(permission amazonS3Permission) []eacl.Operation {
return nil
}

func encodeObjectACL(log *zap.Logger, bucketACL *layer.BucketACL, bucketName, objectVersion string) *AccessControlPolicy {
func encodeObjectACL(log *zap.Logger, bucketACL *layer.BucketACL, bucketName, objectVersion string) *AccessControlPolicyResponse {
ownerGrantee := NewGrantee(granteeCanonicalUser)
ownerGrantee.ID = bucketACL.Info.Owner.String()
ownerGrantee.DisplayName = bucketACL.Info.Owner.String()

res := &AccessControlPolicy{
res := &AccessControlPolicyResponse{
Owner: Owner{
ID: bucketACL.Info.Owner.String(),
DisplayName: bucketACL.Info.Owner.String(),
Expand Down Expand Up @@ -1631,7 +1631,7 @@ func generateGrant(key string, bucketACL *layer.BucketACL, permission amazonS3Pe
}
}

func (h *handler) encodeBucketACL(bucketName string, bucketACL *layer.BucketACL) *AccessControlPolicy {
func (h *handler) encodeBucketACL(bucketName string, bucketACL *layer.BucketACL) *AccessControlPolicyResponse {
return encodeObjectACL(h.log, bucketACL, bucketName, "")
}

Expand Down
2 changes: 1 addition & 1 deletion api/handler/multipart_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type (
}

CompleteMultipartUpload struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CompleteMultipartUpload"`
XMLName xml.Name `xml:"CompleteMultipartUpload"`
Parts []*layer.CompletedPart `xml:"Part"`
}

Expand Down
2 changes: 1 addition & 1 deletion api/handler/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type (
}

NotificationConfiguration struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ NotificationConfiguation"`
XMLName xml.Name `xml:"NotificationConfiguation"`
NotificationConfiguration data.NotificationConfiguration
}
)
Expand Down
2 changes: 1 addition & 1 deletion api/handler/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const (
)

type createBucketParams struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CreateBucketConfiguration" json:"-"`
XMLName xml.Name `xml:"CreateBucketConfiguration" json:"-"`
LocationConstraint string
}

Expand Down
11 changes: 9 additions & 2 deletions api/handler/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ type Bucket struct {

// AccessControlPolicy contains ACL.
type AccessControlPolicy struct {
XMLName xml.Name `xml:"AccessControlPolicy" json:"-"`
Owner Owner
AccessControlList []*Grant `xml:"AccessControlList>Grant"`
}

// AccessControlPolicyResponse is used for gate response and contains xmlns definition.
type AccessControlPolicyResponse struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ AccessControlPolicy" json:"-"`
Owner Owner
AccessControlList []*Grant `xml:"AccessControlList>Grant"`
Expand Down Expand Up @@ -251,14 +258,14 @@ type ListObjectsVersionsResponse struct {

// VersioningConfiguration contains VersioningConfiguration XML representation.
type VersioningConfiguration struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ VersioningConfiguration"`
XMLName xml.Name `xml:"VersioningConfiguration"`
Status string `xml:"Status,omitempty"`
MfaDelete string `xml:"MfaDelete,omitempty"`
}

// Tagging contains tag set.
type Tagging struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ Tagging"`
XMLName xml.Name `xml:"Tagging"`
TagSet []Tag `xml:"TagSet>Tag"`
}

Expand Down
2 changes: 1 addition & 1 deletion api/handler/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestAccessControlPolicyXML(t *testing.T) {
// https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html
var policyTemplate = `
<?xml version="1.0" encoding="UTF-8"?>
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<AccessControlPolicy>
<Owner>
<ID>%[1]s</ID>
<DisplayName>display-name</DisplayName>
Expand Down

0 comments on commit 04b2c71

Please sign in to comment.