Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Btoi

func Btoi(b bool) int

Btoi converts boolean to int

func CRDInstalled

func CRDInstalled(discovery client.IDiscovery, log logr.Logger) bool

CRDInstalled to check if the CRD is installed or not

func CleanupOldCrd

func CleanupOldCrd(client *dclient.Client, log logr.Logger)

CleanupOldCrd deletes any existing NamespacedPolicyViolation resources in cluster If resource violates policy, new Violations will be generated

func ContainsNamepace

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

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

func ContainsString

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

ContainsString check if the string is contains in a list

func ConvertResource

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

convertResource converts raw bytes to an unstructured object

func ExtractResources

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

extracts the new and old resource as unstructured

func GetPolicy

func GetPolicy(path string) (clusterPolicies []*v1.ClusterPolicy, errors []error)

GetPolicy - Extracts policies from a YAML

func HigherThanKubernetesVersion

func HigherThanKubernetesVersion(client *client.Client, log logr.Logger, k8smajor, k8sminor, k8ssub int) bool

HigherThanKubernetesVersion compare kuberneates client version to user given version

func JoinPatches

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

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

func MarshalPolicy

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

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

NewKubeClient returns a new kubernetes client

func SliceContains

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

func SplitYAMLDocuments

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.