package source

import "k8s.io/apiserver/pkg/admission/plugin/policy/manifest/source"

Package source provides a Source implementation that loads policy configurations from manifest files.

Index

Functions

func SetReloadIntervalForTests

func SetReloadIntervalForTests(interval time.Duration) func()

SetReloadIntervalForTests sets the reload interval for testing and returns a function to restore the original value.

Types

type BindingPolicyName

type BindingPolicyName[B runtime.Object] func(B) string

BindingPolicyName extracts the policy name referenced by a binding.

type PolicyCompiler

type PolicyCompiler[P runtime.Object, E generic.Evaluator] func(P) (E, error)

PolicyCompiler compiles a policy into an Evaluator.

type PolicyLoadFunc

type PolicyLoadFunc[P, B runtime.Object] func(dir string) ([]P, []B, string, error)

PolicyLoadFunc loads policy and binding manifests from a directory.

type StaticPolicySource

type StaticPolicySource[P, B runtime.Object, E generic.Evaluator] struct {
	// contains filtered or unexported fields
}

StaticPolicySource provides policy configurations loaded from manifest files.

func NewStaticPolicySource

func NewStaticPolicySource[P, B runtime.Object, E generic.Evaluator](
	manifestsDir, apiServerID string,
	compiler PolicyCompiler[P, E],
	loadFunc PolicyLoadFunc[P, B],
	getBindingPolicyName BindingPolicyName[B],
	manifestType metrics.ManifestType,
) *StaticPolicySource[P, B, E]

NewStaticPolicySource creates a new static policy source that loads configurations from the specified directory.

func (*StaticPolicySource[P, B, E]) HasSynced

func (s *StaticPolicySource[P, B, E]) HasSynced() bool

HasSynced returns true if the initial load has completed.

func (*StaticPolicySource[P, B, E]) Hooks

func (s *StaticPolicySource[P, B, E]) Hooks() []generic.PolicyHook[P, B, E]

Hooks returns the list of policy hooks.

func (*StaticPolicySource[P, B, E]) LoadInitial

func (s *StaticPolicySource[P, B, E]) LoadInitial() error

LoadInitial performs the initial load of manifests. This should be called during API server startup and will fail if the manifests cannot be loaded.

func (*StaticPolicySource[P, B, E]) RunReloadLoop

func (s *StaticPolicySource[P, B, E]) RunReloadLoop(ctx context.Context)

RunReloadLoop watches for configuration changes and reloads when detected. It blocks until ctx is canceled.

Source Files

source.go

Version
v0.36.0 (latest)
Published
Apr 22, 2026
Platform
linux/amd64
Imports
9 packages
Last checked
35 minutes ago

Tools for package owners.