Sort idpcache keys to make things as deterministic as possible.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer
2020-09-22 10:03:32 -05:00
parent 9beb3855b5
commit 16ef2baf8a
2 changed files with 28 additions and 0 deletions
@@ -7,6 +7,7 @@ package idpcache
import (
"context"
"fmt"
"sort"
"sync"
"k8s.io/apiserver/pkg/authentication/authenticator"
@@ -68,6 +69,14 @@ func (c *Cache) Keys() []Key {
result = append(result, key.(Key))
return true
})
// Sort the results for consistency.
sort.Slice(result, func(i, j int) bool {
return result[i].APIGroup < result[j].APIGroup ||
result[i].Kind < result[j].Kind ||
result[i].Namespace < result[j].Namespace ||
result[i].Name < result[j].Name
})
return result
}