Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNoClientInContext = errors.New("no client in context")
)
Functions ¶
func DoNothing ¶
func DoNothing() controllerutil.MutateFn
func OwnedBy ¶
func OwnedBy(owner client.Object) []client.ListOption
OwnedBy filters for resources owned by the given owner based on controller references. It requires that the index ".metadata.controller" is registered
func OwnedByLabel ¶
func OwnedByLabel(owner client.Object) []client.ListOption
OwnedByLabel should only be used when ownership could not be determined by controllerRef because of cross-namespace references
func WithClient ¶
func WithClient(ctx context.Context, c JanitorClient) context.Context
Types ¶
type JanitorClient ¶
type JanitorClient interface {
ScopedClient
// Cleanup cleans up all objects of type objectList that were not created or updated during the current reconciliation.
Cleanup(ctx context.Context, objectList types.ObjectList, listOpts []client.ListOption) (deleted int, err error)
// Wrap wraps the given function with a cleanup of all objects that were not created or updated during the current reconciliation.
Wrap(ctx context.Context, objectList types.ObjectList, listOpts []client.ListOption, f func(ScopedClient) bool) (deleted int, err error)
// CleanupAll cleans up all objects that were not created or updated during the current reconciliation.
CleanupAll(ctx context.Context, listOpts []client.ListOption) (int, error)
// AddKnownTypeToState ensures that the given object type is tracked in the state.
// This means that the janitor will clean up all objects of this type that were not created or updated during the current reconciliation.
AddKnownTypeToState(obj types.Object)
}
func ClientFromContext ¶
func ClientFromContext(ctx context.Context) (JanitorClient, bool)
func ClientFromContextOrDie ¶
func ClientFromContextOrDie(ctx context.Context) JanitorClient
func NewJanitorClient ¶
func NewJanitorClient(c ScopedClient) JanitorClient
type ScopedClient ¶
type ScopedClient interface {
Scheme() *runtime.Scheme
CreateOrUpdate(ctx context.Context, obj client.Object, mutate controllerutil.MutateFn) (controllerutil.OperationResult, error)
Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error
List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
// AnyChanged returns true if any object has been created or updated
AnyChanged() bool
// Ready returns true if all objects are ready
AllReady() bool
// Reset resets the state of this client instance
Reset()
}
func NewScopedClient ¶
func NewScopedClient(c client.Client, environment string) ScopedClient
Click to show internal directories.
Click to hide internal directories.