mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 01:45:44 +03:00
This PR switches the Nomad repository from using govendor to Go modules for managing dependencies. Aspects of the Nomad workflow remain pretty much the same. The usual Makefile targets should continue to work as they always did. The API submodule simply defers to the parent Nomad version on the repository, keeping the semantics of API versioning that currently exists.
34 lines
918 B
Go
34 lines
918 B
Go
package pagination
|
|
|
|
import (
|
|
"fmt"
|
|
"reflect"
|
|
|
|
"github.com/gophercloud/gophercloud"
|
|
)
|
|
|
|
// SinglePageBase may be embedded in a Page that contains all of the results from an operation at once.
|
|
type SinglePageBase PageResult
|
|
|
|
// NextPageURL always returns "" to indicate that there are no more pages to return.
|
|
func (current SinglePageBase) NextPageURL() (string, error) {
|
|
return "", nil
|
|
}
|
|
|
|
// IsEmpty satisifies the IsEmpty method of the Page interface
|
|
func (current SinglePageBase) IsEmpty() (bool, error) {
|
|
if b, ok := current.Body.([]interface{}); ok {
|
|
return len(b) == 0, nil
|
|
}
|
|
err := gophercloud.ErrUnexpectedType{}
|
|
err.Expected = "[]interface{}"
|
|
err.Actual = fmt.Sprintf("%v", reflect.TypeOf(current.Body))
|
|
return true, err
|
|
}
|
|
|
|
// GetBody returns the single page's body. This method is needed to satisfy the
|
|
// Page interface.
|
|
func (current SinglePageBase) GetBody() interface{} {
|
|
return current.Body
|
|
}
|