store

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecutorKey

func ExecutorKey(namespace, name string) string

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.

func (*Dimension) Hash

func (d *Dimension) Hash() string

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) Count

func (c *ExecutorCaches) Count() int

Count counts all cache items

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

func (*ExecutorCaches) Upsert

func (c *ExecutorCaches) Upsert(executor string, dimension Dimension, allowed *bool)

Upsert will insert a new cache item or update the existing cache item

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL