utils

package
v0.0.0-...-2e8aeb9 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package utils collects all the logic shared between different controllers

Package utils collects all the logic shared between different controllers

Index

Constants

View Source
const (
	// LogInfoLevel -> level associated with informational messages.
	LogInfoLevel = 0
	// LogDebugLevel -> level associated with debug messages.
	LogDebugLevel = 2
)

Variables

This section is empty.

Functions

func CheckLabels

func CheckLabels(ns *corev1.Namespace, matchLabels map[string]string) bool

CheckLabels verifies whether a namespace is characterized by a set of required labels.

func CheckSelectorLabel

func CheckSelectorLabel(ctx context.Context, k8sClient client.Client, namespaceName string, matchLabels map[string]string) (bool, error)

CheckSelectorLabel checks if the given namespace belongs to the whitelisted namespaces where to perform reconciliation.

func CheckSingleLabel

func CheckSingleLabel(obj client.Object, label, value string) bool

CheckSingleLabel checks if the instance has the label and value.

func Contains

func Contains(slice []string, value string) bool

Contains checks if the value is contained in the slice.

func EnforceObjectAbsence

func EnforceObjectAbsence(ctx context.Context, c client.Client, obj client.Object, kind string) error

EnforceObjectAbsence deletes a Kubernetes object and prints the appropriate log messages, without failing if it does not exist.

func FromResult

func FromResult(result controllerutil.OperationResult) int

FromResult returns a logger level, given the result of a CreateOrUpdate operation.

func HTTPGet

func HTTPGet(ctx context.Context, url string, timeout time.Duration) (statusCode int, contents []byte, err error)

HTTPGet performs a HTTP GET request to the given URL.

func HTTPGetJSONIntoStruct

func HTTPGetJSONIntoStruct(ctx context.Context, url string, obj interface{}, timeout time.Duration) (statusCode int, err error)

HTTPGetJSONIntoStruct performs a HTTP GET request to the given URL and unmarshals the response into the given struct.

func LogConstructor

func LogConstructor(logger logr.Logger, ctrlname string) func(*reconcile.Request) logr.Logger

LogConstructor returns a constructor for a logger to be used by the given controller.

func LongThreshold

func LongThreshold() time.Duration

LongThreshold returns the duration used to trigger tracing printing.

func MatchOneInStringSlices

func MatchOneInStringSlices(a, b []string) bool

MatchOneInStringSlices checks if there's at least one common string between two string slices.

func ParseDockerDirectory

func ParseDockerDirectory(name string) string

ParseDockerDirectory returns a valid Docker image directory.

Types

This section is empty.

Directories

Path Synopsis
Package args groups the methods used for utils args.
Package args groups the methods used for utils args.
Package restcfg contains utility functions to deal with rest configs.
Package restcfg contains utility functions to deal with rest configs.
Package tests contains utilities for tests.
Package tests contains utilities for tests.

Jump to

Keyboard shortcuts

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