utils

package
v1.6.2-rc3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiextensionsJsonToKyvernoConditions added in v1.3.4

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

ApiextensionsJsonToKyvernoConditions takes in user-provided conditions in abstract apiextensions.JSON form and converts it into []kyverno.Condition or kyverno.AnyAllConditions according to its content. it also helps in validating the condtions as it returns an error when the conditions are provided wrongfully by the user.

func CRDsInstalled added in v1.3.2

func CRDsInstalled(discovery client.IDiscovery) bool

CRDsInstalled checks if the Kyverno CRDs are installed or not

func ContainsNamepace added in v0.10.0

func ContainsNamepace(patterns []string, ns string) bool

ContainsNamepace check if namespace satisfies any list of pattern(regex)

func ContainsPod added in v1.5.0

func ContainsPod(list []string, element string) bool

func ContainsString added in v0.10.0

func ContainsString(list []string, element string) bool

ContainsString checks if the string is contained in the list

func ConvertResource added in v1.2.0

func ConvertResource(raw []byte, group, version, kind, namespace string) (unstructured.Unstructured, error)

ConvertResource converts raw bytes to an unstructured object

func ExtractResources added in v1.2.0

func ExtractResources(newRaw []byte, request *v1beta1.AdmissionRequest) (unstructured.Unstructured, unstructured.Unstructured, error)

ExtractResources extracts the new and old resource as unstructured

func GetPolicy added in v1.2.0

func GetPolicy(bytes []byte) (clusterPolicies []*v1.ClusterPolicy, err error)

GetPolicy - extracts policies from YAML bytes

func HigherThanKubernetesVersion added in v1.2.0

func HigherThanKubernetesVersion(client *client.Client, log logr.Logger, major, minor, patch int) bool

HigherThanKubernetesVersion compare Kubernetes client version to user given version

func JoinPatches added in v0.8.0

func JoinPatches(patches [][]byte) []byte

JoinPatches joins array of serialized JSON patches to the single JSONPatch array

func MarshalPolicy added in v1.2.0

func MarshalPolicy(policy v1.ClusterPolicy) []byte

MarshalPolicy accurately marshals a policy to JSON, normal marshal would cause empty sub structs in policy to be non nil. TODO This needs to be removed. A simpler way to encode and decode Policy is needed.

func NewKubeClient added in v0.8.0

func NewKubeClient(config *rest.Config) (kubernetes.Interface, error)

NewKubeClient returns a new kubernetes client

func NormalizeSecret added in v1.6.1

func NormalizeSecret(resource *unstructured.Unstructured) (unstructured.Unstructured, error)

func SkipSubResources added in v1.6.2

func SkipSubResources(kind string) bool

SkipSubResources check to skip list of resources which don't have group.

func SliceContains added in v1.2.0

func SliceContains(slice []string, values ...string) bool

SliceContains checks whether values are contained in slice

func SplitYAMLDocuments added in v1.2.0

func SplitYAMLDocuments(yamlBytes []byte) (policies [][]byte, error error)

SplitYAMLDocuments reads the YAML bytes per-document, unmarshals the TypeMeta information from each document and returns a map between the GroupVersionKind of the document and the document bytes

Types

This section is empty.

Jump to

Keyboard shortcuts

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