predicate

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package predicate defines Predicates used by Controllers to filter Events before they are provided to EventHandlers.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Funcs

type Funcs struct {
	// Create returns true if the Create event should be processed
	CreateFunc func(event.CreateEvent) bool

	// Delete returns true if the Delete event should be processed
	DeleteFunc func(event.DeleteEvent) bool

	// Update returns true if the Update event should be processed
	UpdateFunc func(event.UpdateEvent) bool

	// Generic returns true if the Generic event should be processed
	GenericFunc func(event.GenericEvent) bool
}

Funcs is a function that implements Predicate.

Example

This example creates a new Predicate to drop Update Events where the Generation has not changed.

package main

import (
	"sigs.k8s.io/controller-runtime/pkg/event"
	"sigs.k8s.io/controller-runtime/pkg/predicate"
)

var p predicate.Predicate

// This example creates a new Predicate to drop Update Events where the Generation has not changed.
func main() {
	p = predicate.Funcs{
		UpdateFunc: func(e event.UpdateEvent) bool {
			return e.MetaOld.GetGeneration() != e.MetaNew.GetGeneration()
		},
	}
}
Output:

func (Funcs) Create

func (p Funcs) Create(e event.CreateEvent) bool

Create implements Predicate

func (Funcs) Delete

func (p Funcs) Delete(e event.DeleteEvent) bool

Delete implements Predicate

func (Funcs) Generic

func (p Funcs) Generic(e event.GenericEvent) bool

Generic implements Predicate

func (Funcs) Update

func (p Funcs) Update(e event.UpdateEvent) bool

Update implements Predicate

type Predicate

type Predicate interface {
	// Create returns true if the Create event should be processed
	Create(event.CreateEvent) bool

	// Delete returns true if the Delete event should be processed
	Delete(event.DeleteEvent) bool

	// Update returns true if the Update event should be processed
	Update(event.UpdateEvent) bool

	// Generic returns true if the Generic event should be processed
	Generic(event.GenericEvent) bool
}

Predicate filters events before enqueuing the keys.

type ResourceVersionChangedPredicate

type ResourceVersionChangedPredicate struct {
	Funcs
}

ResourceVersionChangedPredicate implements a default update predicate function on resource version change

func (ResourceVersionChangedPredicate) Update

Update implements default UpdateEvent filter for validating resource version change

Jump to

Keyboard shortcuts

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