utils

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Btoi added in v0.8.0

func Btoi(b bool) int

Btoi converts boolean to int

func CRDInstalled added in v0.9.0

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

CRDInstalled to check if the CRD is installed or not

func CleanupOldCrd added in v1.1.0

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 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 check if the string is contains in a list

func ConvertResource added in v1.1.6

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.1.6

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

extracts the new and old resource as unstructured

func HigherThanKubernetesVersion added in v1.1.6

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

HigherThanKubernetesVersion compare kuberneates 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.1.5

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.1.6

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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