Fix Rancher API pagination limits

This fix allows the Traefik Rancher provider to obtain a complete view
of the environments, services and containers being managed by the
Rancher deployment.
This commit is contained in:
Martin Baillie 2017-04-18 12:01:11 +10:00
parent 4ce2c8cc34
commit 73f09f389e

View file

@ -25,6 +25,10 @@ const (
RancherDefaultWatchTime = 15 * time.Second
)
var (
withoutPagination *rancher.ListOpts
)
var _ Provider = (*Rancher)(nil)
// Rancher holds configurations of the Rancher provider.
@ -44,6 +48,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)
}
@ -290,7 +300,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 Rancher Environments %+v", err)
@ -307,7 +317,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 Rancher Services %+v", err)
@ -324,7 +334,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))