no naked returns in go; fix auth v3 unit tests
diff --git a/openstack/auth_env.go b/openstack/auth_env.go
index 2309783..f6d2eb1 100644
--- a/openstack/auth_env.go
+++ b/openstack/auth_env.go
@@ -23,23 +23,17 @@
domainName := os.Getenv("OS_DOMAIN_NAME")
if authURL == "" {
- err := &ErrNoAuthURL{}
- err.Function = "openstack.AuthOptionsFromEnv"
- err.Argument = "authURL"
+ err := gophercloud.ErrMissingInput{Argument: "authURL"}
return nilOptions, err
}
if username == "" && userID == "" {
- err := &ErrNoUsername{}
- err.Function = "openstack.AuthOptionsFromEnv"
- err.Argument = "username"
+ err := gophercloud.ErrMissingInput{Argument: "username"}
return nilOptions, err
}
if password == "" {
- err := &ErrNoPassword{}
- err.Function = "openstack.AuthOptionsFromEnv"
- err.Argument = "password"
+ err := gophercloud.ErrMissingInput{Argument: "password"}
return nilOptions, err
}
diff --git a/openstack/blockstorage/v1/apiversions/requests.go b/openstack/blockstorage/v1/apiversions/requests.go
index 5d83e4e..725c13a 100644
--- a/openstack/blockstorage/v1/apiversions/requests.go
+++ b/openstack/blockstorage/v1/apiversions/requests.go
@@ -16,4 +16,5 @@
// type from the result, call the Extract method on the GetResult.
func Get(client *gophercloud.ServiceClient, v string) (r GetResult) {
_, r.Err = client.Get(getURL(client, v), &r.Body, nil)
+ return
}
diff --git a/openstack/blockstorage/v1/snapshots/requests.go b/openstack/blockstorage/v1/snapshots/requests.go
index 5c05f9b..cb9d0d0 100644
--- a/openstack/blockstorage/v1/snapshots/requests.go
+++ b/openstack/blockstorage/v1/snapshots/requests.go
@@ -40,17 +40,20 @@
_, r.Err = client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 201},
})
+ return
}
// Delete will delete the existing Snapshot with the provided ID.
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = client.Delete(deleteURL(client, id), nil)
+ return
}
// Get retrieves the Snapshot with the provided ID. To extract the Snapshot
// object from the response, call the Extract method on the GetResult.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
+ return
}
// ListOptsBuilder allows extensions to add additional parameters to the List
@@ -120,6 +123,7 @@
_, r.Err = client.Put(updateMetadataURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// IDFromName is a convienience function that returns a snapshot's ID given its name.
diff --git a/openstack/blockstorage/v1/volumes/requests.go b/openstack/blockstorage/v1/volumes/requests.go
index b9fc456..9850cfa 100644
--- a/openstack/blockstorage/v1/volumes/requests.go
+++ b/openstack/blockstorage/v1/volumes/requests.go
@@ -44,17 +44,20 @@
_, r.Err = client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 201},
})
+ return
}
// Delete will delete the existing Volume with the provided ID.
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = client.Delete(deleteURL(client, id), nil)
+ return
}
// Get retrieves the Volume with the provided ID. To extract the Volume object
// from the response, call the Extract method on the GetResult.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
+ return
}
// ListOptsBuilder allows extensions to add additional parameters to the List
@@ -129,6 +132,7 @@
_, r.Err = client.Put(updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// IDFromName is a convienience function that returns a server's ID given its name.
diff --git a/openstack/blockstorage/v1/volumetypes/requests.go b/openstack/blockstorage/v1/volumetypes/requests.go
index 8c7dd46..b95c09a 100644
--- a/openstack/blockstorage/v1/volumetypes/requests.go
+++ b/openstack/blockstorage/v1/volumetypes/requests.go
@@ -35,17 +35,20 @@
_, r.Err = client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 201},
})
+ return
}
// Delete will delete the volume type with the provided ID.
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = client.Delete(deleteURL(client, id), nil)
+ return
}
// Get will retrieve the volume type with the provided ID. To extract the volume
// type from the result, call the Extract method on the GetResult.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
+ return
}
// List returns all volume types.
diff --git a/openstack/cdn/v1/base/requests.go b/openstack/cdn/v1/base/requests.go
index 99e7309..34d3b72 100644
--- a/openstack/cdn/v1/base/requests.go
+++ b/openstack/cdn/v1/base/requests.go
@@ -6,6 +6,7 @@
// entire API.
func Get(c *gophercloud.ServiceClient) (r GetResult) {
_, r.Err = c.Get(getURL(c), &r.Body, nil)
+ return
}
// Ping retrieves a ping to the server.
@@ -14,4 +15,5 @@
OkCodes: []int{204},
MoreHeaders: map[string]string{"Accept": ""},
})
+ return
}
diff --git a/openstack/cdn/v1/flavors/requests.go b/openstack/cdn/v1/flavors/requests.go
index fc05528..1977fe3 100644
--- a/openstack/cdn/v1/flavors/requests.go
+++ b/openstack/cdn/v1/flavors/requests.go
@@ -15,4 +15,5 @@
// Get retrieves a specific flavor based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(getURL(c, id), &r.Body, nil)
+ return
}
diff --git a/openstack/cdn/v1/serviceassets/requests.go b/openstack/cdn/v1/serviceassets/requests.go
index e78508d..80c908f 100644
--- a/openstack/cdn/v1/serviceassets/requests.go
+++ b/openstack/cdn/v1/serviceassets/requests.go
@@ -47,4 +47,5 @@
url += q
}
_, r.Err = c.Delete(url, nil)
+ return
}
diff --git a/openstack/cdn/v1/services/requests.go b/openstack/cdn/v1/services/requests.go
index c0329d6..4c0c626 100644
--- a/openstack/cdn/v1/services/requests.go
+++ b/openstack/cdn/v1/services/requests.go
@@ -91,6 +91,7 @@
resp, err := c.Post(createURL(c), &b, nil, nil)
r.Header = resp.Header
r.Err = err
+ return
}
// Get retrieves a specific service based on its URL or its unique ID. For
@@ -105,6 +106,7 @@
url = getURL(c, idOrURL)
}
_, r.Err = c.Get(url, &r.Body, nil)
+ return
}
// Path is a JSON pointer location that indicates which service parameter is being added, replaced,
@@ -264,6 +266,7 @@
})
r.Header = resp.Header
r.Err = err
+ return
}
// Delete accepts a service's ID or its URL and deletes the CDN service
@@ -278,4 +281,5 @@
url = deleteURL(c, idOrURL)
}
_, r.Err = c.Delete(url, nil)
+ return
}
diff --git a/openstack/client.go b/openstack/client.go
index 62e3f82..9858efb 100644
--- a/openstack/client.go
+++ b/openstack/client.go
@@ -159,7 +159,20 @@
}
}
- result := tokens3.Create(v3Client, options, scope)
+ v3Opts := tokens3.AuthOptions{
+ IdentityEndpoint: options.IdentityEndpoint,
+ Username: options.Username,
+ UserID: options.UserID,
+ Password: options.Password,
+ DomainID: options.DomainID,
+ DomainName: options.DomainName,
+ TenantID: options.TenantID,
+ TenantName: options.TenantName,
+ AllowReauth: options.AllowReauth,
+ TokenID: options.TokenID,
+ }
+
+ result := tokens3.Create(v3Client, v3Opts, scope)
token, err := result.ExtractToken()
if err != nil {
diff --git a/openstack/common/extensions/requests.go b/openstack/common/extensions/requests.go
index bc1ce3e..46b7d60 100755
--- a/openstack/common/extensions/requests.go
+++ b/openstack/common/extensions/requests.go
@@ -8,6 +8,7 @@
// Get retrieves information for a specific extension using its alias.
func Get(c *gophercloud.ServiceClient, alias string) (r GetResult) {
_, r.Err = c.Get(ExtensionURL(c, alias), &r.Body, nil)
+ return
}
// List returns a Pager which allows you to iterate over the full collection of extensions.
diff --git a/openstack/compute/v2/extensions/bootfromvolume/requests.go b/openstack/compute/v2/extensions/bootfromvolume/requests.go
index f99da40..28fef94 100644
--- a/openstack/compute/v2/extensions/bootfromvolume/requests.go
+++ b/openstack/compute/v2/extensions/bootfromvolume/requests.go
@@ -88,4 +88,5 @@
_, r.Err = client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 202},
})
+ return
}
diff --git a/openstack/compute/v2/extensions/defsecrules/requests.go b/openstack/compute/v2/extensions/defsecrules/requests.go
index f01631d..6f24bb3 100644
--- a/openstack/compute/v2/extensions/defsecrules/requests.go
+++ b/openstack/compute/v2/extensions/defsecrules/requests.go
@@ -46,14 +46,17 @@
_, r.Err = client.Post(rootURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Get will return details for a particular default rule.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(resourceURL(client, id), &r.Body, nil)
+ return
}
// Delete will permanently delete a default rule from the project.
func Delete(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) {
_, r.Err = client.Delete(resourceURL(client, id), nil)
+ return
}
diff --git a/openstack/compute/v2/extensions/floatingips/requests.go b/openstack/compute/v2/extensions/floatingips/requests.go
index 2f5cd79..b36aeba 100644
--- a/openstack/compute/v2/extensions/floatingips/requests.go
+++ b/openstack/compute/v2/extensions/floatingips/requests.go
@@ -39,16 +39,19 @@
_, r.Err = client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Get returns data about a previously created FloatingIP.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
+ return
}
// Delete requests the deletion of a previous allocated FloatingIP.
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = client.Delete(deleteURL(client, id), nil)
+ return
}
// AssociateOptsBuilder is the interface types must satfisfy to be used as
@@ -78,6 +81,7 @@
return
}
_, r.Err = client.Post(associateURL(client, serverID), b, nil, nil)
+ return
}
// DisassociateOptsBuilder is the interface types must satfisfy to be used as
@@ -104,4 +108,5 @@
return
}
_, r.Err = client.Post(disassociateURL(client, serverID), b, nil, nil)
+ return
}
diff --git a/openstack/compute/v2/extensions/keypairs/requests.go b/openstack/compute/v2/extensions/keypairs/requests.go
index c4d63ce..adf1e55 100644
--- a/openstack/compute/v2/extensions/keypairs/requests.go
+++ b/openstack/compute/v2/extensions/keypairs/requests.go
@@ -68,14 +68,17 @@
_, r.Err = client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Get returns public data about a previously uploaded KeyPair.
func Get(client *gophercloud.ServiceClient, name string) (r GetResult) {
_, r.Err = client.Get(getURL(client, name), &r.Body, nil)
+ return
}
// Delete requests the deletion of a previous stored KeyPair from the server.
func Delete(client *gophercloud.ServiceClient, name string) (r DeleteResult) {
_, r.Err = client.Delete(deleteURL(client, name), nil)
+ return
}
diff --git a/openstack/compute/v2/extensions/networks/requests.go b/openstack/compute/v2/extensions/networks/requests.go
index 4f66ff9..5432a10 100644
--- a/openstack/compute/v2/extensions/networks/requests.go
+++ b/openstack/compute/v2/extensions/networks/requests.go
@@ -15,4 +15,5 @@
// Get returns data about a previously created Network.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
+ return
}
diff --git a/openstack/compute/v2/extensions/secgroups/requests.go b/openstack/compute/v2/extensions/secgroups/requests.go
index cfb2df8..81993bd 100644
--- a/openstack/compute/v2/extensions/secgroups/requests.go
+++ b/openstack/compute/v2/extensions/secgroups/requests.go
@@ -56,6 +56,7 @@
_, r.Err = client.Post(rootURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// UpdateOpts is the struct responsible for updating an existing security group.
@@ -82,16 +83,19 @@
_, r.Err = client.Put(resourceURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Get will return details for a particular security group.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(resourceURL(client, id), &r.Body, nil)
+ return
}
// Delete will permanently delete a security group from the project.
func Delete(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) {
_, r.Err = client.Delete(resourceURL(client, id), nil)
+ return
}
// CreateRuleOpts represents the configuration for adding a new rule to an
@@ -138,11 +142,13 @@
_, r.Err = client.Post(rootRuleURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// DeleteRule will permanently delete a rule from a security group.
func DeleteRule(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) {
_, r.Err = client.Delete(resourceRuleURL(client, id), nil)
+ return
}
func actionMap(prefix, groupName string) map[string]map[string]string {
@@ -155,9 +161,11 @@
// rules of the group on the server.
func AddServer(client *gophercloud.ServiceClient, serverID, groupName string) (r gophercloud.ErrResult) {
_, r.Err = client.Post(serverActionURL(client, serverID), actionMap("add", groupName), &r.Body, nil)
+ return
}
// RemoveServer will disassociate a server from a security group.
func RemoveServer(client *gophercloud.ServiceClient, serverID, groupName string) (r gophercloud.ErrResult) {
_, r.Err = client.Post(serverActionURL(client, serverID), actionMap("remove", groupName), &r.Body, nil)
+ return
}
diff --git a/openstack/compute/v2/extensions/servergroups/requests.go b/openstack/compute/v2/extensions/servergroups/requests.go
index c5d5f95..ee98837 100644
--- a/openstack/compute/v2/extensions/servergroups/requests.go
+++ b/openstack/compute/v2/extensions/servergroups/requests.go
@@ -41,14 +41,17 @@
_, r.Err = client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Get returns data about a previously created ServerGroup.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
+ return
}
// Delete requests the deletion of a previously allocated ServerGroup.
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = client.Delete(deleteURL(client, id), nil)
+ return
}
diff --git a/openstack/compute/v2/extensions/startstop/requests.go b/openstack/compute/v2/extensions/startstop/requests.go
index 27076b7..1d8a593 100644
--- a/openstack/compute/v2/extensions/startstop/requests.go
+++ b/openstack/compute/v2/extensions/startstop/requests.go
@@ -9,9 +9,11 @@
// Start is the operation responsible for starting a Compute server.
func Start(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) {
_, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-start": nil}, nil, nil)
+ return
}
// Stop is the operation responsible for stopping a Compute server.
func Stop(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) {
_, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-stop": nil}, nil, nil)
+ return
}
diff --git a/openstack/compute/v2/extensions/tenantnetworks/requests.go b/openstack/compute/v2/extensions/tenantnetworks/requests.go
index 2df856f..82836d4 100644
--- a/openstack/compute/v2/extensions/tenantnetworks/requests.go
+++ b/openstack/compute/v2/extensions/tenantnetworks/requests.go
@@ -15,4 +15,5 @@
// Get returns data about a previously created Network.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
+ return
}
diff --git a/openstack/compute/v2/extensions/volumeattach/requests.go b/openstack/compute/v2/extensions/volumeattach/requests.go
index d6c8ddc..ee4d62d 100644
--- a/openstack/compute/v2/extensions/volumeattach/requests.go
+++ b/openstack/compute/v2/extensions/volumeattach/requests.go
@@ -41,14 +41,17 @@
_, r.Err = client.Post(createURL(client, serverID), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Get returns public data about a previously created VolumeAttachment.
func Get(client *gophercloud.ServiceClient, serverID, attachmentID string) (r GetResult) {
_, r.Err = client.Get(getURL(client, serverID, attachmentID), &r.Body, nil)
+ return
}
// Delete requests the deletion of a previous stored VolumeAttachment from the server.
func Delete(client *gophercloud.ServiceClient, serverID, attachmentID string) (r DeleteResult) {
_, r.Err = client.Delete(deleteURL(client, serverID, attachmentID), nil)
+ return
}
diff --git a/openstack/compute/v2/flavors/requests.go b/openstack/compute/v2/flavors/requests.go
index 4b2d3d0..ef133ff 100644
--- a/openstack/compute/v2/flavors/requests.go
+++ b/openstack/compute/v2/flavors/requests.go
@@ -58,6 +58,7 @@
// Use ExtractFlavor to convert its result into a Flavor.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
+ return
}
// IDFromName is a convienience function that returns a flavor's ID given its name.
diff --git a/openstack/compute/v2/images/requests.go b/openstack/compute/v2/images/requests.go
index 9b2b985..df9f1da 100644
--- a/openstack/compute/v2/images/requests.go
+++ b/openstack/compute/v2/images/requests.go
@@ -54,11 +54,13 @@
// Use ExtractImage() to interpret the result as an openstack Image.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
+ return
}
// Delete deletes the specified image ID.
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = client.Delete(deleteURL(client, id), nil)
+ return
}
// IDFromName is a convienience function that returns an image's ID given its name.
diff --git a/openstack/compute/v2/servers/requests.go b/openstack/compute/v2/servers/requests.go
index ba30a79..27ab764 100644
--- a/openstack/compute/v2/servers/requests.go
+++ b/openstack/compute/v2/servers/requests.go
@@ -266,16 +266,19 @@
return
}
_, r.Err = client.Post(listURL(client), reqBody, &r.Body, nil)
+ return
}
// Delete requests that a server previously provisioned be removed from your account.
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = client.Delete(deleteURL(client, id), nil)
+ return
}
// ForceDelete forces the deletion of a server
func ForceDelete(client *gophercloud.ServiceClient, id string) (r ActionResult) {
_, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"forceDelete": ""}, nil, nil)
+ return
}
// Get requests details on a single server, by ID.
@@ -283,6 +286,7 @@
_, r.Err = client.Get(getURL(client, id), &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 203},
})
+ return
}
// UpdateOptsBuilder allows extensions to add additional attributes to the Update request.
@@ -319,6 +323,7 @@
_, r.Err = client.Put(updateURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// ChangeAdminPassword alters the administrator or root password for a specified server.
@@ -329,6 +334,7 @@
},
}
_, r.Err = client.Post(actionURL(client, id), b, nil, nil)
+ return
}
// RebootMethod describes the mechanisms by which a server reboot can be requested.
@@ -377,6 +383,7 @@
return
}
_, r.Err = client.Post(actionURL(client, id), b, nil, nil)
+ return
}
// RebuildOptsBuilder is an interface that allows extensions to override the
@@ -446,6 +453,7 @@
return
}
_, r.Err = client.Post(actionURL(client, id), b, &r.Body, nil)
+ return
}
// ResizeOptsBuilder is an interface that allows extensions to override the default structure of
@@ -480,6 +488,7 @@
return
}
_, r.Err = client.Post(actionURL(client, id), b, nil, nil)
+ return
}
// ConfirmResize confirms a previous rize operation on a server.
@@ -488,12 +497,14 @@
_, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"confirmResize": nil}, nil, &gophercloud.RequestOpts{
OkCodes: []int{201, 202, 204},
})
+ return
}
// RevertResize cancels a previous rize operation on a server.
// See Resize() for more details.
func RevertResize(client *gophercloud.ServiceClient, id string) (r ActionResult) {
_, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"revertResize": nil}, nil, nil)
+ return
}
// RescueOptsBuilder is an interface that allows extensions to override the
@@ -526,6 +537,7 @@
_, r.Err = client.Post(actionURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// ResetMetadataOptsBuilder allows extensions to add additional parameters to the
@@ -560,11 +572,13 @@
_, r.Err = client.Put(metadataURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Metadata requests all the metadata for the given server ID.
func Metadata(client *gophercloud.ServiceClient, id string) (r GetMetadataResult) {
_, r.Err = client.Get(metadataURL(client, id), &r.Body, nil)
+ return
}
// UpdateMetadataOptsBuilder allows extensions to add additional parameters to the
@@ -585,6 +599,7 @@
_, r.Err = client.Post(metadataURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// MetadatumOptsBuilder allows extensions to add additional parameters to the
@@ -622,16 +637,19 @@
_, r.Err = client.Put(metadatumURL(client, id, key), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Metadatum requests the key-value pair with the given key for the given server ID.
func Metadatum(client *gophercloud.ServiceClient, id, key string) (r GetMetadatumResult) {
_, r.Err = client.Get(metadatumURL(client, id, key), &r.Body, nil)
+ return
}
// DeleteMetadatum will delete the key-value pair with the given key for the given server ID.
func DeleteMetadatum(client *gophercloud.ServiceClient, id, key string) (r DeleteMetadatumResult) {
_, r.Err = client.Delete(metadatumURL(client, id, key), nil)
+ return
}
// ListAddresses makes a request against the API to list the servers IP addresses.
@@ -680,6 +698,7 @@
})
r.Err = err
r.Header = resp.Header
+ return
}
// IDFromName is a convienience function that returns a server's ID given its name.
diff --git a/openstack/db/v1/configurations/requests.go b/openstack/db/v1/configurations/requests.go
index 9e1bf05..8fc8295 100644
--- a/openstack/db/v1/configurations/requests.go
+++ b/openstack/db/v1/configurations/requests.go
@@ -54,11 +54,13 @@
return
}
_, r.Err = client.Post(baseURL(client), &b, &r.Body, &gophercloud.RequestOpts{OkCodes: []int{200}})
+ return
}
// Get will retrieve the details for a specified configuration group.
func Get(client *gophercloud.ServiceClient, configID string) (r GetResult) {
_, r.Err = client.Get(resourceURL(client, configID), &r.Body, nil)
+ return
}
// UpdateOptsBuilder is the top-level interface for casting update options into
@@ -96,6 +98,7 @@
return
}
_, r.Err = client.Patch(resourceURL(client, configID), &b, nil, nil)
+ return
}
// Replace will modify an existing configuration group by overwriting the
@@ -108,6 +111,7 @@
return
}
_, r.Err = client.Put(resourceURL(client, configID), &b, nil, nil)
+ return
}
// Delete will permanently delete a configuration group. Please note that
@@ -115,6 +119,7 @@
// you must detach and then delete them.
func Delete(client *gophercloud.ServiceClient, configID string) (r DeleteResult) {
_, r.Err = client.Delete(resourceURL(client, configID), nil)
+ return
}
// ListInstances will list all the instances associated with a particular
@@ -143,6 +148,7 @@
// operation.
func GetDatastoreParam(client *gophercloud.ServiceClient, datastoreID, versionID, paramID string) (r ParamResult) {
_, r.Err = client.Get(getDSParamURL(client, datastoreID, versionID, paramID), &r.Body, nil)
+ return
}
// ListGlobalParams is similar to ListDatastoreParams but does not require a
@@ -157,4 +163,5 @@
// DatastoreID.
func GetGlobalParam(client *gophercloud.ServiceClient, versionID, paramID string) (r ParamResult) {
_, r.Err = client.Get(getGlobalParamURL(client, versionID, paramID), &r.Body, nil)
+ return
}
diff --git a/openstack/db/v1/databases/requests.go b/openstack/db/v1/databases/requests.go
index f441d12..ef5394f 100644
--- a/openstack/db/v1/databases/requests.go
+++ b/openstack/db/v1/databases/requests.go
@@ -69,6 +69,7 @@
return
}
_, r.Err = client.Post(baseURL(client, instanceID), &b, nil, nil)
+ return
}
// List will list all of the databases for a specified instance. Note: this
@@ -84,4 +85,5 @@
// All contained data inside the database will also be permanently deleted.
func Delete(client *gophercloud.ServiceClient, instanceID, dbName string) (r DeleteResult) {
_, r.Err = client.Delete(dbURL(client, instanceID, dbName), nil)
+ return
}
diff --git a/openstack/db/v1/datastores/requests.go b/openstack/db/v1/datastores/requests.go
index aff397b..134e309 100644
--- a/openstack/db/v1/datastores/requests.go
+++ b/openstack/db/v1/datastores/requests.go
@@ -15,6 +15,7 @@
// Get will retrieve the details of a specified datastore type.
func Get(client *gophercloud.ServiceClient, datastoreID string) (r GetResult) {
_, r.Err = client.Get(resourceURL(client, datastoreID), &r.Body, nil)
+ return
}
// ListVersions will list all of the available versions for a specified
@@ -28,4 +29,5 @@
// GetVersion will retrieve the details of a specified datastore version.
func GetVersion(client *gophercloud.ServiceClient, datastoreID, versionID string) (r GetVersionResult) {
_, r.Err = client.Get(versionURL(client, datastoreID, versionID), &r.Body, nil)
+ return
}
diff --git a/openstack/db/v1/flavors/requests.go b/openstack/db/v1/flavors/requests.go
index a7cfeb5..7fac56a 100644
--- a/openstack/db/v1/flavors/requests.go
+++ b/openstack/db/v1/flavors/requests.go
@@ -17,4 +17,5 @@
// Get will retrieve information for a specified hardware flavor.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(getURL(client, id), &r.Body, nil)
+ return
}
diff --git a/openstack/db/v1/instances/requests.go b/openstack/db/v1/instances/requests.go
index 5e43078..4f06649 100644
--- a/openstack/db/v1/instances/requests.go
+++ b/openstack/db/v1/instances/requests.go
@@ -105,6 +105,7 @@
return
}
_, r.Err = client.Post(baseURL(client), &b, &r.Body, &gophercloud.RequestOpts{OkCodes: []int{200}})
+ return
}
// List retrieves the status and information for all database instances.
@@ -117,17 +118,20 @@
// Get retrieves the status and information for a specified database instance.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(resourceURL(client, id), &r.Body, nil)
+ return
}
// Delete permanently destroys the database instance.
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = client.Delete(resourceURL(client, id), nil)
+ return
}
// EnableRootUser enables the login from any host for the root user and
// provides the user with a generated root password.
func EnableRootUser(client *gophercloud.ServiceClient, id string) (r EnableRootUserResult) {
_, r.Err = client.Post(userRootURL(client, id), nil, &r.Body, &gophercloud.RequestOpts{OkCodes: []int{200}})
+ return
}
// IsRootEnabled checks an instance to see if root access is enabled. It returns
@@ -135,6 +139,7 @@
// otherwise.
func IsRootEnabled(client *gophercloud.ServiceClient, id string) (r IsRootEnabledResult) {
_, r.Err = client.Get(userRootURL(client, id), &r.Body, nil)
+ return
}
// Restart will restart only the MySQL Instance. Restarting MySQL will
@@ -143,6 +148,7 @@
func Restart(client *gophercloud.ServiceClient, id string) (r ActionResult) {
b := map[string]interface{}{"restart": struct{}{}}
_, r.Err = client.Post(actionURL(client, id), &b, nil, nil)
+ return
}
// Resize changes the memory size of the instance, assuming a valid
@@ -150,6 +156,7 @@
func Resize(client *gophercloud.ServiceClient, id, flavorRef string) (r ActionResult) {
b := map[string]interface{}{"resize": map[string]string{"flavorRef": flavorRef}}
_, r.Err = client.Post(actionURL(client, id), &b, nil, nil)
+ return
}
// ResizeVolume will resize the attached volume for an instance. It supports
@@ -158,4 +165,5 @@
func ResizeVolume(client *gophercloud.ServiceClient, id string, size int) (r ActionResult) {
b := map[string]interface{}{"resize": map[string]interface{}{"volume": map[string]int{"size": size}}}
_, r.Err = client.Post(actionURL(client, id), &b, nil, nil)
+ return
}
diff --git a/openstack/db/v1/users/requests.go b/openstack/db/v1/users/requests.go
index c0bfa42..d342de3 100644
--- a/openstack/db/v1/users/requests.go
+++ b/openstack/db/v1/users/requests.go
@@ -72,6 +72,7 @@
return
}
_, r.Err = client.Post(baseURL(client, instanceID), &b, nil, nil)
+ return
}
// List will list all the users associated with a specified database instance,
@@ -86,4 +87,5 @@
// Delete will permanently delete a user from a specified database instance.
func Delete(client *gophercloud.ServiceClient, instanceID, userName string) (r DeleteResult) {
_, r.Err = client.Delete(userURL(client, instanceID, userName), nil)
+ return
}
diff --git a/openstack/endpoint_location.go b/openstack/endpoint_location.go
index fb6b84a..ea37f5b 100644
--- a/openstack/endpoint_location.go
+++ b/openstack/endpoint_location.go
@@ -51,7 +51,6 @@
// Report an error if there were no matching endpoints.
err := &gophercloud.ErrEndpointNotFound{}
- err.Function = "openstack.V2EndpointURL"
return "", err
}
diff --git a/openstack/errors.go b/openstack/errors.go
index 8e4cbac..df410b1 100644
--- a/openstack/errors.go
+++ b/openstack/errors.go
@@ -31,7 +31,7 @@
Endpoints []tokens2.Endpoint
}
-func (e *ErrMultipleMatchingEndpointsV2) Error() string {
+func (e ErrMultipleMatchingEndpointsV2) Error() string {
return fmt.Sprintf("Discovered %d matching endpoints: %#v", len(e.Endpoints), e.Endpoints)
}
@@ -42,7 +42,7 @@
Endpoints []tokens3.Endpoint
}
-func (e *ErrMultipleMatchingEndpointsV3) Error() string {
+func (e ErrMultipleMatchingEndpointsV3) Error() string {
return fmt.Sprintf("Discovered %d matching endpoints: %#v", len(e.Endpoints), e.Endpoints)
}
@@ -50,7 +50,7 @@
// found
type ErrNoAuthURL struct{ gophercloud.ErrInvalidInput }
-func (e *ErrNoAuthURL) Error() string {
+func (e ErrNoAuthURL) Error() string {
return "Environment variable OS_AUTH_URL needs to be set."
}
@@ -58,7 +58,7 @@
// found
type ErrNoUsername struct{ gophercloud.ErrInvalidInput }
-func (e *ErrNoUsername) Error() string {
+func (e ErrNoUsername) Error() string {
return "Environment variable OS_USERNAME needs to be set."
}
@@ -66,6 +66,6 @@
// found
type ErrNoPassword struct{ gophercloud.ErrInvalidInput }
-func (e *ErrNoPassword) Error() string {
+func (e ErrNoPassword) Error() string {
return "Environment variable OS_PASSWORD needs to be set."
}
diff --git a/openstack/identity/v2/extensions/admin/roles/requests.go b/openstack/identity/v2/extensions/admin/roles/requests.go
index ba19fd4..4d27972 100644
--- a/openstack/identity/v2/extensions/admin/roles/requests.go
+++ b/openstack/identity/v2/extensions/admin/roles/requests.go
@@ -18,6 +18,7 @@
// ID is a required argument.
func AddUser(client *gophercloud.ServiceClient, tenantID, userID, roleID string) (r UserRoleResult) {
_, r.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil)
+ return
}
// DeleteUser is the operation responsible for deleting a particular role
@@ -25,4 +26,5 @@
// tenant ID is a required argument.
func DeleteUser(client *gophercloud.ServiceClient, tenantID, userID, roleID string) (r UserRoleResult) {
_, r.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil)
+ return
}
diff --git a/openstack/identity/v2/tokens/requests.go b/openstack/identity/v2/tokens/requests.go
index 12c0f17..73e0b91 100644
--- a/openstack/identity/v2/tokens/requests.go
+++ b/openstack/identity/v2/tokens/requests.go
@@ -2,6 +2,32 @@
import "github.com/gophercloud/gophercloud"
+type PasswordCredentialsV2 struct {
+ Username string `json:"username" required:"true"`
+ Password string `json:"password" required:"true"`
+}
+
+type TokenCredentialsV2 struct {
+ ID string `json:"id,omitempty" required:"true"`
+}
+
+// AuthOptionsV2 wraps a gophercloud AuthOptions in order to adhere to the AuthOptionsBuilder
+// interface.
+type AuthOptionsV2 struct {
+ PasswordCredentials *PasswordCredentialsV2 `json:"passwordCredentials,omitempty" xor:"TokenCredentials"`
+
+ // The TenantID and TenantName fields are optional for the Identity V2 API.
+ // Some providers allow you to specify a TenantName instead of the TenantId.
+ // Some require both. Your provider's authentication policies will determine
+ // how these fields influence authentication.
+ TenantID string `json:"tenantId,omitempty"`
+ TenantName string `json:"tenantName,omitempty"`
+
+ // TokenCredentials allows users to authenticate (possibly as another user) with an
+ // authentication token ID.
+ TokenCredentials *TokenCredentialsV2 `json:"token,omitempty" xor:"PasswordCredentials"`
+}
+
// AuthOptionsBuilder describes any argument that may be passed to the Create call.
type AuthOptionsBuilder interface {
// ToTokenCreateMap assembles the Create request body, returning an error if parameters are
@@ -9,6 +35,38 @@
ToTokenV2CreateMap() (map[string]interface{}, error)
}
+// AuthOptions wraps a gophercloud AuthOptions in order to adhere to the AuthOptionsBuilder
+// interface.
+type AuthOptions struct {
+ gophercloud.AuthOptions
+}
+
+// ToTokenV2CreateMap allows AuthOptions to satisfy the AuthOptionsBuilder
+// interface in the v2 tokens package
+func (opts AuthOptions) ToTokenV2CreateMap() (map[string]interface{}, error) {
+ v2Opts := AuthOptionsV2{
+ TenantID: opts.TenantID,
+ TenantName: opts.TenantName,
+ }
+
+ if opts.Password != "" {
+ v2Opts.PasswordCredentials = &PasswordCredentialsV2{
+ Username: opts.Username,
+ Password: opts.Password,
+ }
+ } else {
+ v2Opts.TokenCredentials = &TokenCredentialsV2{
+ ID: opts.TokenID,
+ }
+ }
+
+ b, err := gophercloud.BuildRequestBody(v2Opts, "auth")
+ if err != nil {
+ return nil, err
+ }
+ return b, nil
+}
+
// Create authenticates to the identity service and attempts to acquire a Token.
// If successful, the CreateResult
// Generally, rather than interact with this call directly, end users should call openstack.AuthenticatedClient(),
@@ -22,6 +80,7 @@
_, r.Err = client.Post(CreateURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 203},
})
+ return
}
// Get validates and retrieves information for user's token.
@@ -29,4 +88,5 @@
_, r.Err = client.Get(GetURL(client, token), &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 203},
})
+ return
}
diff --git a/openstack/identity/v2/tokens/requests_test.go b/openstack/identity/v2/tokens/requests_test.go
index d25c2d7..0cbb00c 100644
--- a/openstack/identity/v2/tokens/requests_test.go
+++ b/openstack/identity/v2/tokens/requests_test.go
@@ -1,7 +1,6 @@
package tokens
import (
- "reflect"
"testing"
"github.com/gophercloud/gophercloud"
@@ -13,7 +12,8 @@
th.SetupHTTP()
defer th.TeardownHTTP()
HandleTokenPost(t, requestJSON)
- return Create(client.ServiceClient(), options)
+
+ return Create(client.ServiceClient(), AuthOptions{options})
}
func tokenPostErr(t *testing.T, options gophercloud.AuthOptions, expectedErr error) {
@@ -21,30 +21,15 @@
defer th.TeardownHTTP()
HandleTokenPost(t, "")
- actualErr := Create(client.ServiceClient(), options).Err
- th.CheckDeepEquals(t, reflect.TypeOf(expectedErr), reflect.TypeOf(actualErr))
-}
-
-func TestCreateWithToken(t *testing.T) {
- options := gophercloud.AuthOptions{
- TokenID: "cbc36478b0bd8e67e89469c7749d4127",
- }
-
- IsSuccessful(t, tokenPost(t, options, `
- {
- "auth": {
- "token": {
- "id": "cbc36478b0bd8e67e89469c7749d4127"
- }
- }
- }
- `))
+ actualErr := Create(client.ServiceClient(), AuthOptions{options}).Err
+ th.CheckDeepEquals(t, expectedErr, actualErr)
}
func TestCreateWithPassword(t *testing.T) {
- options := gophercloud.AuthOptions{}
- options.Username = "me"
- options.Password = "swordfish"
+ options := gophercloud.AuthOptions{
+ Username: "me",
+ Password: "swordfish",
+ }
IsSuccessful(t, tokenPost(t, options, `
{
@@ -59,10 +44,11 @@
}
func TestCreateTokenWithTenantID(t *testing.T) {
- options := gophercloud.AuthOptions{}
- options.Username = "me"
- options.Password = "opensesame"
- options.TenantID = "fc394f2ab2df4114bde39905f800dc57"
+ options := gophercloud.AuthOptions{
+ Username: "me",
+ Password: "opensesame",
+ TenantID: "fc394f2ab2df4114bde39905f800dc57",
+ }
IsSuccessful(t, tokenPost(t, options, `
{
@@ -78,10 +64,11 @@
}
func TestCreateTokenWithTenantName(t *testing.T) {
- options := gophercloud.AuthOptions{}
- options.Username = "me"
- options.Password = "opensesame"
- options.TenantName = "demo"
+ options := gophercloud.AuthOptions{
+ Username: "me",
+ Password: "opensesame",
+ TenantName: "demo",
+ }
IsSuccessful(t, tokenPost(t, options, `
{
@@ -97,29 +84,18 @@
}
func TestRequireUsername(t *testing.T) {
- options := gophercloud.AuthOptions{}
- options.Password = "thing"
+ options := gophercloud.AuthOptions{
+ Password: "thing",
+ }
- expected := gophercloud.ErrMissingInput{}
- expected.Argument = "tokens.AuthOptions.Username/tokens.AuthOptions.TokenID"
- expected.Info = "You must provide either username/password or tenantID/token values."
- tokenPostErr(t, options, expected)
+ tokenPostErr(t, options, gophercloud.ErrMissingInput{Argument: "Username"})
}
-func TestRequirePassword(t *testing.T) {
- options := gophercloud.AuthOptions{}
- options.Username = "me"
-
- expected := gophercloud.ErrMissingInput{}
- expected.Argument = "tokens.AuthOptions.Password"
- tokenPostErr(t, options, expected)
-}
-
-func tokenGet(t *testing.T, tokenID string) GetResult {
+func tokenGet(t *testing.T, tokenId string) GetResult {
th.SetupHTTP()
defer th.TeardownHTTP()
- HandleTokenGet(t, tokenID)
- return Get(client.ServiceClient(), tokenID)
+ HandleTokenGet(t, tokenId)
+ return Get(client.ServiceClient(), tokenId)
}
func TestGetWithToken(t *testing.T) {
diff --git a/openstack/identity/v2/users/requests.go b/openstack/identity/v2/users/requests.go
index 90f7c72..ef77d39 100644
--- a/openstack/identity/v2/users/requests.go
+++ b/openstack/identity/v2/users/requests.go
@@ -57,11 +57,13 @@
_, r.Err = client.Post(rootURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 201},
})
+ return
}
// Get requests details on a single user, either by ID.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = client.Get(ResourceURL(client, id), &r.Body, nil)
+ return
}
// UpdateOptsBuilder allows extensions to add additional attributes to the Update request.
@@ -87,11 +89,13 @@
_, r.Err = client.Put(ResourceURL(client, id), &b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Delete is the operation responsible for permanently deleting an API user.
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = client.Delete(ResourceURL(client, id), nil)
+ return
}
// ListRoles lists the existing roles that can be assigned to users.
diff --git a/openstack/identity/v3/endpoints/requests.go b/openstack/identity/v3/endpoints/requests.go
index 30ceacf..fc44365 100644
--- a/openstack/identity/v3/endpoints/requests.go
+++ b/openstack/identity/v3/endpoints/requests.go
@@ -31,6 +31,7 @@
return
}
_, r.Err = client.Post(listURL(client), &b, &r.Body, nil)
+ return
}
type ListOptsBuilder interface {
@@ -91,9 +92,11 @@
return
}
_, r.Err = client.Patch(endpointURL(client, endpointID), &b, &r.Body, nil)
+ return
}
// Delete removes an endpoint from the service catalog.
func Delete(client *gophercloud.ServiceClient, endpointID string) (r DeleteResult) {
_, r.Err = client.Delete(endpointURL(client, endpointID), nil)
+ return
}
diff --git a/openstack/identity/v3/services/requests.go b/openstack/identity/v3/services/requests.go
index 81c8960..bb7bb04 100644
--- a/openstack/identity/v3/services/requests.go
+++ b/openstack/identity/v3/services/requests.go
@@ -9,6 +9,7 @@
func Create(client *gophercloud.ServiceClient, serviceType string) (r CreateResult) {
b := map[string]string{"type": serviceType}
_, r.Err = client.Post(listURL(client), b, &r.Body, nil)
+ return
}
type ListOptsBuilder interface {
@@ -45,16 +46,19 @@
// Get returns additional information about a service, given its ID.
func Get(client *gophercloud.ServiceClient, serviceID string) (r GetResult) {
_, r.Err = client.Get(serviceURL(client, serviceID), &r.Body, nil)
+ return
}
// Update changes the service type of an existing service.
func Update(client *gophercloud.ServiceClient, serviceID string, serviceType string) (r UpdateResult) {
b := map[string]string{"type": serviceType}
_, r.Err = client.Patch(serviceURL(client, serviceID), &b, &r.Body, nil)
+ return
}
// Delete removes an existing service.
// It either deletes all associated endpoints, or fails until all endpoints are deleted.
func Delete(client *gophercloud.ServiceClient, serviceID string) (r DeleteResult) {
_, r.Err = client.Delete(serviceURL(client, serviceID), nil)
+ return
}
diff --git a/openstack/identity/v3/tokens/errors.go b/openstack/identity/v3/tokens/errors.go
index 4476109..9cc1d59 100644
--- a/openstack/identity/v3/tokens/errors.go
+++ b/openstack/identity/v3/tokens/errors.go
@@ -1,72 +1,139 @@
package tokens
import (
- "errors"
"fmt"
+
+ "github.com/gophercloud/gophercloud"
)
-func unacceptedAttributeErr(attribute string) error {
- return fmt.Errorf("The base Identity V3 API does not accept authentication by %s", attribute)
+func unacceptedAttributeErr(attribute string) string {
+ return fmt.Sprintf("The base Identity V3 API does not accept authentication by %s", attribute)
}
-func redundantWithTokenErr(attribute string) error {
- return fmt.Errorf("%s may not be provided when authenticating with a TokenID", attribute)
+func redundantWithTokenErr(attribute string) string {
+ return fmt.Sprintf("%s may not be provided when authenticating with a TokenID", attribute)
}
-func redundantWithUserID(attribute string) error {
- return fmt.Errorf("%s may not be provided when authenticating with a UserID", attribute)
+func redundantWithUserID(attribute string) string {
+ return fmt.Sprintf("%s may not be provided when authenticating with a UserID", attribute)
}
-var (
- // ErrAPIKeyProvided indicates that an APIKey was provided but can't be used.
- ErrAPIKeyProvided = unacceptedAttributeErr("APIKey")
+// ErrAPIKeyProvided indicates that an APIKey was provided but can't be used.
+type ErrAPIKeyProvided struct{ gophercloud.BaseError }
- // ErrTenantIDProvided indicates that a TenantID was provided but can't be used.
- ErrTenantIDProvided = unacceptedAttributeErr("TenantID")
+func (e ErrAPIKeyProvided) Error() string {
+ return unacceptedAttributeErr("APIKey")
+}
- // ErrTenantNameProvided indicates that a TenantName was provided but can't be used.
- ErrTenantNameProvided = unacceptedAttributeErr("TenantName")
+// ErrTenantIDProvided indicates that a TenantID was provided but can't be used.
+type ErrTenantIDProvided struct{ gophercloud.BaseError }
- // ErrUsernameWithToken indicates that a Username was provided, but token authentication is being used instead.
- ErrUsernameWithToken = redundantWithTokenErr("Username")
+func (e ErrTenantIDProvided) Error() string {
+ return unacceptedAttributeErr("TenantID")
+}
- // ErrUserIDWithToken indicates that a UserID was provided, but token authentication is being used instead.
- ErrUserIDWithToken = redundantWithTokenErr("UserID")
+// ErrTenantNameProvided indicates that a TenantName was provided but can't be used.
+type ErrTenantNameProvided struct{ gophercloud.BaseError }
- // ErrDomainIDWithToken indicates that a DomainID was provided, but token authentication is being used instead.
- ErrDomainIDWithToken = redundantWithTokenErr("DomainID")
+func (e ErrTenantNameProvided) Error() string {
+ return unacceptedAttributeErr("TenantName")
+}
- // ErrDomainNameWithToken indicates that a DomainName was provided, but token authentication is being used instead.s
- ErrDomainNameWithToken = redundantWithTokenErr("DomainName")
+// ErrUsernameWithToken indicates that a Username was provided, but token authentication is being used instead.
+type ErrUsernameWithToken struct{ gophercloud.BaseError }
- // ErrUsernameOrUserID indicates that neither username nor userID are specified, or both are at once.
- ErrUsernameOrUserID = errors.New("Exactly one of Username and UserID must be provided for password authentication")
+func (e ErrUsernameWithToken) Error() string {
+ return redundantWithTokenErr("Username")
+}
- // ErrDomainIDWithUserID indicates that a DomainID was provided, but unnecessary because a UserID is being used.
- ErrDomainIDWithUserID = redundantWithUserID("DomainID")
+// ErrUserIDWithToken indicates that a UserID was provided, but token authentication is being used instead.
+type ErrUserIDWithToken struct{ gophercloud.BaseError }
- // ErrDomainNameWithUserID indicates that a DomainName was provided, but unnecessary because a UserID is being used.
- ErrDomainNameWithUserID = redundantWithUserID("DomainName")
+func (e ErrUserIDWithToken) Error() string {
+ return redundantWithTokenErr("UserID")
+}
- // ErrDomainIDOrDomainName indicates that a username was provided, but no domain to scope it.
- // It may also indicate that both a DomainID and a DomainName were provided at once.
- ErrDomainIDOrDomainName = errors.New("You must provide exactly one of DomainID or DomainName to authenticate by Username")
+// ErrDomainIDWithToken indicates that a DomainID was provided, but token authentication is being used instead.
+type ErrDomainIDWithToken struct{ gophercloud.BaseError }
- // ErrMissingPassword indicates that no password was provided and no token is available.
- ErrMissingPassword = errors.New("You must provide a password to authenticate")
+func (e ErrDomainIDWithToken) Error() string {
+ return redundantWithTokenErr("DomainID")
+}
- // ErrScopeDomainIDOrDomainName indicates that a domain ID or Name was required in a Scope, but not present.
- ErrScopeDomainIDOrDomainName = errors.New("You must provide exactly one of DomainID or DomainName in a Scope with ProjectName")
+// ErrDomainNameWithToken indicates that a DomainName was provided, but token authentication is being used instead.s
+type ErrDomainNameWithToken struct{ gophercloud.BaseError }
- // ErrScopeProjectIDOrProjectName indicates that both a ProjectID and a ProjectName were provided in a Scope.
- ErrScopeProjectIDOrProjectName = errors.New("You must provide at most one of ProjectID or ProjectName in a Scope")
+func (e ErrDomainNameWithToken) Error() string {
+ return redundantWithTokenErr("DomainName")
+}
- // ErrScopeProjectIDAlone indicates that a ProjectID was provided with other constraints in a Scope.
- ErrScopeProjectIDAlone = errors.New("ProjectID must be supplied alone in a Scope")
+// ErrUsernameOrUserID indicates that neither username nor userID are specified, or both are at once.
+type ErrUsernameOrUserID struct{ gophercloud.BaseError }
- // ErrScopeDomainName indicates that a DomainName was provided alone in a Scope.
- ErrScopeDomainName = errors.New("DomainName must be supplied with a ProjectName or ProjectID in a Scope.")
+func (e ErrUsernameOrUserID) Error() string {
+ return "Exactly one of Username and UserID must be provided for password authentication"
+}
- // ErrScopeEmpty indicates that no credentials were provided in a Scope.
- ErrScopeEmpty = errors.New("You must provide either a Project or Domain in a Scope")
-)
+// ErrDomainIDWithUserID indicates that a DomainID was provided, but unnecessary because a UserID is being used.
+type ErrDomainIDWithUserID struct{ gophercloud.BaseError }
+
+func (e ErrDomainIDWithUserID) Error() string {
+ return redundantWithUserID("DomainID")
+}
+
+// ErrDomainNameWithUserID indicates that a DomainName was provided, but unnecessary because a UserID is being used.
+type ErrDomainNameWithUserID struct{ gophercloud.BaseError }
+
+func (e ErrDomainNameWithUserID) Error() string {
+ return redundantWithUserID("DomainName")
+}
+
+// ErrDomainIDOrDomainName indicates that a username was provided, but no domain to scope it.
+// It may also indicate that both a DomainID and a DomainName were provided at once.
+type ErrDomainIDOrDomainName struct{ gophercloud.BaseError }
+
+func (e ErrDomainIDOrDomainName) Error() string {
+ return "You must provide exactly one of DomainID or DomainName to authenticate by Username"
+}
+
+// ErrMissingPassword indicates that no password was provided and no token is available.
+type ErrMissingPassword struct{ gophercloud.BaseError }
+
+func (e ErrMissingPassword) Error() string {
+ return "You must provide a password to authenticate"
+}
+
+// ErrScopeDomainIDOrDomainName indicates that a domain ID or Name was required in a Scope, but not present.
+type ErrScopeDomainIDOrDomainName struct{ gophercloud.BaseError }
+
+func (e ErrScopeDomainIDOrDomainName) Error() string {
+ return "You must provide exactly one of DomainID or DomainName in a Scope with ProjectName"
+}
+
+// ErrScopeProjectIDOrProjectName indicates that both a ProjectID and a ProjectName were provided in a Scope.
+type ErrScopeProjectIDOrProjectName struct{ gophercloud.BaseError }
+
+func (e ErrScopeProjectIDOrProjectName) Error() string {
+ return "You must provide at most one of ProjectID or ProjectName in a Scope"
+}
+
+// ErrScopeProjectIDAlone indicates that a ProjectID was provided with other constraints in a Scope.
+type ErrScopeProjectIDAlone struct{ gophercloud.BaseError }
+
+func (e ErrScopeProjectIDAlone) Error() string {
+ return "ProjectID must be supplied alone in a Scope"
+}
+
+// ErrScopeDomainName indicates that a DomainName was provided alone in a Scope.
+type ErrScopeDomainName struct{ gophercloud.BaseError }
+
+func (e ErrScopeDomainName) Error() string {
+ return "DomainName must be supplied with a ProjectName or ProjectID in a Scope"
+}
+
+// ErrScopeEmpty indicates that no credentials were provided in a Scope.
+type ErrScopeEmpty struct{ gophercloud.BaseError }
+
+func (e ErrScopeEmpty) Error() string {
+ return "You must provide either a Project or Domain in a Scope"
+}
diff --git a/openstack/identity/v3/tokens/requests.go b/openstack/identity/v3/tokens/requests.go
index 6978186..12930f9 100644
--- a/openstack/identity/v3/tokens/requests.go
+++ b/openstack/identity/v3/tokens/requests.go
@@ -1,16 +1,275 @@
package tokens
-import (
- "net/http"
+import "github.com/gophercloud/gophercloud"
- "github.com/gophercloud/gophercloud"
-)
+// Scope allows a created token to be limited to a specific domain or project.
+type Scope struct {
+ ProjectID string `json:"scope.project.id,omitempty" not:"ProjectName,DomainID,DomainName"`
+ ProjectName string `json:"scope.project.name,omitempty"`
+ DomainID string `json:"scope.project.id,omitempty" not:"ProjectName,ProjectID,DomainName"`
+ DomainName string `json:"scope.project.id,omitempty"`
+}
// AuthOptionsBuilder describes any argument that may be passed to the Create call.
type AuthOptionsBuilder interface {
// ToTokenV3CreateMap assembles the Create request body, returning an error if parameters are
// missing or inconsistent.
- ToTokenV3CreateMap(*gophercloud.ScopeOptsV3) (map[string]interface{}, error)
+ ToTokenV3CreateMap(*Scope) (map[string]interface{}, error)
+}
+
+type AuthOptions struct {
+ // IdentityEndpoint specifies the HTTP endpoint that is required to work with
+ // the Identity API of the appropriate version. While it's ultimately needed by
+ // all of the identity services, it will often be populated by a provider-level
+ // function.
+ IdentityEndpoint string `json:"-"`
+
+ // Username is required if using Identity V2 API. Consult with your provider's
+ // control panel to discover your account's username. In Identity V3, either
+ // UserID or a combination of Username and DomainID or DomainName are needed.
+ Username string `json:"username,omitempty"`
+ UserID string `json:"id,omitempty"`
+
+ Password string `json:"password,omitempty"`
+
+ // At most one of DomainID and DomainName must be provided if using Username
+ // with Identity V3. Otherwise, either are optional.
+ DomainID string `json:"id,omitempty"`
+ DomainName string `json:"name,omitempty"`
+
+ // The TenantID and TenantName fields are optional for the Identity V2 API.
+ // Some providers allow you to specify a TenantName instead of the TenantId.
+ // Some require both. Your provider's authentication policies will determine
+ // how these fields influence authentication.
+ TenantID string `json:"tenantId,omitempty"`
+ TenantName string `json:"tenantName,omitempty"`
+
+ // AllowReauth should be set to true if you grant permission for Gophercloud to
+ // cache your credentials in memory, and to allow Gophercloud to attempt to
+ // re-authenticate automatically if/when your token expires. If you set it to
+ // false, it will not cache these settings, but re-authentication will not be
+ // possible. This setting defaults to false.
+ AllowReauth bool `json:"-"`
+
+ // TokenID allows users to authenticate (possibly as another user) with an
+ // authentication token ID.
+ TokenID string
+}
+
+func (opts AuthOptions) ToTokenV3CreateMap(scope *Scope) (map[string]interface{}, error) {
+ type domainReq struct {
+ ID *string `json:"id,omitempty"`
+ Name *string `json:"name,omitempty"`
+ }
+
+ type projectReq struct {
+ Domain *domainReq `json:"domain,omitempty"`
+ Name *string `json:"name,omitempty"`
+ ID *string `json:"id,omitempty"`
+ }
+
+ type userReq struct {
+ ID *string `json:"id,omitempty"`
+ Name *string `json:"name,omitempty"`
+ Password string `json:"password"`
+ Domain *domainReq `json:"domain,omitempty"`
+ }
+
+ type passwordReq struct {
+ User userReq `json:"user"`
+ }
+
+ type tokenReq struct {
+ ID string `json:"id"`
+ }
+
+ type identityReq struct {
+ Methods []string `json:"methods"`
+ Password *passwordReq `json:"password,omitempty"`
+ Token *tokenReq `json:"token,omitempty"`
+ }
+
+ type scopeReq struct {
+ Domain *domainReq `json:"domain,omitempty"`
+ Project *projectReq `json:"project,omitempty"`
+ }
+
+ type authReq struct {
+ Identity identityReq `json:"identity"`
+ Scope *scopeReq `json:"scope,omitempty"`
+ }
+
+ type request struct {
+ Auth authReq `json:"auth"`
+ }
+
+ // Populate the request structure based on the provided arguments. Create and return an error
+ // if insufficient or incompatible information is present.
+ var req request
+
+ // Test first for unrecognized arguments.
+ if opts.TenantID != "" {
+ return nil, ErrTenantIDProvided{}
+ }
+ if opts.TenantName != "" {
+ return nil, ErrTenantNameProvided{}
+ }
+
+ if opts.Password == "" {
+ if opts.TokenID != "" {
+ // Because we aren't using password authentication, it's an error to also provide any of the user-based authentication
+ // parameters.
+ if opts.Username != "" {
+ return nil, ErrUsernameWithToken{}
+ }
+ if opts.UserID != "" {
+ return nil, ErrUserIDWithToken{}
+ }
+ if opts.DomainID != "" {
+ return nil, ErrDomainIDWithToken{}
+ }
+ if opts.DomainName != "" {
+ return nil, ErrDomainNameWithToken{}
+ }
+
+ // Configure the request for Token authentication.
+ req.Auth.Identity.Methods = []string{"token"}
+ req.Auth.Identity.Token = &tokenReq{
+ ID: opts.TokenID,
+ }
+ } else {
+ // If no password or token ID are available, authentication can't continue.
+ return nil, ErrMissingPassword{}
+ }
+ } else {
+ // Password authentication.
+ req.Auth.Identity.Methods = []string{"password"}
+
+ // At least one of Username and UserID must be specified.
+ if opts.Username == "" && opts.UserID == "" {
+ return nil, ErrUsernameOrUserID{}
+ }
+
+ if opts.Username != "" {
+ // If Username is provided, UserID may not be provided.
+ if opts.UserID != "" {
+ return nil, ErrUsernameOrUserID{}
+ }
+
+ // Either DomainID or DomainName must also be specified.
+ if opts.DomainID == "" && opts.DomainName == "" {
+ return nil, ErrDomainIDOrDomainName{}
+ }
+
+ if opts.DomainID != "" {
+ if opts.DomainName != "" {
+ return nil, ErrDomainIDOrDomainName{}
+ }
+
+ // Configure the request for Username and Password authentication with a DomainID.
+ req.Auth.Identity.Password = &passwordReq{
+ User: userReq{
+ Name: &opts.Username,
+ Password: opts.Password,
+ Domain: &domainReq{ID: &opts.DomainID},
+ },
+ }
+ }
+
+ if opts.DomainName != "" {
+ // Configure the request for Username and Password authentication with a DomainName.
+ req.Auth.Identity.Password = &passwordReq{
+ User: userReq{
+ Name: &opts.Username,
+ Password: opts.Password,
+ Domain: &domainReq{Name: &opts.DomainName},
+ },
+ }
+ }
+ }
+
+ if opts.UserID != "" {
+ // If UserID is specified, neither DomainID nor DomainName may be.
+ if opts.DomainID != "" {
+ return nil, ErrDomainIDWithUserID{}
+ }
+ if opts.DomainName != "" {
+ return nil, ErrDomainNameWithUserID{}
+ }
+
+ // Configure the request for UserID and Password authentication.
+ req.Auth.Identity.Password = &passwordReq{
+ User: userReq{ID: &opts.UserID, Password: opts.Password},
+ }
+ }
+ }
+
+ // Add a "scope" element if a Scope has been provided.
+ if scope != nil {
+ if scope.ProjectName != "" {
+ // ProjectName provided: either DomainID or DomainName must also be supplied.
+ // ProjectID may not be supplied.
+ if scope.DomainID == "" && scope.DomainName == "" {
+ return nil, ErrScopeDomainIDOrDomainName{}
+ }
+ if scope.ProjectID != "" {
+ return nil, ErrScopeProjectIDOrProjectName{}
+ }
+
+ if scope.DomainID != "" {
+ // ProjectName + DomainID
+ req.Auth.Scope = &scopeReq{
+ Project: &projectReq{
+ Name: &scope.ProjectName,
+ Domain: &domainReq{ID: &scope.DomainID},
+ },
+ }
+ }
+
+ if scope.DomainName != "" {
+ // ProjectName + DomainName
+ req.Auth.Scope = &scopeReq{
+ Project: &projectReq{
+ Name: &scope.ProjectName,
+ Domain: &domainReq{Name: &scope.DomainName},
+ },
+ }
+ }
+ } else if scope.ProjectID != "" {
+ // ProjectID provided. ProjectName, DomainID, and DomainName may not be provided.
+ if scope.DomainID != "" {
+ return nil, ErrScopeProjectIDAlone{}
+ }
+ if scope.DomainName != "" {
+ return nil, ErrScopeProjectIDAlone{}
+ }
+
+ // ProjectID
+ req.Auth.Scope = &scopeReq{
+ Project: &projectReq{ID: &scope.ProjectID},
+ }
+ } else if scope.DomainID != "" {
+ // DomainID provided. ProjectID, ProjectName, and DomainName may not be provided.
+ if scope.DomainName != "" {
+ return nil, ErrScopeDomainIDOrDomainName{}
+ }
+
+ // DomainID
+ req.Auth.Scope = &scopeReq{
+ Domain: &domainReq{ID: &scope.DomainID},
+ }
+ } else if scope.DomainName != "" {
+ return nil, ErrScopeDomainName{}
+ } else {
+ return nil, ErrScopeEmpty{}
+ }
+ }
+
+ b, err2 := gophercloud.BuildRequestBody(req, "")
+ if err2 != nil {
+ return nil, err2
+ }
+ return b, nil
}
func subjectTokenHeaders(c *gophercloud.ServiceClient, subjectToken string) map[string]string {
@@ -20,34 +279,36 @@
}
// Create authenticates and either generates a new token, or changes the Scope of an existing token.
-func Create(c *gophercloud.ServiceClient, opts AuthOptionsBuilder, scopeOpts *gophercloud.ScopeOptsV3) (r CreateResult) {
+func Create(c *gophercloud.ServiceClient, opts AuthOptionsBuilder, scopeOpts *Scope) (r CreateResult) {
b, err := opts.ToTokenV3CreateMap(scopeOpts)
if err != nil {
r.Err = err
return
}
- var resp *http.Response
- resp, r.Err = c.Post(tokenURL(c), b, &r.Body, nil)
+ resp, err := c.Post(tokenURL(c), b, &r.Body, nil)
if resp != nil {
+ r.Err = err
r.Header = resp.Header
}
+ return
}
// Get validates and retrieves information about another token.
func Get(c *gophercloud.ServiceClient, token string) (r GetResult) {
- var resp *http.Response
- resp, r.Err = c.Get(tokenURL(c), &r.Body, &gophercloud.RequestOpts{
+ resp, err := c.Get(tokenURL(c), &r.Body, &gophercloud.RequestOpts{
MoreHeaders: subjectTokenHeaders(c, token),
OkCodes: []int{200, 203},
})
if resp != nil {
+ r.Err = err
r.Header = resp.Header
}
+ return
}
// Validate determines if a specified token is valid or not.
func Validate(c *gophercloud.ServiceClient, token string) (bool, error) {
- response, err := c.Request("HEAD", tokenURL(c), &gophercloud.RequestOpts{
+ resp, err := c.Request("HEAD", tokenURL(c), &gophercloud.RequestOpts{
MoreHeaders: subjectTokenHeaders(c, token),
OkCodes: []int{204, 404},
})
@@ -55,7 +316,7 @@
return false, err
}
- return response.StatusCode == 204, nil
+ return resp.StatusCode == 204, nil
}
// Revoke immediately makes specified token invalid.
@@ -63,4 +324,5 @@
_, r.Err = c.Delete(tokenURL(c), &gophercloud.RequestOpts{
MoreHeaders: subjectTokenHeaders(c, token),
})
+ return
}
diff --git a/openstack/identity/v3/tokens/requests_test.go b/openstack/identity/v3/tokens/requests_test.go
index a39a6f4..faa79e0 100644
--- a/openstack/identity/v3/tokens/requests_test.go
+++ b/openstack/identity/v3/tokens/requests_test.go
@@ -11,15 +11,13 @@
)
// authTokenPost verifies that providing certain AuthOptions and Scope results in an expected JSON structure.
-func authTokenPost(t *testing.T, options AuthOptionsBuilder, scope *gophercloud.ScopeOptsV3, requestJSON string) {
+func authTokenPost(t *testing.T, options AuthOptions, scope *Scope, requestJSON string) {
testhelper.SetupHTTP()
defer testhelper.TeardownHTTP()
client := gophercloud.ServiceClient{
- ProviderClient: &gophercloud.ProviderClient{
- TokenID: "12345abcdef",
- },
- Endpoint: testhelper.Endpoint(),
+ ProviderClient: &gophercloud.ProviderClient{},
+ Endpoint: testhelper.Endpoint(),
}
testhelper.Mux.HandleFunc("/auth/tokens", func(w http.ResponseWriter, r *http.Request) {
@@ -42,7 +40,7 @@
}
}
-func authTokenPostErr(t *testing.T, options AuthOptionsBuilder, scope *gophercloud.ScopeOptsV3, includeToken bool, expectedErr error) {
+func authTokenPostErr(t *testing.T, options AuthOptions, scope *Scope, includeToken bool, expectedErr error) {
testhelper.SetupHTTP()
defer testhelper.TeardownHTTP()
@@ -64,10 +62,7 @@
}
func TestCreateUserIDAndPassword(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "me"
- ao.Password = "squirrel!"
- authTokenPost(t, ao, nil, `
+ authTokenPost(t, AuthOptions{UserID: "me", Password: "squirrel!"}, nil, `
{
"auth": {
"identity": {
@@ -82,10 +77,7 @@
}
func TestCreateUsernameDomainIDPassword(t *testing.T) {
- ao := gophercloud.AuthOptions{DomainID: "abc123"}
- ao.Username = "fakey"
- ao.Password = "notpassword"
- authTokenPost(t, ao, nil, `
+ authTokenPost(t, AuthOptions{Username: "fakey", Password: "notpassword", DomainID: "abc123"}, nil, `
{
"auth": {
"identity": {
@@ -106,10 +98,7 @@
}
func TestCreateUsernameDomainNamePassword(t *testing.T) {
- ao := gophercloud.AuthOptions{DomainName: "spork.net"}
- ao.Username = "frank"
- ao.Password = "swordfish"
- authTokenPost(t, ao, nil, `
+ authTokenPost(t, AuthOptions{Username: "frank", Password: "swordfish", DomainName: "spork.net"}, nil, `
{
"auth": {
"identity": {
@@ -130,7 +119,7 @@
}
func TestCreateTokenID(t *testing.T) {
- authTokenPost(t, gophercloud.AuthOptions{TokenID: "12345abcdef"}, nil, `
+ authTokenPost(t, AuthOptions{TokenID: "12345abcdef"}, nil, `
{
"auth": {
"identity": {
@@ -145,11 +134,9 @@
}
func TestCreateProjectIDScope(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "fenris"
- ao.Password = "g0t0h311"
- scope := &gophercloud.ScopeOptsV3{ProjectID: "123456"}
- authTokenPost(t, ao, scope, `
+ options := AuthOptions{UserID: "fenris", Password: "g0t0h311"}
+ scope := &Scope{ProjectID: "123456"}
+ authTokenPost(t, options, scope, `
{
"auth": {
"identity": {
@@ -172,11 +159,9 @@
}
func TestCreateDomainIDScope(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "fenris"
- ao.Password = "g0t0h311"
- scope := &gophercloud.ScopeOptsV3{DomainID: "1000"}
- authTokenPost(t, ao, scope, `
+ options := AuthOptions{UserID: "fenris", Password: "g0t0h311"}
+ scope := &Scope{DomainID: "1000"}
+ authTokenPost(t, options, scope, `
{
"auth": {
"identity": {
@@ -199,11 +184,9 @@
}
func TestCreateProjectNameAndDomainIDScope(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "fenris"
- ao.Password = "g0t0h311"
- scope := &gophercloud.ScopeOptsV3{ProjectName: "world-domination", DomainID: "1000"}
- authTokenPost(t, ao, scope, `
+ options := AuthOptions{UserID: "fenris", Password: "g0t0h311"}
+ scope := &Scope{ProjectName: "world-domination", DomainID: "1000"}
+ authTokenPost(t, options, scope, `
{
"auth": {
"identity": {
@@ -229,11 +212,9 @@
}
func TestCreateProjectNameAndDomainNameScope(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "fenris"
- ao.Password = "g0t0h311"
- scope := &gophercloud.ScopeOptsV3{ProjectName: "world-domination", DomainName: "evil-plans"}
- authTokenPost(t, ao, scope, `
+ options := AuthOptions{UserID: "fenris", Password: "g0t0h311"}
+ scope := &Scope{ProjectName: "world-domination", DomainName: "evil-plans"}
+ authTokenPost(t, options, scope, `
{
"auth": {
"identity": {
@@ -278,10 +259,8 @@
}`)
})
- ao := gophercloud.AuthOptions{}
- ao.UserID = "me"
- ao.Password = "shhh"
- token, err := Create(&client, ao, nil).Extract()
+ options := AuthOptions{UserID: "me", Password: "shhh"}
+ token, err := Create(&client, options, nil).Extract()
if err != nil {
t.Fatalf("Create returned an error: %v", err)
}
@@ -292,127 +271,123 @@
}
func TestCreateFailureEmptyAuth(t *testing.T) {
- authTokenPostErr(t, gophercloud.AuthOptions{}, nil, false, ErrMissingPassword)
+ authTokenPostErr(t, AuthOptions{}, nil, false, ErrMissingPassword{})
+}
+
+func TestCreateFailureTenantID(t *testing.T) {
+ authTokenPostErr(t, AuthOptions{TenantID: "something"}, nil, false, ErrTenantIDProvided{})
+}
+
+func TestCreateFailureTenantName(t *testing.T) {
+ authTokenPostErr(t, AuthOptions{TenantName: "something"}, nil, false, ErrTenantNameProvided{})
}
func TestCreateFailureTokenIDUsername(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.Username = "somthing"
- authTokenPostErr(t, ao, nil, true, ErrUsernameWithToken)
+ authTokenPostErr(t, AuthOptions{Username: "something", TokenID: "12345"}, nil, true, ErrUsernameWithToken{})
}
func TestCreateFailureTokenIDUserID(t *testing.T) {
- authTokenPostErr(t, gophercloud.AuthOptions{UserID: "something"}, nil, true, ErrUserIDWithToken)
+ authTokenPostErr(t, AuthOptions{UserID: "something", TokenID: "12345"}, nil, true, ErrUserIDWithToken{})
}
func TestCreateFailureTokenIDDomainID(t *testing.T) {
- authTokenPostErr(t, gophercloud.AuthOptions{DomainID: "something"}, nil, true, ErrDomainIDWithToken)
+ authTokenPostErr(t, AuthOptions{DomainID: "something", TokenID: "12345"}, nil, true, ErrDomainIDWithToken{})
}
func TestCreateFailureTokenIDDomainName(t *testing.T) {
- authTokenPostErr(t, gophercloud.AuthOptions{DomainName: "something"}, nil, true, ErrDomainNameWithToken)
+ authTokenPostErr(t, AuthOptions{DomainName: "something", TokenID: "12345"}, nil, true, ErrDomainNameWithToken{})
}
func TestCreateFailureMissingUser(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.Password = "supersecure"
- authTokenPostErr(t, ao, nil, false, ErrUsernameOrUserID)
+ options := AuthOptions{Password: "supersecure"}
+ authTokenPostErr(t, options, nil, false, ErrUsernameOrUserID{})
}
func TestCreateFailureBothUser(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "redundancy"
- ao.Username = "oops"
- ao.Password = "supersecure"
- authTokenPostErr(t, ao, nil, false, ErrUsernameOrUserID)
+ options := AuthOptions{
+ Password: "supersecure",
+ Username: "oops",
+ UserID: "redundancy",
+ }
+ authTokenPostErr(t, options, nil, false, ErrUsernameOrUserID{})
}
func TestCreateFailureMissingDomain(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.Username = "notuniqueenough"
- ao.Password = "supersecure"
- authTokenPostErr(t, ao, nil, false, ErrDomainIDOrDomainName)
+ options := AuthOptions{
+ Password: "supersecure",
+ Username: "notuniqueenough",
+ }
+ authTokenPostErr(t, options, nil, false, ErrDomainIDOrDomainName{})
}
func TestCreateFailureBothDomain(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.Username = "someone"
- ao.Password = "supersecure"
- ao.DomainID = "hurf"
- ao.DomainName = "durf"
- authTokenPostErr(t, ao, nil, false, ErrDomainIDOrDomainName)
+ options := AuthOptions{
+ Password: "supersecure",
+ Username: "someone",
+ DomainID: "hurf",
+ DomainName: "durf",
+ }
+ authTokenPostErr(t, options, nil, false, ErrDomainIDOrDomainName{})
}
func TestCreateFailureUserIDDomainID(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "100"
- ao.Password = "stuff"
- ao.DomainID = "oops"
- authTokenPostErr(t, ao, nil, false, ErrDomainIDWithUserID)
+ options := AuthOptions{
+ UserID: "100",
+ Password: "stuff",
+ DomainID: "oops",
+ }
+ authTokenPostErr(t, options, nil, false, ErrDomainIDWithUserID{})
}
func TestCreateFailureUserIDDomainName(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "100"
- ao.Password = "sssh"
- ao.DomainName = "oops"
- authTokenPostErr(t, ao, nil, false, ErrDomainNameWithUserID)
+ options := AuthOptions{
+ UserID: "100",
+ Password: "sssh",
+ DomainName: "oops",
+ }
+ authTokenPostErr(t, options, nil, false, ErrDomainNameWithUserID{})
}
func TestCreateFailureScopeProjectNameAlone(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "myself"
- ao.Password = "swordfish"
- scope := &gophercloud.ScopeOptsV3{ProjectName: "notenough"}
- authTokenPostErr(t, ao, scope, false, ErrScopeDomainIDOrDomainName)
+ options := AuthOptions{UserID: "myself", Password: "swordfish"}
+ scope := &Scope{ProjectName: "notenough"}
+ authTokenPostErr(t, options, scope, false, ErrScopeDomainIDOrDomainName{})
}
func TestCreateFailureScopeProjectNameAndID(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "myself"
- ao.Password = "swordfish"
- scope := &gophercloud.ScopeOptsV3{ProjectName: "whoops", ProjectID: "toomuch", DomainID: "1234"}
- authTokenPostErr(t, ao, scope, false, ErrScopeProjectIDOrProjectName)
+ options := AuthOptions{UserID: "myself", Password: "swordfish"}
+ scope := &Scope{ProjectName: "whoops", ProjectID: "toomuch", DomainID: "1234"}
+ authTokenPostErr(t, options, scope, false, ErrScopeProjectIDOrProjectName{})
}
func TestCreateFailureScopeProjectIDAndDomainID(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "myself"
- ao.Password = "swordfish"
- scope := &gophercloud.ScopeOptsV3{ProjectID: "toomuch", DomainID: "notneeded"}
- authTokenPostErr(t, ao, scope, false, ErrScopeProjectIDAlone)
+ options := AuthOptions{UserID: "myself", Password: "swordfish"}
+ scope := &Scope{ProjectID: "toomuch", DomainID: "notneeded"}
+ authTokenPostErr(t, options, scope, false, ErrScopeProjectIDAlone{})
}
func TestCreateFailureScopeProjectIDAndDomainNAme(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "myself"
- ao.Password = "swordfish"
- scope := &gophercloud.ScopeOptsV3{ProjectID: "toomuch", DomainName: "notneeded"}
- authTokenPostErr(t, ao, scope, false, ErrScopeProjectIDAlone)
+ options := AuthOptions{UserID: "myself", Password: "swordfish"}
+ scope := &Scope{ProjectID: "toomuch", DomainName: "notneeded"}
+ authTokenPostErr(t, options, scope, false, ErrScopeProjectIDAlone{})
}
func TestCreateFailureScopeDomainIDAndDomainName(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "myself"
- ao.Password = "swordfish"
- scope := &gophercloud.ScopeOptsV3{DomainID: "toomuch", DomainName: "notneeded"}
- authTokenPostErr(t, ao, scope, false, ErrScopeDomainIDOrDomainName)
+ options := AuthOptions{UserID: "myself", Password: "swordfish"}
+ scope := &Scope{DomainID: "toomuch", DomainName: "notneeded"}
+ authTokenPostErr(t, options, scope, false, ErrScopeDomainIDOrDomainName{})
}
func TestCreateFailureScopeDomainNameAlone(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "myself"
- ao.Password = "swordfish"
- scope := &gophercloud.ScopeOptsV3{DomainName: "notenough"}
- authTokenPostErr(t, ao, scope, false, ErrScopeDomainName)
+ options := AuthOptions{UserID: "myself", Password: "swordfish"}
+ scope := &Scope{DomainName: "notenough"}
+ authTokenPostErr(t, options, scope, false, ErrScopeDomainName{})
}
func TestCreateFailureEmptyScope(t *testing.T) {
- ao := gophercloud.AuthOptions{}
- ao.UserID = "myself"
- ao.Password = "swordfish"
- scope := &gophercloud.ScopeOptsV3{}
- authTokenPostErr(t, ao, scope, false, ErrScopeEmpty)
+ options := AuthOptions{UserID: "myself", Password: "swordfish"}
+ scope := &Scope{}
+ authTokenPostErr(t, options, scope, false, ErrScopeEmpty{})
}
func TestGetRequest(t *testing.T) {
diff --git a/openstack/networking/v2/extensions/fwaas/firewalls/requests.go b/openstack/networking/v2/extensions/fwaas/firewalls/requests.go
index d7535f8..21ceb4e 100644
--- a/openstack/networking/v2/extensions/fwaas/firewalls/requests.go
+++ b/openstack/networking/v2/extensions/fwaas/firewalls/requests.go
@@ -89,11 +89,13 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular firewall based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
// UpdateOptsBuilder is the interface options structs have to satisfy in order
@@ -128,9 +130,11 @@
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Delete will permanently delete a particular firewall based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
diff --git a/openstack/networking/v2/extensions/fwaas/policies/requests.go b/openstack/networking/v2/extensions/fwaas/policies/requests.go
index c9c1400..437d124 100644
--- a/openstack/networking/v2/extensions/fwaas/policies/requests.go
+++ b/openstack/networking/v2/extensions/fwaas/policies/requests.go
@@ -88,11 +88,13 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular firewall policy based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
// UpdateOptsBuilder is the interface options structs have to satisfy in order
@@ -127,11 +129,13 @@
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Delete will permanently delete a particular firewall policy based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
type InsertRuleOptsBuilder interface {
@@ -157,6 +161,7 @@
_, r.Err = c.Put(insertURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
func RemoveRule(c *gophercloud.ServiceClient, id, ruleID string) (r RemoveRuleResult) {
@@ -164,4 +169,5 @@
_, r.Err = c.Put(removeURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
diff --git a/openstack/networking/v2/extensions/fwaas/rules/requests.go b/openstack/networking/v2/extensions/fwaas/rules/requests.go
index f90cad1..6b0814c 100644
--- a/openstack/networking/v2/extensions/fwaas/rules/requests.go
+++ b/openstack/networking/v2/extensions/fwaas/rules/requests.go
@@ -103,11 +103,13 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular firewall rule based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
// UpdateOptsBuilder is the interface options structs have to satisfy in order
@@ -148,9 +150,11 @@
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Delete will permanently delete a particular firewall rule based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
diff --git a/openstack/networking/v2/extensions/layer3/floatingips/requests.go b/openstack/networking/v2/extensions/layer3/floatingips/requests.go
index defa9c0..ed6b263 100644
--- a/openstack/networking/v2/extensions/layer3/floatingips/requests.go
+++ b/openstack/networking/v2/extensions/layer3/floatingips/requests.go
@@ -91,11 +91,13 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular floating IP resource based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
// UpdateOptsBuilder is the interface type must satisfy to be used as Update
@@ -131,6 +133,7 @@
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Delete will permanently delete a particular floating IP resource. Please
@@ -138,4 +141,5 @@
// internal ports.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
diff --git a/openstack/networking/v2/extensions/layer3/routers/requests.go b/openstack/networking/v2/extensions/layer3/routers/requests.go
index 301db01..48c0a52 100644
--- a/openstack/networking/v2/extensions/layer3/routers/requests.go
+++ b/openstack/networking/v2/extensions/layer3/routers/requests.go
@@ -73,11 +73,13 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular router based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
type UpdateOptsBuilder interface {
@@ -111,11 +113,13 @@
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Delete will permanently delete a particular router based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
// AddInterfaceOptsBuilder is what types must satisfy to be used as AddInterface
@@ -167,6 +171,7 @@
_, r.Err = c.Put(addInterfaceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// RemoveInterfaceOptsBuilder is what types must satisfy to be used as RemoveInterface
@@ -210,4 +215,5 @@
_, r.Err = c.Put(removeInterfaceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
diff --git a/openstack/networking/v2/extensions/lbaas/members/requests.go b/openstack/networking/v2/extensions/lbaas/members/requests.go
index a261fb5..f74eb82 100644
--- a/openstack/networking/v2/extensions/lbaas/members/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/members/requests.go
@@ -72,11 +72,13 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular pool member based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
type UpdateOptsBuilder interface {
@@ -103,9 +105,11 @@
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 201, 202},
})
+ return
}
// Delete will permanently delete a particular member based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
diff --git a/openstack/networking/v2/extensions/lbaas/monitors/requests.go b/openstack/networking/v2/extensions/lbaas/monitors/requests.go
index 686b2ea..f1b964b 100644
--- a/openstack/networking/v2/extensions/lbaas/monitors/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/monitors/requests.go
@@ -137,11 +137,13 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular health monitor based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
// UpdateOptsBuilder is what types must satisfy to be used as Update
@@ -198,9 +200,11 @@
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 202},
})
+ return
}
// Delete will permanently delete a particular monitor based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
diff --git a/openstack/networking/v2/extensions/lbaas/pools/requests.go b/openstack/networking/v2/extensions/lbaas/pools/requests.go
index a5c2b1f..043945b 100644
--- a/openstack/networking/v2/extensions/lbaas/pools/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/pools/requests.go
@@ -98,11 +98,13 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular pool based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
// UpdateOptsBuilder is the interface types must satisfy to be used as options
@@ -136,11 +138,13 @@
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Delete will permanently delete a particular pool based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
// AssociateMonitor will associate a health monitor with a particular pool.
@@ -151,6 +155,7 @@
func AssociateMonitor(c *gophercloud.ServiceClient, poolID, monitorID string) (r AssociateResult) {
b := map[string]interface{}{"health_monitor": map[string]string{"id": monitorID}}
_, r.Err = c.Post(associateURL(c, poolID), b, &r.Body, nil)
+ return
}
// DisassociateMonitor will disassociate a health monitor with a particular
@@ -158,4 +163,5 @@
// check for the health of the members of the pool.
func DisassociateMonitor(c *gophercloud.ServiceClient, poolID, monitorID string) (r AssociateResult) {
_, r.Err = c.Delete(disassociateURL(c, poolID, monitorID), nil)
+ return
}
diff --git a/openstack/networking/v2/extensions/lbaas/vips/requests.go b/openstack/networking/v2/extensions/lbaas/vips/requests.go
index a255258..f89d769 100644
--- a/openstack/networking/v2/extensions/lbaas/vips/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/vips/requests.go
@@ -104,11 +104,13 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular virtual IP based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
// UpdateOptsBuilder is what types must satisfy to be used as Update
@@ -151,9 +153,11 @@
_, r.Err = c.Put(resourceURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 202},
})
+ return
}
// Delete will permanently delete a particular virtual IP based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
diff --git a/openstack/networking/v2/extensions/security/groups/requests.go b/openstack/networking/v2/extensions/security/groups/requests.go
index 267ebdd..5ca4850 100644
--- a/openstack/networking/v2/extensions/security/groups/requests.go
+++ b/openstack/networking/v2/extensions/security/groups/requests.go
@@ -61,16 +61,19 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular security group based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
// Delete will permanently delete a particular security group based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
// IDFromName is a convenience function that returns a security group's ID given its name.
diff --git a/openstack/networking/v2/extensions/security/rules/requests.go b/openstack/networking/v2/extensions/security/rules/requests.go
index 8b81d04..77f7e37 100644
--- a/openstack/networking/v2/extensions/security/rules/requests.go
+++ b/openstack/networking/v2/extensions/security/rules/requests.go
@@ -111,14 +111,17 @@
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
+ return
}
// Get retrieves a particular security group rule based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
+ return
}
// Delete will permanently delete a particular security group rule based on its unique ID.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(resourceURL(c, id), nil)
+ return
}
diff --git a/openstack/networking/v2/networks/requests.go b/openstack/networking/v2/networks/requests.go
index 31c3037..876a00b 100644
--- a/openstack/networking/v2/networks/requests.go
+++ b/openstack/networking/v2/networks/requests.go
@@ -55,6 +55,7 @@
// Get retrieves a specific network based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(getURL(c, id), &r.Body, nil)
+ return
}
// CreateOptsBuilder is the interface options structs have to satisfy in order
@@ -92,6 +93,7 @@
return
}
_, r.Err = c.Post(createURL(c), b, &r.Body, nil)
+ return
}
// UpdateOptsBuilder is the interface options structs have to satisfy in order
@@ -125,11 +127,13 @@
_, r.Err = c.Put(updateURL(c, networkID), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 201},
})
+ return
}
// Delete accepts a unique ID and deletes the network associated with it.
func Delete(c *gophercloud.ServiceClient, networkID string) (r DeleteResult) {
_, r.Err = c.Delete(deleteURL(c, networkID), nil)
+ return
}
// IDFromName is a convenience function that returns a network's ID given its name.
diff --git a/openstack/networking/v2/ports/requests.go b/openstack/networking/v2/ports/requests.go
index 261e8ad..2a53202 100644
--- a/openstack/networking/v2/ports/requests.go
+++ b/openstack/networking/v2/ports/requests.go
@@ -62,6 +62,7 @@
// Get retrieves a specific port based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(getURL(c, id), &r.Body, nil)
+ return
}
// CreateOptsBuilder is the interface options structs have to satisfy in order
@@ -100,6 +101,7 @@
return
}
_, r.Err = c.Post(createURL(c), b, &r.Body, nil)
+ return
}
// UpdateOptsBuilder is the interface options structs have to satisfy in order
@@ -137,11 +139,13 @@
_, r.Err = c.Put(updateURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 201},
})
+ return
}
// Delete accepts a unique ID and deletes the port associated with it.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(deleteURL(c, id), nil)
+ return
}
// IDFromName is a convenience function that returns a port's ID given its name.
diff --git a/openstack/networking/v2/subnets/requests.go b/openstack/networking/v2/subnets/requests.go
index 5491f3c..2706a5e 100644
--- a/openstack/networking/v2/subnets/requests.go
+++ b/openstack/networking/v2/subnets/requests.go
@@ -61,6 +61,7 @@
// Get retrieves a specific subnet based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
_, r.Err = c.Get(getURL(c, id), &r.Body, nil)
+ return
}
// IPVersion is the IP address version for the subnet. Valid instances are
@@ -109,6 +110,7 @@
return
}
_, r.Err = c.Post(createURL(c), b, &r.Body, nil)
+ return
}
// UpdateOptsBuilder allows extensions to add additional parameters to the
@@ -142,11 +144,13 @@
_, r.Err = c.Put(updateURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 201},
})
+ return
}
// Delete accepts a unique ID and deletes the subnet associated with it.
func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult) {
_, r.Err = c.Delete(deleteURL(c, id), nil)
+ return
}
// IDFromName is a convenience function that returns a subnet's ID given its name.
diff --git a/openstack/objectstorage/v1/accounts/requests.go b/openstack/objectstorage/v1/accounts/requests.go
index 57616c0..b5beef2 100644
--- a/openstack/objectstorage/v1/accounts/requests.go
+++ b/openstack/objectstorage/v1/accounts/requests.go
@@ -43,6 +43,7 @@
r.Header = resp.Header
}
r.Err = err
+ return
}
// UpdateOptsBuilder allows extensions to add additional headers to the Update
@@ -95,4 +96,5 @@
r.Header = resp.Header
}
r.Err = err
+ return
}
diff --git a/openstack/objectstorage/v1/containers/requests.go b/openstack/objectstorage/v1/containers/requests.go
index ba11916..a668673 100644
--- a/openstack/objectstorage/v1/containers/requests.go
+++ b/openstack/objectstorage/v1/containers/requests.go
@@ -109,11 +109,13 @@
r.Header = resp.Header
}
r.Err = err
+ return
}
// Delete is a function that deletes a container.
func Delete(c *gophercloud.ServiceClient, containerName string) (r DeleteResult) {
_, r.Err = c.Delete(deleteURL(c, containerName), nil)
+ return
}
// UpdateOptsBuilder allows extensions to add additional parameters to the
@@ -171,6 +173,7 @@
r.Header = resp.Header
}
r.Err = err
+ return
}
// Get is a function that retrieves the metadata of a container. To extract just
@@ -184,4 +187,5 @@
r.Header = resp.Header
}
r.Err = err
+ return
}
diff --git a/openstack/objectstorage/v1/objects/requests.go b/openstack/objectstorage/v1/objects/requests.go
index 5f8e7c1..99ad9a7 100644
--- a/openstack/objectstorage/v1/objects/requests.go
+++ b/openstack/objectstorage/v1/objects/requests.go
@@ -131,6 +131,7 @@
r.Body = resp.Body
}
r.Err = err
+ return
}
// CreateOptsBuilder allows extensions to add additional parameters to the
@@ -215,6 +216,7 @@
if resp != nil {
r.Header = resp.Header
}
+ return
}
// CopyOptsBuilder allows extensions to add additional parameters to the
@@ -267,6 +269,7 @@
r.Header = resp.Header
}
r.Err = err
+ return
}
// DeleteOptsBuilder allows extensions to add additional parameters to the
@@ -302,6 +305,7 @@
r.Header = resp.Header
}
r.Err = err
+ return
}
// GetOptsBuilder allows extensions to add additional parameters to the
@@ -341,6 +345,7 @@
r.Header = resp.Header
}
r.Err = err
+ return
}
// UpdateOptsBuilder allows extensions to add additional parameters to the
@@ -395,6 +400,7 @@
r.Header = resp.Header
}
r.Err = err
+ return
}
// HTTPMethod represents an HTTP method string (e.g. "GET").
diff --git a/openstack/orchestration/v1/buildinfo/requests.go b/openstack/orchestration/v1/buildinfo/requests.go
index f0e3ec4..32f6032 100644
--- a/openstack/orchestration/v1/buildinfo/requests.go
+++ b/openstack/orchestration/v1/buildinfo/requests.go
@@ -5,4 +5,5 @@
// Get retreives data for the given stack template.
func Get(c *gophercloud.ServiceClient) (r GetResult) {
_, r.Err = c.Get(getURL(c), &r.Body, nil)
+ return
}
diff --git a/openstack/orchestration/v1/stackevents/requests.go b/openstack/orchestration/v1/stackevents/requests.go
index c3ae4b1..e6e7f79 100644
--- a/openstack/orchestration/v1/stackevents/requests.go
+++ b/openstack/orchestration/v1/stackevents/requests.go
@@ -8,6 +8,7 @@
// Find retrieves stack events for the given stack name.
func Find(c *gophercloud.ServiceClient, stackName string) (r FindResult) {
_, r.Err = c.Get(findURL(c, stackName), &r.Body, nil)
+ return
}
// SortDir is a type for specifying in which direction to sort a list of events.
@@ -177,4 +178,5 @@
// Get retreives data for the given stack resource.
func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName, eventID string) (r GetResult) {
_, r.Err = c.Get(getURL(c, stackName, stackID, resourceName, eventID), &r.Body, nil)
+ return
}
diff --git a/openstack/orchestration/v1/stackresources/requests.go b/openstack/orchestration/v1/stackresources/requests.go
index cc4b990..f368b76 100644
--- a/openstack/orchestration/v1/stackresources/requests.go
+++ b/openstack/orchestration/v1/stackresources/requests.go
@@ -8,6 +8,7 @@
// Find retrieves stack resources for the given stack name.
func Find(c *gophercloud.ServiceClient, stackName string) (r FindResult) {
_, r.Err = c.Get(findURL(c, stackName), &r.Body, nil)
+ return
}
// ListOptsBuilder allows extensions to add additional parameters to the
@@ -47,11 +48,13 @@
// Get retreives data for the given stack resource.
func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) (r GetResult) {
_, r.Err = c.Get(getURL(c, stackName, stackID, resourceName), &r.Body, nil)
+ return
}
// Metadata retreives the metadata for the given stack resource.
func Metadata(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) (r MetadataResult) {
_, r.Err = c.Get(metadataURL(c, stackName, stackID, resourceName), &r.Body, nil)
+ return
}
// ListTypes makes a request against the API to list resource types.
@@ -64,9 +67,11 @@
// Schema retreives the schema for the given resource type.
func Schema(c *gophercloud.ServiceClient, resourceType string) (r SchemaResult) {
_, r.Err = c.Get(schemaURL(c, resourceType), &r.Body, nil)
+ return
}
// Template retreives the template representation for the given resource type.
func Template(c *gophercloud.ServiceClient, resourceType string) (r TemplateResult) {
_, r.Err = c.Get(templateURL(c, resourceType), &r.Body, nil)
+ return
}
diff --git a/openstack/orchestration/v1/stacks/requests.go b/openstack/orchestration/v1/stacks/requests.go
index 46d0f46..91f38ee 100644
--- a/openstack/orchestration/v1/stacks/requests.go
+++ b/openstack/orchestration/v1/stacks/requests.go
@@ -93,6 +93,7 @@
return
}
_, r.Err = c.Post(createURL(c), b, &r.Body, nil)
+ return
}
// AdoptOptsBuilder is the interface options structs have to satisfy in order
@@ -181,6 +182,7 @@
return
}
_, r.Err = c.Post(adoptURL(c), b, &r.Body, nil)
+ return
}
// SortDir is a type for specifying in which direction to sort a list of stacks.
@@ -252,10 +254,9 @@
}
// Get retreives a stack based on the stack name and stack ID.
-func Get(c *gophercloud.ServiceClient, stackName, stackID string) GetResult {
- var r GetResult
+func Get(c *gophercloud.ServiceClient, stackName, stackID string) (r GetResult) {
_, r.Err = c.Get(getURL(c, stackName, stackID), &r.Body, nil)
- return r
+ return
}
// UpdateOptsBuilder is the interface options structs have to satisfy in order
@@ -336,11 +337,13 @@
return
}
_, r.Err = c.Put(updateURL(c, stackName, stackID), b, nil, nil)
+ return
}
// Delete deletes a stack based on the stack name and stack ID.
func Delete(c *gophercloud.ServiceClient, stackName, stackID string) (r DeleteResult) {
_, r.Err = c.Delete(deleteURL(c, stackName, stackID), nil)
+ return
}
// PreviewOptsBuilder is the interface options structs have to satisfy in order
@@ -423,6 +426,7 @@
_, r.Err = c.Post(previewURL(c), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}
// Abandon deletes the stack with the provided stackName and stackID, but leaves its
@@ -432,4 +436,5 @@
JSONResponse: &r.Body,
OkCodes: []int{200},
})
+ return
}
diff --git a/openstack/orchestration/v1/stacktemplates/requests.go b/openstack/orchestration/v1/stacktemplates/requests.go
index 57f990f..d248c24 100644
--- a/openstack/orchestration/v1/stacktemplates/requests.go
+++ b/openstack/orchestration/v1/stacktemplates/requests.go
@@ -5,6 +5,7 @@
// Get retreives data for the given stack template.
func Get(c *gophercloud.ServiceClient, stackName, stackID string) (r GetResult) {
_, r.Err = c.Get(getURL(c, stackName, stackID), &r.Body, nil)
+ return
}
// ValidateOptsBuilder describes struct types that can be accepted by the Validate call.
@@ -34,4 +35,5 @@
_, r.Err = c.Post(validateURL(c), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
+ return
}