From 33a40f95348ee0646d7506403e55f4140f350222 Mon Sep 17 00:00:00 2001 From: Trevor Johnson Date: Thu, 6 Oct 2022 11:28:05 -0700 Subject: [PATCH] cache manager list access requests (#565) --- pkg/agent/cache/accessrequest.go | 11 +++++++++++ pkg/agent/cache/manager.go | 1 + 2 files changed, 12 insertions(+) diff --git a/pkg/agent/cache/accessrequest.go b/pkg/agent/cache/accessrequest.go index 5e3ec57aa..01a0e68d4 100644 --- a/pkg/agent/cache/accessrequest.go +++ b/pkg/agent/cache/accessrequest.go @@ -95,3 +95,14 @@ func (c *cacheManager) GetAccessRequest(id string) *v1.ResourceInstance { func (c *cacheManager) DeleteAccessRequest(id string) error { return c.accessRequestMap.Delete(id) } + +func (c *cacheManager) ListAccessRequests() []*v1.ResourceInstance { + list := make([]*v1.ResourceInstance, 0) + for _, key := range c.accessRequestMap.GetKeys() { + item, _ := c.accessRequestMap.Get(key) + if v, ok := item.(*v1.ResourceInstance); ok && v != nil { + list = append(list, v) + } + } + return list +} diff --git a/pkg/agent/cache/manager.go b/pkg/agent/cache/manager.go index 42c0d98b0..1a4374db3 100644 --- a/pkg/agent/cache/manager.go +++ b/pkg/agent/cache/manager.go @@ -111,6 +111,7 @@ type Manager interface { GetAccessRequest(id string) *v1.ResourceInstance GetAccessRequestsByApp(managedAppName string) []*v1.ResourceInstance DeleteAccessRequest(id string) error + ListAccessRequests() []*v1.ResourceInstance GetWatchResourceCacheKeys(group, kind string) []string AddWatchResource(resource *v1.ResourceInstance)