Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

[wip] add DeleteMetadata field for deleting container metadata #456

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions openstack/objectstorage/v1/accounts/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type UpdateOptsBuilder interface {
// deleting an account's metadata.
type UpdateOpts struct {
Metadata map[string]string
DeleteMetadata []string
ContentType string `h:"Content-Type"`
DetectContentType bool `h:"X-Detect-Content-Type"`
TempURLKey string `h:"X-Account-Meta-Temp-URL-Key"`
Expand All @@ -75,6 +76,9 @@ func (opts UpdateOpts) ToAccountUpdateMap() (map[string]string, error) {
for k, v := range opts.Metadata {
headers["X-Account-Meta-"+k] = v
}
for _, k := range opts.DeleteMetadata {
headers["X-Remove-Account-Meta-"+k] = "true"
}
return headers, err
}

Expand Down
10 changes: 8 additions & 2 deletions openstack/objectstorage/v1/containers/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func Create(c *gophercloud.ServiceClient, containerName string, opts CreateOptsB
// Delete is a function that deletes a container.
func Delete(c *gophercloud.ServiceClient, containerName string) DeleteResult {
var res DeleteResult
_, res.Err = c.Delete(deleteURL(c, containerName), nil)
_, res.Err = c.Delete(deleteURL(c, containerName), &gophercloud.RequestOpts{})
return res
}

Expand All @@ -137,7 +137,10 @@ type UpdateOptsBuilder interface {
// UpdateOpts is a structure that holds parameters for updating, creating, or
// deleting a container's metadata.
type UpdateOpts struct {
Metadata map[string]string
// a map of key-value pairs to add/update for the container.
Metadata map[string]string
// a slice a keys of the metadata to delete from the container.
DeleteMetadata []string
ContainerRead string `h:"X-Container-Read"`
ContainerSyncTo string `h:"X-Container-Sync-To"`
ContainerSyncKey string `h:"X-Container-Sync-Key"`
Expand All @@ -157,6 +160,9 @@ func (opts UpdateOpts) ToContainerUpdateMap() (map[string]string, error) {
for k, v := range opts.Metadata {
h["X-Container-Meta-"+k] = v
}
for _, k := range opts.DeleteMetadata {
h["X-Remove-Container-Meta-"+k] = "true"
}
return h, nil
}

Expand Down
10 changes: 7 additions & 3 deletions rackspace/objectstorage/v1/accounts/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ func Get(c *gophercloud.ServiceClient) os.GetResult {
// UpdateOpts is a structure that contains parameters for updating, creating, or
// deleting an account's metadata.
type UpdateOpts struct {
Metadata map[string]string
TempURLKey string `h:"X-Account-Meta-Temp-URL-Key"`
TempURLKey2 string `h:"X-Account-Meta-Temp-URL-Key-2"`
Metadata map[string]string
DeleteMetadata []string
TempURLKey string `h:"X-Account-Meta-Temp-URL-Key"`
TempURLKey2 string `h:"X-Account-Meta-Temp-URL-Key-2"`
}

// ToAccountUpdateMap formats an UpdateOpts into a map[string]string of headers.
Expand All @@ -30,6 +31,9 @@ func (opts UpdateOpts) ToAccountUpdateMap() (map[string]string, error) {
for k, v := range opts.Metadata {
headers["X-Account-Meta-"+k] = v
}
for _, k := range opts.DeleteMetadata {
headers["X-Remove-Account-Meta-"+k] = "true"
}
return headers, err
}

Expand Down
8 changes: 7 additions & 1 deletion rackspace/objectstorage/v1/containers/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ func Delete(c *gophercloud.ServiceClient, containerName string) os.DeleteResult
// UpdateOpts is a structure that holds parameters for updating or creating a
// container's metadata.
type UpdateOpts struct {
Metadata map[string]string
// a map of key-value pairs to add/update for the container.
Metadata map[string]string
// a slice a keys of the metadata to delete from the container.
DeleteMetadata []string
ContainerRead string `h:"X-Container-Read"`
ContainerWrite string `h:"X-Container-Write"`
ContentType string `h:"Content-Type"`
Expand All @@ -76,6 +79,9 @@ func (opts UpdateOpts) ToContainerUpdateMap() (map[string]string, error) {
for k, v := range opts.Metadata {
h["X-Container-Meta-"+k] = v
}
for _, k := range opts.DeleteMetadata {
h["X-Remove-Container-Meta-"+k] = "true"
}
return h, nil
}

Expand Down