parent
326f0cfa2f
commit
5c292c61c6
1437 changed files with 208886 additions and 87131 deletions
1587
vendor/github.com/gophercloud/gophercloud/CHANGELOG.md
generated
vendored
1587
vendor/github.com/gophercloud/gophercloud/CHANGELOG.md
generated
vendored
File diff suppressed because it is too large
Load diff
135
vendor/github.com/gophercloud/gophercloud/README.md
generated
vendored
135
vendor/github.com/gophercloud/gophercloud/README.md
generated
vendored
|
|
@ -13,7 +13,7 @@ Gophercloud is an OpenStack Go SDK.
|
|||
|
||||
Reference a Gophercloud package in your code:
|
||||
|
||||
```Go
|
||||
```go
|
||||
import "github.com/gophercloud/gophercloud"
|
||||
```
|
||||
|
||||
|
|
@ -28,43 +28,79 @@ go mod tidy
|
|||
### Credentials
|
||||
|
||||
Because you'll be hitting an API, you will need to retrieve your OpenStack
|
||||
credentials and either store them as environment variables or in your local Go
|
||||
files. The first method is recommended because it decouples credential
|
||||
information from source code, allowing you to push the latter to your version
|
||||
control system without any security risk.
|
||||
credentials and either store them in a `clouds.yaml` file, as environment
|
||||
variables, or in your local Go files. The first method is recommended because
|
||||
it decouples credential information from source code, allowing you to push the
|
||||
latter to your version control system without any security risk.
|
||||
|
||||
You will need to retrieve the following:
|
||||
|
||||
* username
|
||||
* password
|
||||
* a valid Keystone identity URL
|
||||
* A valid Keystone identity URL
|
||||
* Credentials. These can be a username/password combo, a set of Application
|
||||
Credentials, a pre-generated token, or any other supported authentication
|
||||
mechanism.
|
||||
|
||||
For users that have the OpenStack dashboard installed, there's a shortcut. If
|
||||
you visit the `project/access_and_security` path in Horizon and click on the
|
||||
"Download OpenStack RC File" button at the top right hand corner, you will
|
||||
download a bash file that exports all of your access details to environment
|
||||
variables. To execute the file, run `source admin-openrc.sh` and you will be
|
||||
prompted for your password.
|
||||
you visit the `project/api_access` path in Horizon and click on the
|
||||
"Download OpenStack RC File" button at the top right hand corner, you can
|
||||
download either a `clouds.yaml` file or an `openrc` bash file that exports all
|
||||
of your access details to environment variables. To use the `clouds.yaml` file,
|
||||
place it at `~/.config/openstack/clouds.yaml`. To use the `openrc` file, run
|
||||
`source openrc` and you will be prompted for your password.
|
||||
|
||||
### Authentication
|
||||
|
||||
> NOTE: It is now recommended to use the `clientconfig` package found at
|
||||
> https://github.com/gophercloud/utils/tree/master/openstack/clientconfig
|
||||
> for all authentication purposes.
|
||||
>
|
||||
> The below documentation is still relevant. clientconfig simply implements
|
||||
> the below and presents it in an easier and more flexible way.
|
||||
|
||||
Once you have access to your credentials, you can begin plugging them into
|
||||
Gophercloud. The next step is authentication, and this is handled by a base
|
||||
"Provider" struct. To get one, you can either pass in your credentials
|
||||
explicitly, or tell Gophercloud to use environment variables:
|
||||
Gophercloud. The next step is authentication, which is handled by a base
|
||||
"Provider" struct. There are number of ways to construct such a struct.
|
||||
|
||||
**With `gophercloud/utils`**
|
||||
|
||||
The [github.com/gophercloud/utils](https://github.com/gophercloud/utils)
|
||||
library provides the `clientconfig` package to simplify authentication. It
|
||||
provides additional functionality, such as the ability to read `clouds.yaml`
|
||||
files. To generate a "Provider" struct using the `clientconfig` package:
|
||||
|
||||
```go
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/openstack"
|
||||
"github.com/gophercloud/gophercloud/openstack/utils"
|
||||
"github.com/gophercloud/utils/openstack/clientconfig"
|
||||
)
|
||||
|
||||
// You can also skip configuring this and instead set 'OS_CLOUD' in your
|
||||
// environment
|
||||
opts := new(clientconfig.ClientOpts)
|
||||
opts.Cloud = "devstack-admin"
|
||||
|
||||
provider, err := clientconfig.AuthenticatedClient(opts)
|
||||
```
|
||||
|
||||
A provider client is a top-level client that all of your OpenStack service
|
||||
clients derive from. The provider contains all of the authentication details
|
||||
that allow your Go code to access the API - such as the base URL and token ID.
|
||||
|
||||
Once we have a base Provider, we inject it as a dependency into each OpenStack
|
||||
service. For example, in order to work with the Compute API, we need a Compute
|
||||
service client. This can be created like so:
|
||||
|
||||
```go
|
||||
client, err := clientconfig.NewServiceClient("compute", opts)
|
||||
```
|
||||
|
||||
**Without `gophercloud/utils`**
|
||||
|
||||
> *Note*
|
||||
> gophercloud doesn't provide support for `clouds.yaml` file so you need to
|
||||
> implement this functionality yourself if you don't wish to use
|
||||
> `gophercloud/utils`.
|
||||
|
||||
You can also generate a "Provider" struct without using the `clientconfig`
|
||||
package from `gophercloud/utils`. To do this, you can either pass in your
|
||||
credentials explicitly or tell Gophercloud to use environment variables:
|
||||
|
||||
```go
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
"github.com/gophercloud/gophercloud/openstack"
|
||||
)
|
||||
|
||||
// Option 1: Pass in the values yourself
|
||||
|
|
@ -85,34 +121,29 @@ Once you have the `opts` variable, you can pass it in and get back a
|
|||
provider, err := openstack.AuthenticatedClient(opts)
|
||||
```
|
||||
|
||||
The `ProviderClient` is the top-level client that all of your OpenStack services
|
||||
derive from. The provider contains all of the authentication details that allow
|
||||
your Go code to access the API - such as the base URL and token ID.
|
||||
|
||||
### Provision a server
|
||||
|
||||
Once we have a base Provider, we inject it as a dependency into each OpenStack
|
||||
service. In order to work with the Compute API, we need a Compute service
|
||||
client; which can be created like so:
|
||||
As above, you can then use this provider client to generate a service client
|
||||
for a particular OpenStack service:
|
||||
|
||||
```go
|
||||
client, err := openstack.NewComputeV2(provider, gophercloud.EndpointOpts{
|
||||
Region: os.Getenv("OS_REGION_NAME"),
|
||||
Region: os.Getenv("OS_REGION_NAME"),
|
||||
})
|
||||
```
|
||||
|
||||
We then use this `client` for any Compute API operation we want. In our case,
|
||||
we want to provision a new server - so we invoke the `Create` method and pass
|
||||
in the flavor ID (hardware specification) and image ID (operating system) we're
|
||||
interested in:
|
||||
### Provision a server
|
||||
|
||||
We can use the Compute service client generated above for any Compute API
|
||||
operation we want. In our case, we want to provision a new server. To do this,
|
||||
we invoke the `Create` method and pass in the flavor ID (hardware
|
||||
specification) and image ID (operating system) we're interested in:
|
||||
|
||||
```go
|
||||
import "github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
|
||||
|
||||
server, err := servers.Create(client, servers.CreateOpts{
|
||||
Name: "My new server!",
|
||||
FlavorRef: "flavor_id",
|
||||
ImageRef: "image_id",
|
||||
Name: "My new server!",
|
||||
FlavorRef: "flavor_id",
|
||||
ImageRef: "image_id",
|
||||
}).Extract()
|
||||
```
|
||||
|
||||
|
|
@ -130,6 +161,8 @@ Gophercloud versioning follows [semver](https://semver.org/spec/v2.0.0.html).
|
|||
|
||||
Before `v1.0.0`, there were no guarantees. Starting with v1, there will be no breaking changes within a major release.
|
||||
|
||||
See the [Release instructions](./RELEASE.md).
|
||||
|
||||
## Contributing
|
||||
|
||||
See the [contributing guide](./.github/CONTRIBUTING.md).
|
||||
|
|
@ -138,19 +171,3 @@ See the [contributing guide](./.github/CONTRIBUTING.md).
|
|||
|
||||
If you're struggling with something or have spotted a potential bug, feel free
|
||||
to submit an issue to our [bug tracker](https://github.com/gophercloud/gophercloud/issues).
|
||||
|
||||
## Thank You
|
||||
|
||||
We'd like to extend special thanks and appreciation to the following:
|
||||
|
||||
### OpenLab
|
||||
|
||||
<a href="http://openlabtesting.org/"><img src="./docs/assets/openlab.png" width="600px"></a>
|
||||
|
||||
OpenLab is providing a full CI environment to test each PR and merge for a variety of OpenStack releases.
|
||||
|
||||
### VEXXHOST
|
||||
|
||||
<a href="https://vexxhost.com/"><img src="./docs/assets/vexxhost.png" width="600px"></a>
|
||||
|
||||
VEXXHOST is providing their services to assist with the development and testing of Gophercloud.
|
||||
|
|
|
|||
79
vendor/github.com/gophercloud/gophercloud/RELEASE.md
generated
vendored
Normal file
79
vendor/github.com/gophercloud/gophercloud/RELEASE.md
generated
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# Gophercloud release
|
||||
|
||||
## Contributions
|
||||
|
||||
### The semver label
|
||||
|
||||
Gophercloud follows [semver](https://semver.org/).
|
||||
|
||||
Each Pull request must have a label indicating its impact on the API:
|
||||
* `semver:patch` for changes that don't impact the API
|
||||
* `semver:minor` for changes that impact the API in a backwards-compatible fashion
|
||||
* `semver:major` for changes that introduce a breaking change in the API
|
||||
|
||||
Automation prevents merges if the label is not present.
|
||||
|
||||
### Metadata
|
||||
|
||||
The release notes for a given release are generated based on the PR title: make
|
||||
sure that the PR title is descriptive.
|
||||
|
||||
## Release of a new version
|
||||
|
||||
Requirements:
|
||||
* [`gh`](https://github.com/cli/cli)
|
||||
* [`jq`](https://stedolan.github.io/jq/)
|
||||
|
||||
### Step 1: Collect all PRs since the last release
|
||||
|
||||
Supposing that the base release is `v1.2.0`:
|
||||
|
||||
```
|
||||
for commit_sha in $(git log --pretty=format:"%h" v1.2.0..HEAD); do
|
||||
gh pr list --search "$commit_sha" --state merged --json number,title,labels,url
|
||||
done | jq '.[]' | jq --slurp 'unique_by(.number)' > prs.json
|
||||
```
|
||||
|
||||
This JSON file will be useful later.
|
||||
|
||||
### Step 2: Determine the version
|
||||
|
||||
In order to determine the version of the next release, we first check that no incompatible change is detected in the code that has been merged since the last release. This step can be automated with the `gorelease` tool:
|
||||
|
||||
```shell
|
||||
gorelease | grep -B2 -A0 '^## incompatible changes'
|
||||
```
|
||||
|
||||
If the tool detects incompatible changes outside a `testing` package, then the bump is major.
|
||||
|
||||
Next, we check all PRs merged since the last release using the file `prs.json` that we generated above.
|
||||
|
||||
* Find PRs labeled with `semver:major`: `jq 'map(select(contains({labels: [{name: "semver:major"}]}) ))' prs.json`
|
||||
* Find PRs labeled with `semver:minor`: `jq 'map(select(contains({labels: [{name: "semver:minor"}]}) ))' prs.json`
|
||||
|
||||
The highest semver descriptor determines the release bump.
|
||||
|
||||
### Step 3: Release notes and version string
|
||||
|
||||
Once all PRs have a sensible title, generate the release notes:
|
||||
|
||||
```shell
|
||||
jq -r '.[] | "* [GH-\(.number)](\(.url)) \(.title)"' prs.json
|
||||
```
|
||||
|
||||
Add that to the top of `CHANGELOG.md`. Also add any information that could be useful to consumers willing to upgrade.
|
||||
|
||||
**Set the new version string in the `DefaultUserAgent` constant in `provider_client.go`.**
|
||||
|
||||
Create a PR with these two changes. The new PR should be labeled with the semver label corresponding to the type of bump.
|
||||
|
||||
### Step 3: Git tag and Github release
|
||||
|
||||
The Go mod system relies on Git tags. In order to simulate a review mechanism, we rely on Github to create the tag through the Release mechanism.
|
||||
|
||||
* [Prepare a new release](https://github.com/gophercloud/gophercloud/releases/new)
|
||||
* Let Github generate the release notes by clicking on Generate release notes
|
||||
* Click on **Save draft**
|
||||
* Ask another Gophercloud maintainer to review and publish the release
|
||||
|
||||
_Note: never change a release or force-push a tag. Tags are almost immediately picked up by the Go proxy and changing the commit it points to will be detected as tampering._
|
||||
48
vendor/github.com/gophercloud/gophercloud/errors.go
generated
vendored
48
vendor/github.com/gophercloud/gophercloud/errors.go
generated
vendored
|
|
@ -116,61 +116,109 @@ type ErrDefault400 struct {
|
|||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault400) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault401 is the default error type returned on a 401 HTTP response code.
|
||||
type ErrDefault401 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault401) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault403 is the default error type returned on a 403 HTTP response code.
|
||||
type ErrDefault403 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault403) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault404 is the default error type returned on a 404 HTTP response code.
|
||||
type ErrDefault404 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault404) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault405 is the default error type returned on a 405 HTTP response code.
|
||||
type ErrDefault405 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault405) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault408 is the default error type returned on a 408 HTTP response code.
|
||||
type ErrDefault408 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault408) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault409 is the default error type returned on a 409 HTTP response code.
|
||||
type ErrDefault409 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault409) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault429 is the default error type returned on a 429 HTTP response code.
|
||||
type ErrDefault429 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault429) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault500 is the default error type returned on a 500 HTTP response code.
|
||||
type ErrDefault500 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault500) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault502 is the default error type returned on a 502 HTTP response code.
|
||||
type ErrDefault502 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault502) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault503 is the default error type returned on a 503 HTTP response code.
|
||||
type ErrDefault503 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault503) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
// ErrDefault504 is the default error type returned on a 504 HTTP response code.
|
||||
type ErrDefault504 struct {
|
||||
ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault504) Unwrap() error {
|
||||
return e.ErrUnexpectedResponseCode
|
||||
}
|
||||
|
||||
func (e ErrDefault400) Error() string {
|
||||
e.DefaultErrString = fmt.Sprintf(
|
||||
"Bad request with: [%s %s], error message: %s",
|
||||
|
|
|
|||
9
vendor/github.com/gophercloud/gophercloud/openstack/auth_env.go
generated
vendored
9
vendor/github.com/gophercloud/gophercloud/openstack/auth_env.go
generated
vendored
|
|
@ -46,6 +46,7 @@ func AuthOptionsFromEnv() (gophercloud.AuthOptions, error) {
|
|||
applicationCredentialID := os.Getenv("OS_APPLICATION_CREDENTIAL_ID")
|
||||
applicationCredentialName := os.Getenv("OS_APPLICATION_CREDENTIAL_NAME")
|
||||
applicationCredentialSecret := os.Getenv("OS_APPLICATION_CREDENTIAL_SECRET")
|
||||
systemScope := os.Getenv("OS_SYSTEM_SCOPE")
|
||||
|
||||
// If OS_PROJECT_ID is set, overwrite tenantID with the value.
|
||||
if v := os.Getenv("OS_PROJECT_ID"); v != "" {
|
||||
|
|
@ -109,6 +110,13 @@ func AuthOptionsFromEnv() (gophercloud.AuthOptions, error) {
|
|||
}
|
||||
}
|
||||
|
||||
var scope *gophercloud.AuthScope
|
||||
if systemScope == "all" {
|
||||
scope = &gophercloud.AuthScope{
|
||||
System: true,
|
||||
}
|
||||
}
|
||||
|
||||
ao := gophercloud.AuthOptions{
|
||||
IdentityEndpoint: authURL,
|
||||
UserID: userID,
|
||||
|
|
@ -122,6 +130,7 @@ func AuthOptionsFromEnv() (gophercloud.AuthOptions, error) {
|
|||
ApplicationCredentialID: applicationCredentialID,
|
||||
ApplicationCredentialName: applicationCredentialName,
|
||||
ApplicationCredentialSecret: applicationCredentialSecret,
|
||||
Scope: scope,
|
||||
}
|
||||
|
||||
return ao, nil
|
||||
|
|
|
|||
2
vendor/github.com/gophercloud/gophercloud/openstack/client.go
generated
vendored
2
vendor/github.com/gophercloud/gophercloud/openstack/client.go
generated
vendored
|
|
@ -369,7 +369,7 @@ func NewBareMetalV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointO
|
|||
// NewBareMetalIntrospectionV1 creates a ServiceClient that may be used with the v1
|
||||
// bare metal introspection package.
|
||||
func NewBareMetalIntrospectionV1(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
|
||||
return initClientOpts(client, eo, "baremetal-inspector")
|
||||
return initClientOpts(client, eo, "baremetal-introspection")
|
||||
}
|
||||
|
||||
// NewObjectStorageV1 creates a ServiceClient that may be used with the v1
|
||||
|
|
|
|||
20
vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/doc.go
generated
vendored
20
vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/doc.go
generated
vendored
|
|
@ -11,6 +11,26 @@ Example to List Servers
|
|||
AllTenants: true,
|
||||
}
|
||||
|
||||
allPages, err := servers.ListSimple(computeClient, listOpts).AllPages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
allServers, err := servers.ExtractServers(allPages)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, server := range allServers {
|
||||
fmt.Printf("%+v\n", server)
|
||||
}
|
||||
|
||||
Example to List Detail Servers
|
||||
|
||||
listOpts := servers.ListOpts{
|
||||
AllTenants: true,
|
||||
}
|
||||
|
||||
allPages, err := servers.List(computeClient, listOpts).AllPages()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
|||
17
vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/requests.go
generated
vendored
17
vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/requests.go
generated
vendored
|
|
@ -94,7 +94,22 @@ func (opts ListOpts) ToServerListQuery() (string, error) {
|
|||
return q.String(), err
|
||||
}
|
||||
|
||||
// List makes a request against the API to list servers accessible to you.
|
||||
// ListSimple makes a request against the API to list servers accessible to you.
|
||||
func ListSimple(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
|
||||
url := listURL(client)
|
||||
if opts != nil {
|
||||
query, err := opts.ToServerListQuery()
|
||||
if err != nil {
|
||||
return pagination.Pager{Err: err}
|
||||
}
|
||||
url += query
|
||||
}
|
||||
return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
|
||||
return ServerPage{pagination.LinkedPageBase{PageResult: r}}
|
||||
})
|
||||
}
|
||||
|
||||
// List makes a request against the API to list servers details accessible to you.
|
||||
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
|
||||
url := listDetailURL(client)
|
||||
if opts != nil {
|
||||
|
|
|
|||
12
vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/results.go
generated
vendored
12
vendor/github.com/gophercloud/gophercloud/openstack/compute/v2/servers/results.go
generated
vendored
|
|
@ -277,6 +277,10 @@ type ServerPage struct {
|
|||
|
||||
// IsEmpty returns true if a page contains no Server results.
|
||||
func (r ServerPage) IsEmpty() (bool, error) {
|
||||
if r.StatusCode == 204 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
s, err := ExtractServers(r)
|
||||
return len(s) == 0, err
|
||||
}
|
||||
|
|
@ -385,6 +389,10 @@ type AddressPage struct {
|
|||
|
||||
// IsEmpty returns true if an AddressPage contains no networks.
|
||||
func (r AddressPage) IsEmpty() (bool, error) {
|
||||
if r.StatusCode == 204 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
addresses, err := ExtractAddresses(r)
|
||||
return len(addresses) == 0, err
|
||||
}
|
||||
|
|
@ -410,6 +418,10 @@ type NetworkAddressPage struct {
|
|||
|
||||
// IsEmpty returns true if a NetworkAddressPage contains no addresses.
|
||||
func (r NetworkAddressPage) IsEmpty() (bool, error) {
|
||||
if r.StatusCode == 204 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
addresses, err := ExtractNetworkAddresses(r)
|
||||
return len(addresses) == 0, err
|
||||
}
|
||||
|
|
|
|||
4
vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/results.go
generated
vendored
4
vendor/github.com/gophercloud/gophercloud/openstack/identity/v2/tenants/results.go
generated
vendored
|
|
@ -27,6 +27,10 @@ type TenantPage struct {
|
|||
|
||||
// IsEmpty determines whether or not a page of Tenants contains any results.
|
||||
func (r TenantPage) IsEmpty() (bool, error) {
|
||||
if r.StatusCode == 204 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
tenants, err := ExtractTenants(r)
|
||||
return len(tenants) == 0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ type GetConsumerResult struct {
|
|||
|
||||
// IsEmpty determines whether or not a page of Consumers contains any results.
|
||||
func (c ConsumersPage) IsEmpty() (bool, error) {
|
||||
if c.StatusCode == 204 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
consumers, err := ExtractConsumers(c)
|
||||
return len(consumers) == 0, err
|
||||
}
|
||||
|
|
@ -208,6 +212,10 @@ type AccessTokensPage struct {
|
|||
|
||||
// IsEmpty determines whether or not a an AccessTokensPage contains any results.
|
||||
func (r AccessTokensPage) IsEmpty() (bool, error) {
|
||||
if r.StatusCode == 204 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
accessTokens, err := ExtractAccessTokens(r)
|
||||
return len(accessTokens) == 0, err
|
||||
}
|
||||
|
|
@ -251,6 +259,10 @@ type AccessTokenRolesPage struct {
|
|||
|
||||
// IsEmpty determines whether or not a an AccessTokensPage contains any results.
|
||||
func (r AccessTokenRolesPage) IsEmpty() (bool, error) {
|
||||
if r.StatusCode == 204 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
accessTokenRoles, err := ExtractAccessTokenRoles(r)
|
||||
return len(accessTokenRoles) == 0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,6 +204,10 @@ type ImagePage struct {
|
|||
|
||||
// IsEmpty returns true if an ImagePage contains no Images results.
|
||||
func (r ImagePage) IsEmpty() (bool, error) {
|
||||
if r.StatusCode == 204 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
images, err := ExtractImages(r)
|
||||
return len(images) == 0, err
|
||||
}
|
||||
|
|
|
|||
5
vendor/github.com/gophercloud/gophercloud/pagination/http.go
generated
vendored
5
vendor/github.com/gophercloud/gophercloud/pagination/http.go
generated
vendored
|
|
@ -44,8 +44,9 @@ func PageResultFrom(resp *http.Response) (PageResult, error) {
|
|||
func PageResultFromParsed(resp *http.Response, body interface{}) PageResult {
|
||||
return PageResult{
|
||||
Result: gophercloud.Result{
|
||||
Body: body,
|
||||
Header: resp.Header,
|
||||
Body: body,
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header,
|
||||
},
|
||||
URL: *resp.Request.URL,
|
||||
}
|
||||
|
|
|
|||
3
vendor/github.com/gophercloud/gophercloud/pagination/pager.go
generated
vendored
3
vendor/github.com/gophercloud/gophercloud/pagination/pager.go
generated
vendored
|
|
@ -134,6 +134,9 @@ func (p Pager) EachPage(handler func(Page) (bool, error)) error {
|
|||
// AllPages returns all the pages from a `List` operation in a single page,
|
||||
// allowing the user to retrieve all the pages at once.
|
||||
func (p Pager) AllPages() (Page, error) {
|
||||
if p.Err != nil {
|
||||
return nil, p.Err
|
||||
}
|
||||
// pagesSlice holds all the pages until they get converted into as Page Body.
|
||||
var pagesSlice []interface{}
|
||||
// body will contain the final concatenated Page body.
|
||||
|
|
|
|||
2
vendor/github.com/gophercloud/gophercloud/provider_client.go
generated
vendored
2
vendor/github.com/gophercloud/gophercloud/provider_client.go
generated
vendored
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
// DefaultUserAgent is the default User-Agent string set in the request header.
|
||||
const (
|
||||
DefaultUserAgent = "gophercloud/2.0.0"
|
||||
DefaultUserAgent = "gophercloud/v1.5.0"
|
||||
DefaultMaxBackoffRetries = 60
|
||||
)
|
||||
|
||||
|
|
|
|||
5
vendor/github.com/gophercloud/gophercloud/results.go
generated
vendored
5
vendor/github.com/gophercloud/gophercloud/results.go
generated
vendored
|
|
@ -30,6 +30,11 @@ type Result struct {
|
|||
// this will be the deserialized JSON structure.
|
||||
Body interface{}
|
||||
|
||||
// StatusCode is the HTTP status code of the original response. Will be
|
||||
// one of the OkCodes defined on the gophercloud.RequestOpts that was
|
||||
// used in the request.
|
||||
StatusCode int
|
||||
|
||||
// Header contains the HTTP header structure from the original response.
|
||||
Header http.Header
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue