Documentation
¶
Index ¶
- func HashRegex(expr api.RegExpression) string
- func ShouldInvalidate(last *metav1.Time, now time.Time, interval time.Duration) bool
- type CompiledRegex
- type CompiledRule
- type CompiledTarget
- type CompiledTargetsCache
- func (c *CompiledTargetsCache[K]) Delete(key K) bool
- func (c *CompiledTargetsCache[K]) Get(key K) ([]CompiledTarget, bool)
- func (c *CompiledTargetsCache[K]) GetOrBuild(key K, build func() ([]CompiledTarget, error)) ([]CompiledTarget, error)
- func (c *CompiledTargetsCache[K]) PruneActive(active map[K]struct{}) int
- func (c *CompiledTargetsCache[K]) Reset()
- func (c *CompiledTargetsCache[K]) Set(key K, value []CompiledTarget)
- func (c *CompiledTargetsCache[K]) Stats() int
- type DiscoveryNamespacedResourceCache
- type ImpersonationCache
- func (c *ImpersonationCache) Get(ns, name string) (client.Client, bool)
- func (c *ImpersonationCache) Invalidate(namespace, name string)
- func (c *ImpersonationCache) LoadOrCreate(ctx context.Context, log logr.Logger, baseREST *rest.Config, ...) (client.Client, error)
- func (c *ImpersonationCache) Reset()
- func (c *ImpersonationCache) Set(namespace, name string, cl client.Client)
- func (c *ImpersonationCache) Stats() (entries int)
- type JSONPathCache
- func (c *JSONPathCache) Delete(path string) bool
- func (c *JSONPathCache) DeleteMany(expressions ...string) int
- func (c *JSONPathCache) Get(path string) (*jsonpath.CompiledJSONPath, bool)
- func (c *JSONPathCache) GetOrCompile(path string) (*jsonpath.CompiledJSONPath, error)
- func (c *JSONPathCache) PruneActive(active map[string]struct{}) int
- func (c *JSONPathCache) Reset()
- func (c *JSONPathCache) Stats() int
- type Key
- type PendingDeleteHint
- type QuantityCache
- func (c *QuantityCache[K]) AddPendingDelete(key K, uid types.UID)
- func (c *QuantityCache[K]) Delete(key K) bool
- func (c *QuantityCache[K]) DeleteReservation(key K, reservationID string) bool
- func (c *QuantityCache[K]) Get(key K) (QuantityEntry, bool)
- func (c *QuantityCache[K]) HasPendingDeletes(key K) bool
- func (c *QuantityCache[K]) Len() int
- func (c *QuantityCache[K]) PendingDeletes(key K) []types.UID
- func (c *QuantityCache[K]) PurgeReservationsForKey(key K, shouldDelete func(Reservation) bool) int
- func (c *QuantityCache[K]) RemovePendingDelete(key K, uid types.UID) bool
- func (c *QuantityCache[K]) Snapshot() map[K]QuantityEntry
- func (c *QuantityCache[K]) UpsertReservation(key K, reservation Reservation, persistedUsed resource.Quantity, ...) (allowed bool, effectiveUsed resource.Quantity, entry QuantityEntry)
- type QuantityEntry
- type RegexCache
- type RegistryRuleSetCache
- func (c *RegistryRuleSetCache) GetOrBuild(specRules []rules.OCIRegistry) (rs *RuleSet, fromCache bool, err error)
- func (c *RegistryRuleSetCache) Has(id string) bool
- func (c *RegistryRuleSetCache) HashRules(specRules []rules.OCIRegistry) string
- func (c *RegistryRuleSetCache) Match(specRules []rules.OCIRegistry, reference string, pullPolicy corev1.PullPolicy) (*CompiledRule, error)
- func (c *RegistryRuleSetCache) MatchReference(rs *RuleSet, reference string) (*CompiledRule, error)
- func (c *RegistryRuleSetCache) MatchRuleSet(rs *RuleSet, reference string, pullPolicy corev1.PullPolicy) (*CompiledRule, error)
- func (c *RegistryRuleSetCache) PruneActive(activeIDs map[string]struct{}) int
- func (c *RegistryRuleSetCache) Reset()
- func (c *RegistryRuleSetCache) Stats() int
- type Reservation
- type RuleSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashRegex ¶ added in v0.13.5
func HashRegex(expr api.RegExpression) string
Types ¶
type CompiledRegex ¶ added in v0.13.5
func (*CompiledRegex) MatchString ¶ added in v0.13.5
func (r *CompiledRegex) MatchString(value string) bool
type CompiledRule ¶
type CompiledRule struct {
Expression api.RegExpression
RegexID string
AllowedPolicy map[corev1.PullPolicy]struct{} // nil/empty => allow any
}
func (*CompiledRule) AllowsPullPolicy ¶ added in v0.13.5
func (r *CompiledRule) AllowsPullPolicy(pullPolicy corev1.PullPolicy) bool
type CompiledTarget ¶
type CompiledTarget struct {
capsulev1beta2.CustomQuotaStatusTarget
CompiledPath *jsonpath.CompiledJSONPath
CompiledSelectors []selectors.CompiledSelectorWithFields
CompiledConditions []*jsonpath.CompiledJSONPath
}
type CompiledTargetsCache ¶
type CompiledTargetsCache[K comparable] struct { // contains filtered or unexported fields }
func NewCompiledTargetsCache ¶
func NewCompiledTargetsCache[K comparable]() *CompiledTargetsCache[K]
func (*CompiledTargetsCache[K]) Delete ¶
func (c *CompiledTargetsCache[K]) Delete(key K) bool
func (*CompiledTargetsCache[K]) Get ¶
func (c *CompiledTargetsCache[K]) Get(key K) ([]CompiledTarget, bool)
func (*CompiledTargetsCache[K]) GetOrBuild ¶
func (c *CompiledTargetsCache[K]) GetOrBuild(key K, build func() ([]CompiledTarget, error)) ([]CompiledTarget, error)
func (*CompiledTargetsCache[K]) PruneActive ¶
func (c *CompiledTargetsCache[K]) PruneActive(active map[K]struct{}) int
func (*CompiledTargetsCache[K]) Reset ¶
func (c *CompiledTargetsCache[K]) Reset()
func (*CompiledTargetsCache[K]) Set ¶
func (c *CompiledTargetsCache[K]) Set(key K, value []CompiledTarget)
func (*CompiledTargetsCache[K]) Stats ¶
func (c *CompiledTargetsCache[K]) Stats() int
type DiscoveryNamespacedResourceCache ¶
type DiscoveryNamespacedResourceCache struct {
// contains filtered or unexported fields
}
func NewDiscoveryNamespacedResourceCache ¶
func NewDiscoveryNamespacedResourceCache() DiscoveryNamespacedResourceCache
func NewDiscoveryNamespacedResourceCacheWithTTL ¶
func NewDiscoveryNamespacedResourceCacheWithTTL(ttl time.Duration) DiscoveryNamespacedResourceCache
func (*DiscoveryNamespacedResourceCache) Get ¶
func (c *DiscoveryNamespacedResourceCache) Get( disco discovery.DiscoveryInterface, ) ([]schema.GroupVersionResource, error)
func (*DiscoveryNamespacedResourceCache) Invalidate ¶
func (c *DiscoveryNamespacedResourceCache) Invalidate()
type ImpersonationCache ¶
type ImpersonationCache struct {
// contains filtered or unexported fields
}
func NewImpersonationCache ¶
func NewImpersonationCache() *ImpersonationCache
func (*ImpersonationCache) Get ¶
func (c *ImpersonationCache) Get(ns, name string) (client.Client, bool)
Get returns a cached client if present.
func (*ImpersonationCache) Invalidate ¶
func (c *ImpersonationCache) Invalidate(namespace, name string)
Invalidate removes one entry.
func (*ImpersonationCache) LoadOrCreate ¶
func (c *ImpersonationCache) LoadOrCreate( ctx context.Context, log logr.Logger, baseREST *rest.Config, scheme *runtime.Scheme, sa meta.NamespacedRFC1123ObjectReferenceWithNamespace, ) (client.Client, error)
LoadOrCreate returns a cached impersonated client for the given service account, creating and caching it if missing.
func (*ImpersonationCache) Reset ¶
func (c *ImpersonationCache) Reset()
Clear drops all cached clients.
func (*ImpersonationCache) Set ¶
func (c *ImpersonationCache) Set(namespace, name string, cl client.Client)
Set stores a client explicitly (rarely needed).
func (*ImpersonationCache) Stats ¶
func (c *ImpersonationCache) Stats() (entries int)
Stats helps you log cache state.
type JSONPathCache ¶
type JSONPathCache struct {
// contains filtered or unexported fields
}
func NewJSONPathCache ¶
func NewJSONPathCache() *JSONPathCache
func (*JSONPathCache) Delete ¶
func (c *JSONPathCache) Delete(path string) bool
func (*JSONPathCache) DeleteMany ¶
func (c *JSONPathCache) DeleteMany(expressions ...string) int
func (*JSONPathCache) Get ¶
func (c *JSONPathCache) Get(path string) (*jsonpath.CompiledJSONPath, bool)
func (*JSONPathCache) GetOrCompile ¶
func (c *JSONPathCache) GetOrCompile(path string) (*jsonpath.CompiledJSONPath, error)
func (*JSONPathCache) PruneActive ¶
func (c *JSONPathCache) PruneActive(active map[string]struct{}) int
func (*JSONPathCache) Reset ¶
func (c *JSONPathCache) Reset()
func (*JSONPathCache) Stats ¶
func (c *JSONPathCache) Stats() int
type QuantityCache ¶
type QuantityCache[K comparable] struct { // contains filtered or unexported fields }
func NewQuantityCache ¶
func NewQuantityCache[K comparable]() *QuantityCache[K]
func (*QuantityCache[K]) AddPendingDelete ¶
func (c *QuantityCache[K]) AddPendingDelete(key K, uid types.UID)
func (*QuantityCache[K]) Delete ¶
func (c *QuantityCache[K]) Delete(key K) bool
func (*QuantityCache[K]) DeleteReservation ¶
func (c *QuantityCache[K]) DeleteReservation(key K, reservationID string) bool
func (*QuantityCache[K]) Get ¶
func (c *QuantityCache[K]) Get(key K) (QuantityEntry, bool)
func (*QuantityCache[K]) HasPendingDeletes ¶
func (c *QuantityCache[K]) HasPendingDeletes(key K) bool
func (*QuantityCache[K]) Len ¶
func (c *QuantityCache[K]) Len() int
func (*QuantityCache[K]) PendingDeletes ¶
func (c *QuantityCache[K]) PendingDeletes(key K) []types.UID
func (*QuantityCache[K]) PurgeReservationsForKey ¶
func (c *QuantityCache[K]) PurgeReservationsForKey( key K, shouldDelete func(Reservation) bool, ) int
PurgeReservationsForKey removes reservations for which shouldDelete returns true. Returns number of removed reservations.
func (*QuantityCache[K]) RemovePendingDelete ¶
func (c *QuantityCache[K]) RemovePendingDelete(key K, uid types.UID) bool
func (*QuantityCache[K]) Snapshot ¶
func (c *QuantityCache[K]) Snapshot() map[K]QuantityEntry
func (*QuantityCache[K]) UpsertReservation ¶
func (c *QuantityCache[K]) UpsertReservation( key K, reservation Reservation, persistedUsed resource.Quantity, limit resource.Quantity, ) (allowed bool, effectiveUsed resource.Quantity, entry QuantityEntry)
UpsertReservation ensures a reservation is idempotent per (key, reservationID). It validates:
persistedUsed + sum(all reservations including this one) <= limit
type QuantityEntry ¶
type RegexCache ¶ added in v0.13.5
type RegexCache struct {
// contains filtered or unexported fields
}
func NewRegexCache ¶ added in v0.13.5
func NewRegexCache() *RegexCache
func (*RegexCache) GetOrCompile ¶ added in v0.13.5
func (c *RegexCache) GetOrCompile(expr api.RegExpression) (*CompiledRegex, bool, error)
func (*RegexCache) Has ¶ added in v0.13.5
func (c *RegexCache) Has(id string) bool
func (*RegexCache) Reset ¶ added in v0.13.5
func (c *RegexCache) Reset()
func (*RegexCache) Stats ¶ added in v0.13.5
func (c *RegexCache) Stats() int
type RegistryRuleSetCache ¶
type RegistryRuleSetCache struct {
// contains filtered or unexported fields
}
func NewRegistryRuleSetCache ¶
func NewRegistryRuleSetCache(regexCache *RegexCache) *RegistryRuleSetCache
func (*RegistryRuleSetCache) GetOrBuild ¶
func (c *RegistryRuleSetCache) GetOrBuild(specRules []rules.OCIRegistry) (rs *RuleSet, fromCache bool, err error)
func (*RegistryRuleSetCache) Has ¶
func (c *RegistryRuleSetCache) Has(id string) bool
func (*RegistryRuleSetCache) HashRules ¶
func (c *RegistryRuleSetCache) HashRules(specRules []rules.OCIRegistry) string
func (*RegistryRuleSetCache) Match ¶ added in v0.13.5
func (c *RegistryRuleSetCache) Match( specRules []rules.OCIRegistry, reference string, pullPolicy corev1.PullPolicy, ) (*CompiledRule, error)
Match matches reference, regex and pullPolicy. Admission evaluation should usually use MatchReference instead.
func (*RegistryRuleSetCache) MatchReference ¶ added in v0.13.5
func (c *RegistryRuleSetCache) MatchReference( rs *RuleSet, reference string, ) (*CompiledRule, error)
MatchReference matches reference and regex only. It intentionally does not check pullPolicy.
func (*RegistryRuleSetCache) MatchRuleSet ¶ added in v0.13.5
func (c *RegistryRuleSetCache) MatchRuleSet( rs *RuleSet, reference string, pullPolicy corev1.PullPolicy, ) (*CompiledRule, error)
func (*RegistryRuleSetCache) PruneActive ¶
func (c *RegistryRuleSetCache) PruneActive(activeIDs map[string]struct{}) int
func (*RegistryRuleSetCache) Reset ¶
func (c *RegistryRuleSetCache) Reset()
func (*RegistryRuleSetCache) Stats ¶
func (c *RegistryRuleSetCache) Stats() int
type Reservation ¶
type RuleSet ¶
type RuleSet struct {
ID string
Compiled []CompiledRule
}