more error types; RequestOptsBuilder error fixes
diff --git a/errors.go b/errors.go
index 04126d8..b28be11 100644
--- a/errors.go
+++ b/errors.go
@@ -8,13 +8,13 @@
Function string
}
-func (e *BaseError) Error() string {
+func (e BaseError) Error() string {
return "An error occurred while executing a Gophercloud request."
}
// ErrInvalidInput is an error type used for most non-HTTP Gophercloud errors.
type ErrInvalidInput struct {
- *BaseError
+ BaseError
Argument string
Value interface{}
}
@@ -26,7 +26,7 @@
// ErrMissingInput is the error when input is required in a particular
// situation but not provided by the user
type ErrMissingInput struct {
- *BaseError
+ BaseError
Argument string
}
@@ -37,7 +37,7 @@
// ErrUnexpectedResponseCode is returned by the Request method when a response code other than
// those listed in OkCodes is encountered.
type ErrUnexpectedResponseCode struct {
- *BaseError
+ BaseError
URL string
Method string
Expected []int
@@ -169,7 +169,7 @@
// ErrTimeOut is the error type returned when an operations times out.
type ErrTimeOut struct {
- *BaseError
+ BaseError
}
func (e *ErrTimeOut) Error() string {
@@ -178,7 +178,7 @@
// ErrUnableToReauthenticate is the error type returned when reauthentication fails.
type ErrUnableToReauthenticate struct {
- *BaseError
+ BaseError
}
func (e *ErrUnableToReauthenticate) Error() string {
@@ -188,7 +188,7 @@
// ErrErrorAfterReauthentication is the error type returned when reauthentication
// succeeds, but an error occurs afterword (usually an HTTP error).
type ErrErrorAfterReauthentication struct {
- *BaseError
+ BaseError
}
func (e *ErrErrorAfterReauthentication) Error() string {
@@ -200,7 +200,7 @@
// factory methods like "NewComputeV2()" and can mean that a service is not
// enabled for your account.
type ErrServiceNotFound struct {
- *BaseError
+ BaseError
}
func (e *ErrServiceNotFound) Error() string {
@@ -212,7 +212,7 @@
// factory methods, and usually indicates that a region was specified
// incorrectly.
type ErrEndpointNotFound struct {
- *BaseError
+ BaseError
}
func (e *ErrEndpointNotFound) Error() string {
@@ -222,24 +222,27 @@
// ErrResourceNotFound is the error when trying to retrieve a resource's
// ID by name and the resource doesn't exist.
type ErrResourceNotFound struct {
- *BaseError
- Name string
+ BaseError
+ ID, Name string
ResourceType string
}
func (e *ErrResourceNotFound) Error() string {
- return fmt.Sprintf("Unable to find %s: %s", e.ResourceType, e.Name)
+ if e.Name != "" {
+ return fmt.Sprintf("Unable to find %s with name %s", e.ResourceType, e.Name)
+ }
+ return fmt.Sprintf("Unable to find %s with ID %s", e.ResourceType, e.ID)
}
// ErrMultipleResourcesFound is the error when trying to retrieve a resource's
// ID by name and multiple resources have the user-provided name.
type ErrMultipleResourcesFound struct {
- *BaseError
+ BaseError
Name string
Count int
ResourceType string
}
func (e *ErrMultipleResourcesFound) Error() string {
- return fmt.Sprintf("Found %d %s matching %s", e.Count, e.ResourceType, e.Name)
+ return fmt.Sprintf("Found %d %ss matching %s", e.Count, e.ResourceType, e.Name)
}
diff --git a/openstack/cdn/v1/services/requests.go b/openstack/cdn/v1/services/requests.go
index 31626ba..89ee372 100644
--- a/openstack/cdn/v1/services/requests.go
+++ b/openstack/cdn/v1/services/requests.go
@@ -350,7 +350,7 @@
reqBody[i] = patch.ToCDNServiceUpdateMap()
}
- resp, err := c.Request("PATCH", url, gophercloud.RequestOpts{
+ resp, err := c.Request("PATCH", url, &gophercloud.RequestOpts{
JSONBody: &reqBody,
OkCodes: []int{202},
})
diff --git a/openstack/client.go b/openstack/client.go
index be08be0..62e3f82 100644
--- a/openstack/client.go
+++ b/openstack/client.go
@@ -75,9 +75,9 @@
switch chosen.ID {
case v20:
- return v2auth(client, endpoint, options)
+ return v2auth(client, endpoint, options, gophercloud.EndpointOpts{})
case v30:
- return v3auth(client, endpoint, options)
+ return v3auth(client, endpoint, options, gophercloud.EndpointOpts{})
default:
// The switch statement must be out of date from the versions list.
return fmt.Errorf("Unrecognized identity version: %s", chosen.ID)
@@ -85,11 +85,11 @@
}
// AuthenticateV2 explicitly authenticates against the identity v2 endpoint.
-func AuthenticateV2(client *gophercloud.ProviderClient, options gophercloud.AuthOptions) error {
- return v2auth(client, "", options)
+func AuthenticateV2(client *gophercloud.ProviderClient, options gophercloud.AuthOptions, eo gophercloud.EndpointOpts) error {
+ return v2auth(client, "", options, eo)
}
-func v2auth(client *gophercloud.ProviderClient, endpoint string, options gophercloud.AuthOptions) error {
+func v2auth(client *gophercloud.ProviderClient, endpoint string, options gophercloud.AuthOptions, eo gophercloud.EndpointOpts) error {
v2Client, err := NewIdentityV2(client, eo)
if err != nil {
return err
@@ -114,7 +114,7 @@
if options.AllowReauth {
client.ReauthFunc = func() error {
client.TokenID = ""
- return v2auth(client, endpoint, options)
+ return v2auth(client, endpoint, options, eo)
}
}
client.TokenID = token.ID
@@ -126,11 +126,11 @@
}
// AuthenticateV3 explicitly authenticates against the identity v3 service.
-func AuthenticateV3(client *gophercloud.ProviderClient, options gophercloud.AuthOptions) error {
- return v3auth(client, "", options)
+func AuthenticateV3(client *gophercloud.ProviderClient, options gophercloud.AuthOptions, eo gophercloud.EndpointOpts) error {
+ return v3auth(client, "", options, eo)
}
-func v3auth(client *gophercloud.ProviderClient, endpoint string, options gophercloud.AuthOptions) error {
+func v3auth(client *gophercloud.ProviderClient, endpoint string, options gophercloud.AuthOptions, eo gophercloud.EndpointOpts) error {
// Override the generated service endpoint with the one returned by the version endpoint.
v3Client, err := NewIdentityV3(client, eo)
if err != nil {
@@ -176,7 +176,7 @@
if options.AllowReauth {
client.ReauthFunc = func() error {
client.TokenID = ""
- return v3auth(client, endpoint, options)
+ return v3auth(client, endpoint, options, eo)
}
}
client.EndpointLocator = func(opts gophercloud.EndpointOpts) (string, error) {
@@ -189,20 +189,36 @@
// NewIdentityV2 creates a ServiceClient that may be used to interact with the v2 identity service.
func NewIdentityV2(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
v2Endpoint := client.IdentityBase + "v2.0/"
+ /*
+ eo.ApplyDefaults("identity")
+ url, err := client.EndpointLocator(eo)
+ if err != nil {
+ return nil, err
+ }
+ */
return &gophercloud.ServiceClient{
ProviderClient: client,
Endpoint: v2Endpoint,
+ //Endpoint: url,
}, nil
}
// NewIdentityV3 creates a ServiceClient that may be used to access the v3 identity service.
func NewIdentityV3(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
v3Endpoint := client.IdentityBase + "v3/"
+ /*
+ eo.ApplyDefaults("identity")
+ url, err := client.EndpointLocator(eo)
+ if err != nil {
+ return nil, err
+ }
+ */
return &gophercloud.ServiceClient{
ProviderClient: client,
Endpoint: v3Endpoint,
+ //Endpoint: url,
}, nil
}
diff --git a/openstack/compute/v2/servers/errors.go b/openstack/compute/v2/servers/errors.go
new file mode 100644
index 0000000..ebfcdcd
--- /dev/null
+++ b/openstack/compute/v2/servers/errors.go
@@ -0,0 +1,65 @@
+package servers
+
+import (
+ "fmt"
+
+ "github.com/gophercloud/gophercloud"
+)
+
+// ErrNeitherImageIDNorImageNameProvided is the error when neither the image
+// ID nor the image name is provided for a server operation
+type ErrNeitherImageIDNorImageNameProvided struct{ *gophercloud.ErrMissingInput }
+
+func (e ErrNeitherImageIDNorImageNameProvided) Error() string {
+ return "One and only one of the image ID and the image name must be provided."
+}
+
+// ErrNeitherFlavorIDNorFlavorNameProvided is the error when neither the flavor
+// ID nor the flavor name is provided for a server operation
+type ErrNeitherFlavorIDNorFlavorNameProvided struct{ *gophercloud.ErrMissingInput }
+
+func (e ErrNeitherFlavorIDNorFlavorNameProvided) Error() string {
+ return "One and only one of the flavor ID and the flavor name must be provided."
+}
+
+// ErrInvalidHowParameterProvided is the error when an unknown value is given
+// for the `how` argument
+type ErrInvalidHowParameterProvided struct{ *gophercloud.ErrInvalidInput }
+
+// ErrNoAdminPassProvided is the error when an administrative password isn't
+// provided for a server operation
+type ErrNoAdminPassProvided struct{ *gophercloud.ErrMissingInput }
+
+// ErrNoImageIDProvided is the error when an image ID isn't provided for a server
+// operation
+type ErrNoImageIDProvided struct{ *gophercloud.ErrMissingInput }
+
+// ErrNoIDProvided is the error when a server ID isn't provided for a server
+// operation
+type ErrNoIDProvided struct{ *gophercloud.ErrMissingInput }
+
+// ErrServer is a generic error type for servers HTTP operations.
+type ErrServer struct {
+ *gophercloud.ErrUnexpectedResponseCode
+ ID string
+}
+
+func (se *ErrServer) Error() string {
+ return fmt.Sprintf("Error while executing HTTP request for server [%s]", se.ID)
+}
+
+// Error404 overrides the generic 404 error message.
+func (se *ErrServer) Error404(e *gophercloud.ErrUnexpectedResponseCode) error {
+ se.ErrUnexpectedResponseCode = e
+ return &ErrServerNotFound{se}
+}
+
+// ErrServerNotFound is the error when a 404 is received during server HTTP
+// operations.
+type ErrServerNotFound struct {
+ *ErrServer
+}
+
+func (e *ErrServerNotFound) Error() string {
+ return fmt.Sprintf("I couldn't find server [%s]", e.ID)
+}
diff --git a/openstack/compute/v2/servers/requests.go b/openstack/compute/v2/servers/requests.go
index 06db312..c6d3a8e 100644
--- a/openstack/compute/v2/servers/requests.go
+++ b/openstack/compute/v2/servers/requests.go
@@ -759,7 +759,7 @@
// Metadatum requests the key-value pair with the given key for the given server ID.
func Metadatum(client *gophercloud.ServiceClient, id, key string) GetMetadatumResult {
var res GetMetadatumResult
- _, res.Err = client.Request("GET", metadatumURL(client, id, key), gophercloud.RequestOpts{
+ _, res.Err = client.Request("GET", metadatumURL(client, id, key), &gophercloud.RequestOpts{
JSONResponse: &res.Body,
})
return res
diff --git a/openstack/db/v1/configurations/requests.go b/openstack/db/v1/configurations/requests.go
index 818f443..035ff29 100644
--- a/openstack/db/v1/configurations/requests.go
+++ b/openstack/db/v1/configurations/requests.go
@@ -103,7 +103,7 @@
return res
}
- _, res.Err = client.Request("POST", baseURL(client), gophercloud.RequestOpts{
+ _, res.Err = client.Request("POST", baseURL(client), &gophercloud.RequestOpts{
OkCodes: []int{200},
JSONBody: &reqBody,
JSONResponse: &res.Body,
@@ -116,7 +116,7 @@
func Get(client *gophercloud.ServiceClient, configID string) GetResult {
var res GetResult
- _, res.Err = client.Request("GET", resourceURL(client, configID), gophercloud.RequestOpts{
+ _, res.Err = client.Request("GET", resourceURL(client, configID), &gophercloud.RequestOpts{
OkCodes: []int{200},
JSONResponse: &res.Body,
})
@@ -186,7 +186,7 @@
return res
}
- _, res.Err = client.Request("PATCH", resourceURL(client, configID), gophercloud.RequestOpts{
+ _, res.Err = client.Request("PATCH", resourceURL(client, configID), &gophercloud.RequestOpts{
OkCodes: []int{200},
JSONBody: &reqBody,
})
@@ -206,7 +206,7 @@
return res
}
- _, res.Err = client.Request("PUT", resourceURL(client, configID), gophercloud.RequestOpts{
+ _, res.Err = client.Request("PUT", resourceURL(client, configID), &gophercloud.RequestOpts{
OkCodes: []int{202},
JSONBody: &reqBody,
})
@@ -220,7 +220,7 @@
func Delete(client *gophercloud.ServiceClient, configID string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", resourceURL(client, configID), gophercloud.RequestOpts{
+ _, res.Err = client.Request("DELETE", resourceURL(client, configID), &gophercloud.RequestOpts{
OkCodes: []int{202},
})
@@ -256,7 +256,7 @@
func GetDatastoreParam(client *gophercloud.ServiceClient, datastoreID, versionID, paramID string) ParamResult {
var res ParamResult
- _, res.Err = client.Request("GET", getDSParamURL(client, datastoreID, versionID, paramID), gophercloud.RequestOpts{
+ _, res.Err = client.Request("GET", getDSParamURL(client, datastoreID, versionID, paramID), &gophercloud.RequestOpts{
OkCodes: []int{200},
JSONResponse: &res.Body,
})
@@ -278,7 +278,7 @@
func GetGlobalParam(client *gophercloud.ServiceClient, versionID, paramID string) ParamResult {
var res ParamResult
- _, res.Err = client.Request("GET", getGlobalParamURL(client, versionID, paramID), gophercloud.RequestOpts{
+ _, res.Err = client.Request("GET", getGlobalParamURL(client, versionID, paramID), &gophercloud.RequestOpts{
OkCodes: []int{200},
JSONResponse: &res.Body,
})
diff --git a/openstack/db/v1/databases/requests.go b/openstack/db/v1/databases/requests.go
index 26bca04..ff57245 100644
--- a/openstack/db/v1/databases/requests.go
+++ b/openstack/db/v1/databases/requests.go
@@ -83,7 +83,7 @@
return res
}
- _, res.Err = client.Request("POST", baseURL(client, instanceID), gophercloud.RequestOpts{
+ _, res.Err = client.Request("POST", baseURL(client, instanceID), &gophercloud.RequestOpts{
JSONBody: &reqBody,
OkCodes: []int{202},
})
@@ -107,7 +107,7 @@
func Delete(client *gophercloud.ServiceClient, instanceID, dbName string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", dbURL(client, instanceID, dbName), gophercloud.RequestOpts{
+ _, res.Err = client.Request("DELETE", dbURL(client, instanceID, dbName), &gophercloud.RequestOpts{
OkCodes: []int{202},
})
diff --git a/openstack/db/v1/datastores/requests.go b/openstack/db/v1/datastores/requests.go
index b7188c4..277c797 100644
--- a/openstack/db/v1/datastores/requests.go
+++ b/openstack/db/v1/datastores/requests.go
@@ -17,7 +17,7 @@
func Get(client *gophercloud.ServiceClient, datastoreID string) GetResult {
var res GetResult
- _, res.Err = client.Request("GET", resourceURL(client, datastoreID), gophercloud.RequestOpts{
+ _, res.Err = client.Request("GET", resourceURL(client, datastoreID), &gophercloud.RequestOpts{
OkCodes: []int{200},
JSONResponse: &res.Body,
})
@@ -38,7 +38,7 @@
func GetVersion(client *gophercloud.ServiceClient, datastoreID, versionID string) GetVersionResult {
var res GetVersionResult
- _, res.Err = client.Request("GET", versionURL(client, datastoreID, versionID), gophercloud.RequestOpts{
+ _, res.Err = client.Request("GET", versionURL(client, datastoreID, versionID), &gophercloud.RequestOpts{
OkCodes: []int{200},
JSONResponse: &res.Body,
})
diff --git a/openstack/db/v1/flavors/requests.go b/openstack/db/v1/flavors/requests.go
index 6eb598b..c767606 100644
--- a/openstack/db/v1/flavors/requests.go
+++ b/openstack/db/v1/flavors/requests.go
@@ -20,7 +20,7 @@
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var gr GetResult
- _, gr.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
+ _, gr.Err = client.Request("GET", getURL(client, id), &gophercloud.RequestOpts{
JSONResponse: &gr.Body,
OkCodes: []int{200},
})
diff --git a/openstack/db/v1/instances/requests.go b/openstack/db/v1/instances/requests.go
index 35b9f9a..7714a21 100644
--- a/openstack/db/v1/instances/requests.go
+++ b/openstack/db/v1/instances/requests.go
@@ -104,7 +104,7 @@
return res
}
- _, res.Err = client.Request("POST", baseURL(client), gophercloud.RequestOpts{
+ _, res.Err = client.Request("POST", baseURL(client), &gophercloud.RequestOpts{
JSONBody: &reqBody,
JSONResponse: &res.Body,
OkCodes: []int{200},
@@ -126,7 +126,7 @@
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var res GetResult
- _, res.Err = client.Request("GET", resourceURL(client, id), gophercloud.RequestOpts{
+ _, res.Err = client.Request("GET", resourceURL(client, id), &gophercloud.RequestOpts{
JSONResponse: &res.Body,
OkCodes: []int{200},
})
@@ -138,7 +138,7 @@
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", resourceURL(client, id), gophercloud.RequestOpts{
+ _, res.Err = client.Request("DELETE", resourceURL(client, id), &gophercloud.RequestOpts{
OkCodes: []int{202},
})
@@ -150,7 +150,7 @@
func EnableRootUser(client *gophercloud.ServiceClient, id string) UserRootResult {
var res UserRootResult
- _, res.Err = client.Request("POST", userRootURL(client, id), gophercloud.RequestOpts{
+ _, res.Err = client.Request("POST", userRootURL(client, id), &gophercloud.RequestOpts{
JSONResponse: &res.Body,
OkCodes: []int{200},
})
@@ -164,7 +164,7 @@
func IsRootEnabled(client *gophercloud.ServiceClient, id string) (bool, error) {
var res gophercloud.Result
- _, err := client.Request("GET", userRootURL(client, id), gophercloud.RequestOpts{
+ _, err := client.Request("GET", userRootURL(client, id), &gophercloud.RequestOpts{
JSONResponse: &res.Body,
OkCodes: []int{200},
})
@@ -178,7 +178,7 @@
func Restart(client *gophercloud.ServiceClient, id string) ActionResult {
var res ActionResult
- _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
+ _, res.Err = client.Request("POST", actionURL(client, id), &gophercloud.RequestOpts{
JSONBody: map[string]interface{}{"restart": struct{}{}},
OkCodes: []int{202},
})
@@ -201,7 +201,7 @@
reqBody := req{Resize: resize{FlavorRef: flavorRef}}
- _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
+ _, res.Err = client.Request("POST", actionURL(client, id), &gophercloud.RequestOpts{
JSONBody: reqBody,
OkCodes: []int{202},
})
@@ -229,7 +229,7 @@
reqBody := req{Resize: resize{Volume: volume{Size: size}}}
- _, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
+ _, res.Err = client.Request("POST", actionURL(client, id), &gophercloud.RequestOpts{
JSONBody: reqBody,
OkCodes: []int{202},
})
diff --git a/openstack/db/v1/users/requests.go b/openstack/db/v1/users/requests.go
index acf0a13..8f86297 100644
--- a/openstack/db/v1/users/requests.go
+++ b/openstack/db/v1/users/requests.go
@@ -101,7 +101,7 @@
return res
}
- _, res.Err = client.Request("POST", baseURL(client, instanceID), gophercloud.RequestOpts{
+ _, res.Err = client.Request("POST", baseURL(client, instanceID), &gophercloud.RequestOpts{
JSONBody: &reqBody,
OkCodes: []int{202},
})
@@ -124,7 +124,7 @@
func Delete(client *gophercloud.ServiceClient, instanceID, userName string) DeleteResult {
var res DeleteResult
- _, res.Err = client.Request("DELETE", userURL(client, instanceID, userName), gophercloud.RequestOpts{
+ _, res.Err = client.Request("DELETE", userURL(client, instanceID, userName), &gophercloud.RequestOpts{
OkCodes: []int{202},
})
diff --git a/openstack/endpoint_location.go b/openstack/endpoint_location.go
index 70f6800..a14f989 100644
--- a/openstack/endpoint_location.go
+++ b/openstack/endpoint_location.go
@@ -77,6 +77,7 @@
err.Function = "openstack.V3EndpointURL"
err.Argument = "Availability"
err.Value = opts.Availability
+ return "", err
}
if (opts.Availability == gophercloud.Availability(endpoint.Interface)) &&
(opts.Region == "" || endpoint.Region == opts.Region) {
diff --git a/openstack/errors.go b/openstack/errors.go
index 8467200..8e4cbac 100644
--- a/openstack/errors.go
+++ b/openstack/errors.go
@@ -10,7 +10,7 @@
// ErrEndpointNotFound is the error when no suitable endpoint can be found
// in the user's catalog
-type ErrEndpointNotFound struct{ *gophercloud.BaseError }
+type ErrEndpointNotFound struct{ gophercloud.BaseError }
func (e ErrEndpointNotFound) Error() string {
return "No suitable endpoint could be found in the service catalog."
@@ -18,16 +18,16 @@
// ErrInvalidAvailabilityProvided is the error when an invalid endpoint
// availability is provided
-type ErrInvalidAvailabilityProvided struct{ *gophercloud.ErrInvalidInput }
+type ErrInvalidAvailabilityProvided struct{ gophercloud.ErrInvalidInput }
func (e ErrInvalidAvailabilityProvided) Error() string {
- return "Unexpected availability in endpoint query"
+ return fmt.Sprintf("Unexpected availability in endpoint query: %s", e.Value)
}
// ErrMultipleMatchingEndpointsV2 is the error when more than one endpoint
// for the given options is found in the v2 catalog
type ErrMultipleMatchingEndpointsV2 struct {
- *gophercloud.BaseError
+ gophercloud.BaseError
Endpoints []tokens2.Endpoint
}
@@ -38,7 +38,7 @@
// ErrMultipleMatchingEndpointsV3 is the error when more than one endpoint
// for the given options is found in the v3 catalog
type ErrMultipleMatchingEndpointsV3 struct {
- *gophercloud.BaseError
+ gophercloud.BaseError
Endpoints []tokens3.Endpoint
}
@@ -48,7 +48,7 @@
// ErrNoAuthURL is the error when the OS_AUTH_URL environment variable is not
// found
-type ErrNoAuthURL struct{ *gophercloud.ErrInvalidInput }
+type ErrNoAuthURL struct{ gophercloud.ErrInvalidInput }
func (e *ErrNoAuthURL) Error() string {
return "Environment variable OS_AUTH_URL needs to be set."
@@ -56,7 +56,7 @@
// ErrNoUsername is the error when the OS_USERNAME environment variable is not
// found
-type ErrNoUsername struct{ *gophercloud.ErrInvalidInput }
+type ErrNoUsername struct{ gophercloud.ErrInvalidInput }
func (e *ErrNoUsername) Error() string {
return "Environment variable OS_USERNAME needs to be set."
@@ -64,7 +64,7 @@
// ErrNoPassword is the error when the OS_PASSWORD environment variable is not
// found
-type ErrNoPassword struct{ *gophercloud.ErrInvalidInput }
+type ErrNoPassword struct{ gophercloud.ErrInvalidInput }
func (e *ErrNoPassword) Error() string {
return "Environment variable OS_PASSWORD needs to be set."
diff --git a/openstack/identity/v3/endpoints/requests.go b/openstack/identity/v3/endpoints/requests.go
index 5093d1a..c9b8cf5 100644
--- a/openstack/identity/v3/endpoints/requests.go
+++ b/openstack/identity/v3/endpoints/requests.go
@@ -107,7 +107,7 @@
reqBody.Endpoint.ServiceID = gophercloud.MaybeString(opts.ServiceID)
var result UpdateResult
- _, result.Err = client.Request("PATCH", endpointURL(client, endpointID), gophercloud.RequestOpts{
+ _, result.Err = client.Request("PATCH", endpointURL(client, endpointID), &gophercloud.RequestOpts{
JSONBody: &reqBody,
JSONResponse: &result.Body,
OkCodes: []int{200},
diff --git a/openstack/identity/v3/services/requests.go b/openstack/identity/v3/services/requests.go
index 68d008b..484afab 100644
--- a/openstack/identity/v3/services/requests.go
+++ b/openstack/identity/v3/services/requests.go
@@ -60,7 +60,7 @@
req := request{Type: serviceType}
var result UpdateResult
- _, result.Err = client.Request("PATCH", serviceURL(client, serviceID), gophercloud.RequestOpts{
+ _, result.Err = client.Request("PATCH", serviceURL(client, serviceID), &gophercloud.RequestOpts{
JSONBody: &req,
JSONResponse: &result.Body,
OkCodes: []int{200},
diff --git a/openstack/identity/v3/tokens/requests.go b/openstack/identity/v3/tokens/requests.go
index 39dede0..4b87311 100644
--- a/openstack/identity/v3/tokens/requests.go
+++ b/openstack/identity/v3/tokens/requests.go
@@ -260,7 +260,7 @@
// 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{
+ response, err := c.Request("HEAD", tokenURL(c), &gophercloud.RequestOpts{
MoreHeaders: subjectTokenHeaders(c, token),
OkCodes: []int{204, 404},
})
diff --git a/openstack/objectstorage/v1/accounts/requests.go b/openstack/objectstorage/v1/accounts/requests.go
index 57d6a6d..f50cf97 100644
--- a/openstack/objectstorage/v1/accounts/requests.go
+++ b/openstack/objectstorage/v1/accounts/requests.go
@@ -39,7 +39,7 @@
}
}
- resp, err := c.Request("HEAD", getURL(c), gophercloud.RequestOpts{
+ resp, err := c.Request("HEAD", getURL(c), &gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{204},
})
@@ -95,7 +95,7 @@
}
}
- resp, err := c.Request("POST", updateURL(c), gophercloud.RequestOpts{
+ resp, err := c.Request("POST", updateURL(c), &gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201, 202, 204},
})
diff --git a/openstack/objectstorage/v1/containers/requests.go b/openstack/objectstorage/v1/containers/requests.go
index c20d009..b2160c3 100644
--- a/openstack/objectstorage/v1/containers/requests.go
+++ b/openstack/objectstorage/v1/containers/requests.go
@@ -110,7 +110,7 @@
}
}
- resp, err := c.Request("PUT", createURL(c, containerName), gophercloud.RequestOpts{
+ resp, err := c.Request("PUT", createURL(c, containerName), &gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201, 202, 204},
})
@@ -178,7 +178,7 @@
}
}
- resp, err := c.Request("POST", updateURL(c, containerName), gophercloud.RequestOpts{
+ resp, err := c.Request("POST", updateURL(c, containerName), &gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201, 202, 204},
})
@@ -194,7 +194,7 @@
// function.
func Get(c *gophercloud.ServiceClient, containerName string) GetResult {
var res GetResult
- resp, err := c.Request("HEAD", getURL(c, containerName), gophercloud.RequestOpts{
+ resp, err := c.Request("HEAD", getURL(c, containerName), &gophercloud.RequestOpts{
OkCodes: []int{200, 204},
})
if resp != nil {
diff --git a/openstack/objectstorage/v1/objects/requests.go b/openstack/objectstorage/v1/objects/requests.go
index a2c1f85..9a6da58 100644
--- a/openstack/objectstorage/v1/objects/requests.go
+++ b/openstack/objectstorage/v1/objects/requests.go
@@ -133,7 +133,7 @@
url += query
}
- resp, err := c.Request("GET", url, gophercloud.RequestOpts{
+ resp, err := c.Request("GET", url, &gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{200, 304},
})
@@ -226,7 +226,7 @@
return res
}
- ropts := gophercloud.RequestOpts{
+ ropts := &gophercloud.RequestOpts{
RawBody: content,
MoreHeaders: h,
}
@@ -295,7 +295,7 @@
}
url := copyURL(c, containerName, objectName)
- resp, err := c.Request("COPY", url, gophercloud.RequestOpts{
+ resp, err := c.Request("COPY", url, &gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201},
})
@@ -384,7 +384,7 @@
url += query
}
- resp, err := c.Request("HEAD", url, gophercloud.RequestOpts{
+ resp, err := c.Request("HEAD", url, &gophercloud.RequestOpts{
OkCodes: []int{200, 204},
})
if resp != nil {
@@ -442,7 +442,7 @@
}
url := updateURL(c, containerName, objectName)
- resp, err := c.Request("POST", url, gophercloud.RequestOpts{
+ resp, err := c.Request("POST", url, &gophercloud.RequestOpts{
MoreHeaders: h,
})
if resp != nil {
diff --git a/openstack/orchestration/v1/stackevents/requests.go b/openstack/orchestration/v1/stackevents/requests.go
index bd1a24a..6112571 100644
--- a/openstack/orchestration/v1/stackevents/requests.go
+++ b/openstack/orchestration/v1/stackevents/requests.go
@@ -9,7 +9,7 @@
func Find(c *gophercloud.ServiceClient, stackName string) FindResult {
var res FindResult
- _, res.Err = c.Request("GET", findURL(c, stackName), gophercloud.RequestOpts{
+ _, res.Err = c.Request("GET", findURL(c, stackName), &gophercloud.RequestOpts{
JSONResponse: &res.Body,
})
return res
diff --git a/openstack/orchestration/v1/stackresources/requests.go b/openstack/orchestration/v1/stackresources/requests.go
index e8debdd..3ce40eb 100644
--- a/openstack/orchestration/v1/stackresources/requests.go
+++ b/openstack/orchestration/v1/stackresources/requests.go
@@ -10,7 +10,7 @@
var res FindResult
// Send request to API
- _, res.Err = c.Request("GET", findURL(c, stackName), gophercloud.RequestOpts{
+ _, res.Err = c.Request("GET", findURL(c, stackName), &gophercloud.RequestOpts{
JSONResponse: &res.Body,
})
return res
diff --git a/openstack/orchestration/v1/stacktemplates/requests.go b/openstack/orchestration/v1/stacktemplates/requests.go
index 090fa2c..a4687ef 100644
--- a/openstack/orchestration/v1/stacktemplates/requests.go
+++ b/openstack/orchestration/v1/stacktemplates/requests.go
@@ -9,7 +9,7 @@
// Get retreives data for the given stack template.
func Get(c *gophercloud.ServiceClient, stackName, stackID string) GetResult {
var res GetResult
- _, res.Err = c.Request("GET", getURL(c, stackName, stackID), gophercloud.RequestOpts{
+ _, res.Err = c.Request("GET", getURL(c, stackName, stackID), &gophercloud.RequestOpts{
JSONResponse: &res.Body,
})
return res
diff --git a/openstack/utils/choose_version.go b/openstack/utils/choose_version.go
index caeaf63..c605d08 100644
--- a/openstack/utils/choose_version.go
+++ b/openstack/utils/choose_version.go
@@ -59,7 +59,7 @@
}
var resp response
- _, err := client.Request("GET", client.IdentityBase, gophercloud.RequestOpts{
+ _, err := client.Request("GET", client.IdentityBase, &gophercloud.RequestOpts{
JSONResponse: &resp,
OkCodes: []int{200, 300},
})
diff --git a/pagination/http.go b/pagination/http.go
index db31b55..9ac2372 100644
--- a/pagination/http.go
+++ b/pagination/http.go
@@ -53,7 +53,7 @@
// Request performs an HTTP request and extracts the http.Response from the result.
func Request(client *gophercloud.ServiceClient, headers map[string]string, url string) (*http.Response, error) {
- return client.Request("GET", url, gophercloud.RequestOpts{
+ return client.Request("GET", url, &gophercloud.RequestOpts{
MoreHeaders: headers,
OkCodes: []int{200, 204},
})
diff --git a/results.go b/results.go
index 1a3aaa4..2b7e01f 100644
--- a/results.go
+++ b/results.go
@@ -48,8 +48,7 @@
if readCloser, ok := reader.(io.Closer); ok {
defer readCloser.Close()
}
- jsonDecoder := json.NewDecoder(reader)
- return jsonDecoder.Decode(to)
+ return json.NewDecoder(reader).Decode(to)
}
b, err := json.Marshal(r.Body)