Skip to content

Swift V1: Cannot delete ACL rules #2215

@kayrus

Description

@kayrus

I noticed that it is impossible to delete ACL rules. Swift accepts empty header values for this, e.g.:

curl hsot -H 'X-Container-Read: '

I found at least two problems and I made a local fix:

diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/requests.go b/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/requests.go
index bea0d95..d9670a6 100644
--- a/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/requests.go
+++ b/vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/containers/requests.go
@@ -154,18 +154,18 @@ type UpdateOptsBuilder interface {
 type UpdateOpts struct {
        Metadata               map[string]string
        RemoveMetadata         []string
-       ContainerRead          string `h:"X-Container-Read"`
-       ContainerSyncTo        string `h:"X-Container-Sync-To"`
-       ContainerSyncKey       string `h:"X-Container-Sync-Key"`
-       ContainerWrite         string `h:"X-Container-Write"`
-       ContentType            string `h:"Content-Type"`
-       DetectContentType      bool   `h:"X-Detect-Content-Type"`
-       RemoveVersionsLocation string `h:"X-Remove-Versions-Location"`
-       VersionsLocation       string `h:"X-Versions-Location"`
-       RemoveHistoryLocation  string `h:"X-Remove-History-Location"`
-       HistoryLocation        string `h:"X-History-Location"`
-       TempURLKey             string `h:"X-Container-Meta-Temp-URL-Key"`
-       TempURLKey2            string `h:"X-Container-Meta-Temp-URL-Key-2"`
+       ContainerRead          *string `h:"X-Container-Read"`
+       ContainerSyncTo        *string `h:"X-Container-Sync-To"`
+       ContainerSyncKey       *string `h:"X-Container-Sync-Key"`
+       ContainerWrite         *string `h:"X-Container-Write"`
+       ContentType            string  `h:"Content-Type"`
+       DetectContentType      bool    `h:"X-Detect-Content-Type"`
+       RemoveVersionsLocation string  `h:"X-Remove-Versions-Location"`
+       VersionsLocation       string  `h:"X-Versions-Location"`
+       RemoveHistoryLocation  string  `h:"X-Remove-History-Location"`
+       HistoryLocation        string  `h:"X-History-Location"`
+       TempURLKey             string  `h:"X-Container-Meta-Temp-URL-Key"`
+       TempURLKey2            string  `h:"X-Container-Meta-Temp-URL-Key-2"`
 }
 
 // ToContainerUpdateMap formats a UpdateOpts into a map of headers.
diff --git a/vendor/github.com/gophercloud/gophercloud/params.go b/vendor/github.com/gophercloud/gophercloud/params.go
index 219c020..6282894 100644
--- a/vendor/github.com/gophercloud/gophercloud/params.go
+++ b/vendor/github.com/gophercloud/gophercloud/params.go
@@ -445,6 +445,9 @@ func BuildHeaders(opts interface{}) (map[string]string, error) {
 
                                // if the field is set, add it to the slice of query pieces
                                if !isZero(v) {
+                                       if v.Kind() == reflect.Ptr {
+                                               v = v.Elem()
+                                       }
                                        switch v.Kind() {
                                        case reflect.String:
                                                optsMap[tags[0]] = v.String()
diff --git a/vendor/github.com/gophercloud/gophercloud/provider_client.go b/vendor/github.com/gophercloud/gophercloud/provider_client.go
index 916e59a..faa421f 100644
--- a/vendor/github.com/gophercloud/gophercloud/provider_client.go
+++ b/vendor/github.com/gophercloud/gophercloud/provider_client.go
@@ -408,11 +408,7 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts
 
        if options.MoreHeaders != nil {
                for k, v := range options.MoreHeaders {
-                       if v != "" {
-                               req.Header.Set(k, v)
-                       } else {
-                               req.Header.Del(k)
-                       }
+                       req.Header.Set(k, v)
                }
        }
 

@jtopjian I don't know which consequences may it cause. Your feedback is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions