k8s

package
v0.0.0-...-71653c3 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OwnershipIndexField = "metadata.ownerReference"
)
View Source
const StatusFieldName = "Status"

Variables

View Source
var (
	CommonConditionReasons = map[string]CommonCondition{
		"Finalizing":         {RemovalVerb: "Finalized", Reasons: []string{"FinalizationFailed", "FinalizerRemovalFailed", "InProgress"}},
		"FailedToInitialize": {RemovalVerb: "Initialized", Reasons: []string{"InternalError"}},
		"Invalid":            {RemovalVerb: "Valid", Reasons: []string{"ControllerNotAccessible", "ControllerNotFound", "ControllerReferenceMissing", "InternalError"}},
	}
)

Functions

func AddOwnershipIndex

func AddOwnershipIndex(ctx context.Context, fieldIndexes client.FieldIndexer, ownedObjType client.Object) error

func ClearStaleConditions

func ClearStaleConditions(conditions *[]metav1.Condition, currentGeneration int64)

func GetCondition

func GetCondition(conditions []metav1.Condition, conditionType string) *metav1.Condition

func GetConditionMessage

func GetConditionMessage(conditions []metav1.Condition, conditionType string) string

func GetConditionReason

func GetConditionReason(conditions []metav1.Condition, conditionType string) string

func GetConditionStatus

func GetConditionStatus(conditions []metav1.Condition, conditionType string) *metav1.ConditionStatus

func GetStatusOfType

func GetStatusOfType[T any](o client.Object) (T, bool)

func HasCondition

func HasCondition(conditions []metav1.Condition, conditionType string) bool

func IndexGetOwnerReferencesOf

func IndexGetOwnerReferencesOf(obj client.Object) []string

func IsConditionStatusOneOf

func IsConditionStatusOneOf(conditions []metav1.Condition, conditionType string, statuses ...metav1.ConditionStatus) bool

func MustGetStatusOfType

func MustGetStatusOfType[T any](o client.Object) T

func NewReconciliation

func NewReconciliation[O client.Object](ctx context.Context, c client.Client, req ctrl.Request, object O, finalizerValue string, finalizerFunc func(*Reconciliation[O]) error) (*Reconciliation[O], *Result)

func OwnedBy

func OwnedBy(scheme *runtime.Scheme, owner client.Object) client.ListOption

func RemoveConditionIfReasonIsOneOf

func RemoveConditionIfReasonIsOneOf(conditions *[]metav1.Condition, conditionType string, reasons ...string) bool

func SetCondition

func SetCondition(conditions *[]metav1.Condition, conditionType string, status metav1.ConditionStatus, reason, message string, args ...interface{}) bool

func SetConditionsGenerationAndTransitionTime

func SetConditionsGenerationAndTransitionTime(conditions []metav1.Condition, generation int64)

Types

type CommonCondition

type CommonCondition struct {
	RemovalVerb string
	Reasons     []string
}

type ConditionsProvider

type ConditionsProvider interface {
	GetConditions() []metav1.Condition
}

type ControlleeObjectStatus

type ControlleeObjectStatus interface {
	SetInvalidDueToControllerNotAccessible(message string, args ...interface{}) bool
	SetInvalidDueToControllerNotFound(message string, args ...interface{}) bool
	SetInvalidDueToControllerReferenceMissing(message string, args ...interface{}) bool
	SetInvalidDueToInternalError(message string, args ...interface{}) bool
	SetValidIfInvalidDueToAnyOf(reason ...string) bool
}

type FinalizingObjectStatus

type FinalizingObjectStatus interface {
	IsFinalizing() bool
	SetFinalizingDueToFinalizationFailed(message string, args ...interface{}) bool
	SetFinalizingDueToFinalizerRemovalFailed(message string, args ...interface{}) bool
	SetFinalizingDueToInProgress(message string, args ...interface{}) bool
	SetFinalizedIfFinalizingDueToAnyOf(reason ...string) bool
}

type InitializableObjectStatus

type InitializableObjectStatus interface {
	SetFailedToInitializeDueToInternalError(message string, args ...interface{}) bool
	SetInitializedIfFailedToInitializeDueToAnyOf(reason ...string) bool
}

type Reconciliation

type Reconciliation[O client.Object] struct {
	Ctx    context.Context
	Client client.Client
	Object O
	// contains filtered or unexported fields
}

func (*Reconciliation[O]) FinalizeObjectIfDeleted

func (r *Reconciliation[O]) FinalizeObjectIfDeleted() *Result

func (*Reconciliation[O]) GetRequiredController

func (r *Reconciliation[O]) GetRequiredController(controller client.Object) *Result

func (*Reconciliation[O]) InitializeObject

func (r *Reconciliation[O]) InitializeObject() *Result

func (*Reconciliation[O]) UpdateStatus

func (r *Reconciliation[O]) UpdateStatus() *Result

type Result

type Result struct {
	Error        error
	Requeue      bool
	RequeueAfter *time.Duration
}

func Continue

func Continue() *Result

func DoNotRequeue

func DoNotRequeue() *Result

func Requeue

func Requeue() *Result

func RequeueAfter

func RequeueAfter(interval time.Duration) *Result

func RequeueDueToError

func RequeueDueToError(err error) *Result

func (*Result) ToResultAndError

func (r *Result) ToResultAndError() (ctrl.Result, error)

Jump to

Keyboard shortcuts

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