utils

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddElementToContext added in v1.10.0

func AddElementToContext(ctx engineapi.PolicyContext, element interface{}, index, nesting int, elementScope *bool) error

func ApplyPatchNew

func ApplyPatchNew(resource, patch []byte) ([]byte, error)

ApplyPatchNew patches given resource with given joined patches

func ApplyPatches

func ApplyPatches(resource []byte, patches [][]byte) ([]byte, error)

ApplyPatches patches given resource with given patches and returns patched document return original resource if any error occurs

func EvaluateList added in v1.10.0

func EvaluateList(jmesPath string, ctx enginecontext.EvalInterface) ([]interface{}, error)

func ExtractMatchingImages added in v1.10.0

func ExtractMatchingImages(
	resource unstructured.Unstructured,
	context enginecontext.Interface,
	rule kyvernov1.Rule,
	cfg config.Configuration,
) ([]apiutils.ImageInfo, string, error)

func GetMatchingImages added in v1.10.0

func GetMatchingImages(images map[string]map[string]apiutils.ImageInfo, rule kyvernov1.Rule) ([]apiutils.ImageInfo, string)

func ImageMatches added in v1.10.0

func ImageMatches(image string, imagePatterns []string) bool

func InvertedElement added in v1.10.0

func InvertedElement(elements []interface{})

InvertedElement inverted the order of element for patchStrategicMerge policies as kustomize patch revering the order of patch resources.

func IsDeleteRequest added in v1.10.0

func IsDeleteRequest(ctx engineapi.PolicyContext) bool

func IsEmptyUnstructured added in v1.10.0

func IsEmptyUnstructured(u *unstructured.Unstructured) bool

func IsImageVerified added in v1.10.0

func IsSameRuleResponse added in v1.11.2

func IsSameRuleResponse(r1 *engineapi.RuleResponse, r2 *engineapi.RuleResponse) bool

func IsUpdateRequest added in v1.11.2

func IsUpdateRequest(ctx engineapi.PolicyContext) bool

func MatchesException added in v1.12.0

func MatchesException(
	polexs []kyvernov2beta1.PolicyException,
	policyContext engineapi.PolicyContext,
	logger logr.Logger,
) *kyvernov2beta1.PolicyException

MatchesException takes a list of exceptions and checks if there is an exception applies to the incoming resource. It returns the matched policy exception.

func MatchesResourceDescription added in v1.10.0

func MatchesResourceDescription(
	resource unstructured.Unstructured,
	rule kyvernov1.Rule,
	admissionInfo kyvernov1beta1.RequestInfo,
	namespaceLabels map[string]string,
	policyNamespace string,
	gvk schema.GroupVersionKind,
	subresource string,
	operation kyvernov1.AdmissionOperation,
) error

matchesResourceDescription checks if the resource matches resource description of the rule or not

func TransformConditions added in v1.10.0

func TransformConditions(original apiextensions.JSON) (interface{}, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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