common

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// OpenSCAPExitCodeCompliant defines a success coming from OpenSCAP
	OpenSCAPExitCodeCompliant string = "0"
	// OpenSCAPExitCodeNonCompliant defines a non-compliance error coming from OpenSCAP
	OpenSCAPExitCodeNonCompliant string = "2"
	// PodUnschedulableExitCode is a custom error that indicates that we couldn't schedule the pod
	PodUnschedulableExitCode string = "unschedulable"

	// taken from k8sutil
	ForceRunModeEnv             = "OSDK_FORCE_RUN_MODE"
	LocalRunMode    RunModeType = "local"
	ClusterRunMode  RunModeType = "cluster"
)

Variables

This section is empty.

Functions

func CallCustomHandler

func CallCustomHandler(err error) (reconcile.Result, error)

CallCustomHandler calls the custom handler for an error if it has one

func ContainsFinalizer

func ContainsFinalizer(slice []string, f string) bool

ContainsFinalizer checks if the given finalizer `f` is in the given list of finalizers

func GenerateEventForResult

func GenerateEventForResult(recorder record.EventRecorder, obj runtime.Object, objInfo metav1.Object, result compv1alpha1.ComplianceScanStatusResult)

func GetComplianceOperatorName

func GetComplianceOperatorName() string

GetComplianceOperatorName gets the name that the operator is currently running with.

func GetComplianceOperatorNamespace

func GetComplianceOperatorNamespace() string

GetComplianceOperatorNamespace gets the namespace that the operator is currently running on.

func GetWatchNamespace

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the Namespace the operator should be watching for changes. Eventually the watch namespace will not be used when OLM begins to support only the AllNamespaces install type. To support AllNamespaces initially, GetWatchNamespace will return the operator namespace if WATCH_NAMESPACE is empty.

func HasCustomHandler

func HasCustomHandler(err error) bool

HasCustomHandler returns whether the error has a custom handler or not

func IsRetriable

func IsRetriable(err error) bool

IsRetriable returns whether the error is retriable or not using the NonRetriableCtrlError interface

func RemoveFinalizer

func RemoveFinalizer(slice []string, f string) (result []string)

RemoveFinalizer removes the given finalizer `f` from the given list of finalizers

func ReturnWithRetriableError

func ReturnWithRetriableError(log logr.Logger, err error) (reconcile.Result, error)

ReturnWithRetriableError will check if the error is retriable we return it. If it's not retriable, we return nil so the reconciler doesn't keep looping.

Types

type ErrorHandler

type ErrorHandler func() (reconcile.Result, error)

ErrorHandler defines a function that handles errors It can be used in a non retriable or a retriable error.

type NonRetriableCtrlError

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

NonRetriableCtrlError wraps errors with the addition of having the information for the error being non-retriable

func NewNonRetriableCtrlError

func NewNonRetriableCtrlError(errorFmt string, args ...interface{}) *NonRetriableCtrlError

NewNonRetriableCtrlError creates an error with the RetriableCtrlError interface

func NewRetriableCtrlErrorWithCustomHandler

func NewRetriableCtrlErrorWithCustomHandler(customHandler ErrorHandler, errorFmt string, args ...interface{}) *NonRetriableCtrlError

NewRetriableCtrlErrorWithCustomHandler creates an error with the RetriableCtrlError interface This error is retriable has a custom handler

func WrapNonRetriableCtrlError

func WrapNonRetriableCtrlError(err error) *NonRetriableCtrlError

WrapNonRetriableCtrlError wraps an error with the RetriableCtrlError interface

func (NonRetriableCtrlError) Error

func (cerr NonRetriableCtrlError) Error() string

func (NonRetriableCtrlError) HasCustomHandler

func (cerr NonRetriableCtrlError) HasCustomHandler() bool

HasCustomHandler checks whether an error has a custom handler

func (NonRetriableCtrlError) IsRetriable

func (cerr NonRetriableCtrlError) IsRetriable() bool

IsRetriable exposes if the error is retriable or not

type RunModeType

type RunModeType string

type SafeRecorder

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

func NewSafeRecorder

func NewSafeRecorder(name string, mgr manager.Manager) *SafeRecorder

func (*SafeRecorder) AnnotatedEventf

func (sr *SafeRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})

AnnotatedEventf is just like eventf, but with annotations attached

func (*SafeRecorder) Event

func (sr *SafeRecorder) Event(object runtime.Object, eventtype, reason, message string)

func (*SafeRecorder) Eventf

func (sr *SafeRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

Eventf is just like Event, but with Sprintf for the message field.

type TimeoutError added in v0.1.60

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

Timeout Error

func NewTimeoutError added in v0.1.60

func NewTimeoutError(errorFmt string, args ...interface{}) *TimeoutError

NewTimeoutError creates an error with the RetriableCtrlError interface

func (TimeoutError) Error added in v0.1.60

func (t TimeoutError) Error() string

Jump to

Keyboard shortcuts

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