Documentation ¶
Index ¶
- func ExecutorKey(namespace, name string) string
- func GetOwnedByWork(action ExecuteAction) bool
- type CacheValue
- type Dimension
- type DimensionCaches
- type ExecuteAction
- type ExecutorCaches
- func (c *ExecutorCaches) CleanupUnnecessaryCaches(necessaryCaches *ExecutorCaches)
- func (c *ExecutorCaches) Count() int
- func (c *ExecutorCaches) DimensionCachesExists(executor string) bool
- func (c *ExecutorCaches) Get(executor string, dimension Dimension) (allowed *bool, cacheExistence bool)
- func (c *ExecutorCaches) IterateCacheItems(executorKey string, fn func(v CacheValue) error)
- func (c *ExecutorCaches) RemoveByHash(executor string, hash string)
- func (c *ExecutorCaches) Upsert(executor string, dimension Dimension, allowed *bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecutorKey ¶
ExecutorKey return a key of executor caches map
func GetOwnedByWork ¶
func GetOwnedByWork(action ExecuteAction) bool
GetOwnedByWork judges whether a resource is owned by work according to the execute action
Types ¶
type CacheValue ¶
type CacheValue struct { Dimension Dimension // pointer can differ from default false value Allowed *bool }
CacheValue contains the cached result and the dimension
type Dimension ¶
type Dimension struct { Group string Version string Resource string Namespace string Name string ExecuteAction ExecuteAction }
Dimension represents the dimension of the cache, it determines what the cache is for.
type DimensionCaches ¶
type DimensionCaches struct {
// contains filtered or unexported fields
}
DimensionCaches contains a set of caches for an executor
type ExecuteAction ¶
type ExecuteAction int
ExecuteAction is the action of executing the manifest work
const ( // ApplyAndDeleteAction represents applying(create/update) resource to the managed cluster, // and is responsiable for deleting the resource ApplyAndDeleteAction ExecuteAction = iota // ApplyNoDeleteAction represents only applying(create/update) resource to the managed cluster, // but is not responsiable for deleting the resource ApplyNoDeleteAction )
func GetExecuteAction ¶
func GetExecuteAction(ownedByTheWork bool) ExecuteAction
GetExecuteAction get the execute action by judging whether a resource is owned by work
func (ExecuteAction) String ¶
func (a ExecuteAction) String() string
type ExecutorCaches ¶
type ExecutorCaches struct {
// contains filtered or unexported fields
}
ExecutorCaches is a two-level map cache structure, the 1-level map's key is the executor(service account) in the format of {namespace}/{name}, and the 2-level map's key is the hash value of the dimension(cached subject access review result of a specific resource, group-version-resource-namespace-name-action)
func NewExecutorCache ¶
func NewExecutorCache() *ExecutorCaches
NewExecutorCache creates an executor caches
func (*ExecutorCaches) CleanupUnnecessaryCaches ¶
func (c *ExecutorCaches) CleanupUnnecessaryCaches(necessaryCaches *ExecutorCaches)
CleanupUnnecessaryCaches only keeps the necessaryCaches and removes others
func (*ExecutorCaches) DimensionCachesExists ¶
func (c *ExecutorCaches) DimensionCachesExists(executor string) bool
DimensionCachesExists returns if the dimension caches of the executor exists
func (*ExecutorCaches) Get ¶
func (c *ExecutorCaches) Get(executor string, dimension Dimension) (allowed *bool, cacheExistence bool)
Get gets a cache item value and existence by the dimension if the cacheExistence is false that indicates the executor/dimension cache item does not exist in the caches if the cacheExistence is true but the allowed is nil that means the caches do not know if it is allowed
func (*ExecutorCaches) IterateCacheItems ¶
func (c *ExecutorCaches) IterateCacheItems(executorKey string, fn func(v CacheValue) error)
IterateCacheItems iterates all caches of executorKey and executes fn on it
func (*ExecutorCaches) RemoveByHash ¶
func (c *ExecutorCaches) RemoveByHash(executor string, hash string)
RemoveByHash removes an cache item by dimension hash