utils

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoConfigPolicyMessageTest added in v0.11.0

func DoConfigPolicyMessageTest(clientHubDynamic dynamic.Interface,
	gvrConfigPolicy schema.GroupVersionResource, namespace string, policyName string,
	templateIdx int, timeout int, expectedMsg string,
)

func GetClusterLevelWithTimeout

func GetClusterLevelWithTimeout(
	clientHubDynamic dynamic.Interface,
	gvr schema.GroupVersionResource,
	name string,
	wantFound bool,
	timeout int,
) *unstructured.Unstructured

GetClusterLevelWithTimeout keeps polling to get the object for timeout seconds until wantFound is met (true for found, false for not found)

func GetComplianceState

func GetComplianceState(managedPlc *unstructured.Unstructured) (result interface{})

GetComplianceState parses status field of configurationPolicy to get compliance

func GetFieldFromSecret

func GetFieldFromSecret(secret *unstructured.Unstructured, field string) (result interface{})

GetFieldFromSecret parses data field of secrets for the specified field

func GetLastEvaluated added in v0.7.0

func GetLastEvaluated(configPolicy *unstructured.Unstructured) (string, int64)

GetLastEvaluated parses the configuration policy and returns the status.lastEvaluated and status.lastEvaluatedGeneration fields. If they are not set, then default null values are returned.

func GetMatchingEvents

func GetMatchingEvents(
	client kubernetes.Interface, namespace, objName, reasonRegex, msgRegex string, timeout int,
) []corev1.Event

func GetMetrics added in v0.10.0

func GetMetrics(metricPatterns ...string) []string

GetMetrics execs into the config-policy-controller pod and curls the metrics endpoint, filters the response with the given patterns, and returns the value(s) for the matching metric(s).

func GetServerVersion added in v0.12.0

func GetServerVersion(clientManaged kubernetes.Interface) string

func GetStatusMessage

func GetStatusMessage(managedPlc *unstructured.Unstructured) (result interface{})

GetStatusMessage parses status field to get message

func GetWithTimeout

func GetWithTimeout(
	clientHubDynamic dynamic.Interface,
	gvr schema.GroupVersionResource,
	name, namespace string,
	wantFound bool,
	timeout int,
) *unstructured.Unstructured

GetWithTimeout keeps polling to get the object for timeout seconds until wantFound is met (true for found, false for not found)

func Kubectl

func Kubectl(args ...string)

Kubectl executes kubectl commands

func ParseYaml

func ParseYaml(file string) *unstructured.Unstructured

ParseYaml read given yaml file and unmarshal it to &unstructured.Unstructured{}

func Pause

func Pause(s uint)

Pause sleep for given seconds

Types

This section is empty.

Jump to

Keyboard shortcuts

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