utils

package
v1.8.0-rc6 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PolicyAnnotation = "policies.kyverno.io/last-applied-patches"
)

Variables

View Source
var OperationToPastTense = map[string]string{
	"add":     "added",
	"remove":  "removed",
	"replace": "replaced",
	"move":    "moved",
	"copy":    "copied",
	"test":    "tested",
}

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 dclient.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 ContainsString added in v0.10.0

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

ContainsString checks if the string is contained in the list

func ContainsWildcardPatterns added in v1.8.0

func ContainsWildcardPatterns(patterns []string, key string) bool

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 CopyMap added in v1.7.0

func CopyMap(m map[string]interface{}) map[string]interface{}

CopyMap creates a full copy of the target map

func CopySlice added in v1.7.0

func CopySlice(s []interface{}) []interface{}

CopySlice creates a full copy of the target slice

func CopySliceOfMaps added in v1.7.0

func CopySliceOfMaps(s []map[string]interface{}) []interface{}

CopySliceOfMaps creates a full copy of the target slice

func ExtractResources added in v1.2.0

ExtractResources extracts the new and old resource as unstructured

func GenerateAnnotationPatches added in v1.7.0

func GenerateAnnotationPatches(engineResponses []*response.EngineResponse, log logr.Logger) [][]byte

func HigherThanKubernetesVersion added in v1.2.0

func HigherThanKubernetesVersion(client discovery.ServerVersionInterface, log logr.Logger, major, minor, patch int) bool

HigherThanKubernetesVersion compare Kubernetes client version to user given version

func NormalizeSecret added in v1.6.1

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

func OverrideRuntimeErrorHandler added in v1.7.2

func OverrideRuntimeErrorHandler()

func SliceContains added in v1.2.0

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

SliceContains checks whether values are contained in slice

func ToMap added in v1.7.0

func ToMap(data interface{}) (map[string]interface{}, error)

Types

type RulePatch added in v1.7.0

type RulePatch struct {
	RuleName string `json:"rulename"`
	Op       string `json:"op"`
	Path     string `json:"path"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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