outposts: implement general paginator for list API requests (#10619)
* outposts: implement general paginator Signed-off-by: Jens Langhammer <jens@goauthentik.io> * migrate LDAP Signed-off-by: Jens Langhammer <jens@goauthentik.io> * change main outpost refresh logic to use paginator everywhere Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add comments to understand anything Signed-off-by: Jens Langhammer <jens@goauthentik.io> * actually use paginator everywhere Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -14,7 +14,10 @@ import (
|
||||
)
|
||||
|
||||
func (ps *ProxyServer) Refresh() error {
|
||||
providers, _, err := ps.akAPI.Client.OutpostsApi.OutpostsProxyList(context.Background()).Execute()
|
||||
providers, err := ak.Paginator(ps.akAPI.Client.OutpostsApi.OutpostsProxyList(context.Background()), ak.PaginatorOptions{
|
||||
PageSize: 100,
|
||||
Logger: ps.log,
|
||||
})
|
||||
if err != nil {
|
||||
ps.log.WithError(err).Error("Failed to fetch providers")
|
||||
}
|
||||
@ -22,7 +25,7 @@ func (ps *ProxyServer) Refresh() error {
|
||||
return err
|
||||
}
|
||||
apps := make(map[string]*application.Application)
|
||||
for _, provider := range providers.Results {
|
||||
for _, provider := range providers {
|
||||
rsp := sentry.StartSpan(context.Background(), "authentik.outposts.proxy.application_ss")
|
||||
ua := fmt.Sprintf(" (provider=%s)", provider.Name)
|
||||
hc := &http.Client{
|
||||
@ -35,7 +38,7 @@ func (ps *ProxyServer) Refresh() error {
|
||||
),
|
||||
}
|
||||
a, err := application.NewApplication(provider, hc, ps)
|
||||
existing, ok := apps[a.Host]
|
||||
existing, ok := ps.apps[a.Host]
|
||||
if ok {
|
||||
existing.Stop()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user