utils

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package utils contains utilities to manage the external network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteClusterRoleBinding

func DeleteClusterRoleBinding(ctx context.Context, cl client.Client, obj client.Object) error

DeleteClusterRoleBinding deletes the cluster role bindings owned by the given object.

func EnsureMetrics

func EnsureMetrics(ctx context.Context,
	cl client.Client, s *runtime.Scheme,
	metrics *networkingv1beta1.Metrics, owner metav1.Object) error

EnsureMetrics ensures that the metrics service and service monitor are created or deleted.

func EnsureServiceAccountAndClusterRoleBinding

func EnsureServiceAccountAndClusterRoleBinding(ctx context.Context, cl client.Client, s *runtime.Scheme,
	deploy *networkingv1beta1.DeploymentTemplate, owner client.Object, clusterRoleName string) error

EnsureServiceAccountAndClusterRoleBinding ensures that the service account and the cluster role binding are created or deleted.

func GetIfExists

func GetIfExists[T any](m map[string]interface{}, key string) (*T, bool)

GetIfExists returns the value of a key in a map casting its type, or nil if the key is not present or the type is wrong.

func GetValueOrDefault

func GetValueOrDefault(m map[string]interface{}, key, defaultValue string) string

GetValueOrDefault returns the value of a key in a map, or a default value if the key is not present.

func IgnoreAPINotFoundError

func IgnoreAPINotFoundError(err error) error

IgnoreAPINotFoundError ignores the error if it is an API not found error (the CRD is not installed).

func KindToResource

func KindToResource(kind string) string

KindToResource returns the resource name for a given kind.

func NewOwnerEnqueuer

func NewOwnerEnqueuer(ownerKind string) handler.EventHandler

NewOwnerEnqueuer returns a new OwnerEnqueuer.

func ParseEndpoint

func ParseEndpoint(endpoint map[string]interface{}) *networkingv1beta1.EndpointStatus

ParseEndpoint parses an endpoint from a map.

func ParseGroupVersionResource

func ParseGroupVersionResource(gvr string) (schema.GroupVersionResource, error)

ParseGroupVersionResource parses a GroupVersionResource from a string in the form group/version/resource.

func ParseInternalEndpoint

func ParseInternalEndpoint(internalEndpoint map[string]interface{}) *networkingv1beta1.InternalGatewayEndpoint

ParseInternalEndpoint parses an internal endpoint from a map.

func ParseRef

func ParseRef(ref map[string]interface{}) *corev1.ObjectReference

ParseRef parses an ObjectReference from a map.

func RenderTemplate

func RenderTemplate(obj, data interface{}, forceString bool) (interface{}, error)

RenderTemplate renders a template.

func ResourceToKind

func ResourceToKind(gvr schema.GroupVersionResource, kubeClient kubernetes.Interface) (string, error)

ResourceToKind returns the kind name for a given resource.

func TranslateMap

func TranslateMap(obj interface{}) map[string]string

TranslateMap translates a map[string]interface{} to a map[string]string.

Types

type OwnerEnqueuer

type OwnerEnqueuer struct {
	// contains filtered or unexported fields
}

OwnerEnqueuer is an event handler that enqueues the owner of the object for a given kind.

func (*OwnerEnqueuer) Create

Create enqueues the owner of the object for a given kind.

func (*OwnerEnqueuer) Delete

Delete enqueues the owner of the object for a given kind.

func (*OwnerEnqueuer) Generic

Generic enqueues the owner of the object for a given kind.

func (*OwnerEnqueuer) Update

Update enqueues the owner of the object for a given kind.

Jump to

Keyboard shortcuts

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