policymanager

package
v0.0.0-...-7320257 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 12 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.

Types

type ObjRef

type ObjRef struct {
	Group     string `json:",omitempty"`
	Kind      string `json:",omitempty"`
	Name      string `json:",omitempty"`
	Namespace string `json:",omitempty"`
}

func ToPolicyRefs

func ToPolicyRefs(policies []Policy) []ObjRef

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.

type Policy

type Policy struct {
	// contains filtered or unexported fields
}

func PolicyFromUnstructured

func PolicyFromUnstructured(u unstructured.Unstructured, policyCRDs map[PolicyCrdID]PolicyCRD) (Policy, error)

func (Policy) DeepCopy

func (p Policy) DeepCopy() Policy

func (Policy) EffectiveSpec

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

func (Policy) IsAttachedTo

func (p Policy) IsAttachedTo(objRef ObjRef) bool

func (Policy) IsDirect

func (p Policy) IsDirect() bool

func (Policy) IsInherited

func (p Policy) IsInherited() bool

func (Policy) MarshalJSON

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

func (Policy) Name

func (p Policy) Name() string

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{}

func (Policy) TargetRef

func (p Policy) TargetRef() ObjRef

func (Policy) Unstructured

func (p Policy) Unstructured() *unstructured.Unstructured

type PolicyCRD

type PolicyCRD struct {
	// contains filtered or unexported fields
}

func (PolicyCRD) CRD

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

func (p PolicyCRD) IsInherited() 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 {
	// contains filtered or unexported fields
}

func New

func (*PolicyManager) AddPolicy

func (p *PolicyManager) AddPolicy(unstrucutredPolicy unstructured.Unstructured) error

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

func (p *PolicyManager) GetPolicy(namespacedName string) (Policy, bool)

func (*PolicyManager) Init

func (p *PolicyManager) Init(ctx context.Context) error

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

func (*PolicyManager) PoliciesAttachedTo

func (p *PolicyManager) PoliciesAttachedTo(objRef ObjRef) []Policy

Jump to

Keyboard shortcuts

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