Merge pull request #1453 from martinbaillie/rancher-provider-pagination-fixes

Fix Rancher API pagination limits
This commit is contained in:
Vincent Demeester 2017-04-19 13:36:55 +02:00 committed by GitHub
commit 4e0f131fcd

View file

@ -26,6 +26,10 @@ const (
RancherDefaultWatchTime = 15 * time.Second
)
var (
withoutPagination *rancher.ListOpts
)
var _ provider.Provider = (*Provider)(nil)
// Provider holds configurations of the provider.
@ -45,6 +49,12 @@ type rancherData struct {
Health string
}
func init() {
withoutPagination = &rancher.ListOpts{
Filters: map[string]interface{}{"limit": 0},
}
}
func (r rancherData) String() string {
return fmt.Sprintf("{name:%s, labels:%v, containers: %v, health: %s}", r.Name, r.Labels, r.Containers, r.Health)
}
@ -291,7 +301,7 @@ func listRancherEnvironments(client *rancher.RancherClient) []*rancher.Environme
var environmentList = []*rancher.Environment{}
environments, err := client.Environment.List(nil)
environments, err := client.Environment.List(withoutPagination)
if err != nil {
log.Errorf("Cannot get Provider Environments %+v", err)
@ -308,7 +318,7 @@ func listRancherServices(client *rancher.RancherClient) []*rancher.Service {
var servicesList = []*rancher.Service{}
services, err := client.Service.List(nil)
services, err := client.Service.List(withoutPagination)
if err != nil {
log.Errorf("Cannot get Provider Services %+v", err)
@ -325,7 +335,7 @@ func listRancherContainer(client *rancher.RancherClient) []*rancher.Container {
containerList := []*rancher.Container{}
container, err := client.Container.List(nil)
container, err := client.Container.List(withoutPagination)
log.Debugf("first container len: %i", len(container.Data))