internal: Use loop instead of recursion in NewAPIController (#10745)
use loop instead of recursion
This commit is contained in:
@ -77,11 +77,17 @@ func NewAPIController(akURL url.URL, token string) *APIController {
|
|||||||
|
|
||||||
// Because we don't know the outpost UUID, we simply do a list and pick the first
|
// Because we don't know the outpost UUID, we simply do a list and pick the first
|
||||||
// The service account this token belongs to should only have access to a single outpost
|
// The service account this token belongs to should only have access to a single outpost
|
||||||
outposts, _, err := apiClient.OutpostsApi.OutpostsInstancesList(context.Background()).Execute()
|
var outposts *api.PaginatedOutpostList
|
||||||
if err != nil {
|
var err error
|
||||||
|
for {
|
||||||
|
outposts, _, err = apiClient.OutpostsApi.OutpostsInstancesList(context.Background()).Execute()
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
log.WithError(err).Error("Failed to fetch outpost configuration, retrying in 3 seconds")
|
log.WithError(err).Error("Failed to fetch outpost configuration, retrying in 3 seconds")
|
||||||
time.Sleep(time.Second * 3)
|
time.Sleep(time.Second * 3)
|
||||||
return NewAPIController(akURL, token)
|
|
||||||
}
|
}
|
||||||
if len(outposts.Results) < 1 {
|
if len(outposts.Results) < 1 {
|
||||||
panic("No outposts found with given token, ensure the given token corresponds to an authenitk Outpost")
|
panic("No outposts found with given token, ensure the given token corresponds to an authenitk Outpost")
|
||||||
|
Reference in New Issue
Block a user