mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
* Add openstack service discovery. * Add gophercloud code for openstack service discovery. * first changes for juliusv comments. * add gophercloud code for floatingip. * Add tests to openstack sd. * Add testify suite vendor files. * add copyright and make changes for code climate. * Fixed typos in provider openstack. * Renamed tenant to project in openstack sd. * Change type of password to Secret in openstack sd.
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
|
|
}
|