From a5940f62b4ca7a35ae6b4aa39565559ee1741a2e Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Fri, 10 Feb 2023 14:04:45 -0500 Subject: [PATCH] Adding comment for max loops --- internal/keyring/keyring.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/keyring/keyring.go b/internal/keyring/keyring.go index 5dc708720..ed3dc8419 100644 --- a/internal/keyring/keyring.go +++ b/internal/keyring/keyring.go @@ -75,7 +75,11 @@ func GetAccessToken(tenant string) (string, error) { var accessToken string - for i := 0; i < 10; i++ { + //Access tokens have no size limit, but should be smaller than (10*2048) bytes. + //The max number of loops safeguards against infinite loops, however unlikely. + maxNumberOfLoops := 10 + + for i := 0; i < maxNumberOfLoops; i++ { a, err := keyring.Get(fmt.Sprintf("%s %d", secretAccessToken, i), tenant) if err == keyring.ErrNotFound { return accessToken, nil