utils

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: Apache-2.0 Imports: 22 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 check if the string is contains in a 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 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