policymanager

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergePoliciesOfDifferentHierarchy

func MergePoliciesOfDifferentHierarchy(parentPolicies, childPolicies map[PolicyCrdID]*Policy) (map[PolicyCrdID]*Policy, error)

func MergePoliciesOfSameHierarchy

func MergePoliciesOfSameHierarchy(policies1, policies2 map[PolicyCrdID]*Policy) (map[PolicyCrdID]*Policy, error)

func MergePoliciesOfSimilarKind

func MergePoliciesOfSimilarKind(policies []*Policy) (map[PolicyCrdID]*Policy, error)

MergePoliciesOfSimilarKind will convert a slice a policies to a map of policies by merging policies of similar kind. The returned map will have the policy kind as the key.

func ToPolicyRefs

func ToPolicyRefs(policies []Policy) []common.GKNN

ToPolicyRefs returns the Object references of all given policies. Note that these are not the value of targetRef within the Policies but rather the reference to the Policy object itself.

Types

type Policy

type Policy struct {
	Unstructured *unstructured.Unstructured
	// TargetRefs references the target objects this policy is attached to. This
	// only makes sense in case of a directly-attached-policy, or an
	// unmerged-inherited-policy.
	TargetRef common.GKNN
	// Indicates whether the policy is supposed to be "inherited" (as opposed to
	// "direct").
	Inheritable bool
}

func ConstructPolicy

func ConstructPolicy(u *unstructured.Unstructured, inherited bool) (Policy, error)

func ConvertPoliciesMapToSlice

func ConvertPoliciesMapToSlice(policies map[common.GKNN]*Policy) []*Policy

func (Policy) DeepCopy

func (p Policy) DeepCopy() *Policy

func (Policy) EffectiveSpec

func (p Policy) EffectiveSpec() (map[string]interface{}, error)

func (Policy) GKNN

func (p Policy) GKNN() common.GKNN

func (Policy) IsAttachedTo

func (p Policy) IsAttachedTo(objRef common.GKNN) bool

func (Policy) IsDirect

func (p Policy) IsDirect() bool

func (Policy) IsInheritable

func (p Policy) IsInheritable() bool

func (*Policy) MarshalJSON

func (p *Policy) MarshalJSON() ([]byte, error)

func (Policy) PolicyCrdID

func (p Policy) PolicyCrdID() PolicyCrdID

PolicyCrdID returns a unique identifier for the CRD of this policy.

func (Policy) Spec

func (p Policy) Spec() map[string]interface{}

type PolicyCRD

type PolicyCRD struct {
	CRD *apiextensionsv1.CustomResourceDefinition
}

func (PolicyCRD) ID

func (p PolicyCRD) ID() PolicyCrdID

ID returns a unique identifier for this PolicyCRD.

func (PolicyCRD) IsClusterScoped

func (p PolicyCRD) IsClusterScoped() bool

IsClusterScoped returns true if the CRD is cluster scoped. Such policies can be used to target a cluster scoped resource like GatewayClass.

func (PolicyCRD) IsDirect

func (p PolicyCRD) IsDirect() bool

func (PolicyCRD) IsInheritable

func (p PolicyCRD) IsInheritable() bool

func (PolicyCRD) IsValid

func (p PolicyCRD) IsValid() bool

IsValid return true if the PolicyCRD satisfies requirements for qualifying as a Gateway Policy CRD.

type PolicyCrdID

type PolicyCrdID string

PolicyCrdID has the structurued "<CRD Kind>.<CRD Group>"

type PolicyManager

type PolicyManager struct {
	Fetcher common.GroupKindFetcher
	// contains filtered or unexported fields
}

func New

func (*PolicyManager) GetCRD

func (p *PolicyManager) GetCRD(name string) (*PolicyCRD, bool)

func (*PolicyManager) GetCRDs

func (p *PolicyManager) GetCRDs() []*PolicyCRD

func (*PolicyManager) GetPolicies

func (p *PolicyManager) GetPolicies() []*Policy

func (*PolicyManager) Init

func (p *PolicyManager) Init() error

Init will construct a local cache of all Policy CRDs and Policy Resources.

func (*PolicyManager) PoliciesAttachedTo

func (p *PolicyManager) PoliciesAttachedTo(objRef common.GKNN) []*Policy

Jump to

Keyboard shortcuts

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