Documentation ¶
Overview ¶
Package condition contains interfaces and primitives for use with our await logic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type All ¶
type All struct {
// contains filtered or unexported fields
}
func NewAll ¶
NewAll joins multiple Satisfiers and resolves when all of them are simultaneously satisfied. The conditions should all apply to the same object.
func (*All) Object ¶
func (ac *All) Object() *unstructured.Unstructured
Object returns the first condition's current state.
type Custom ¶
type Custom struct {
// contains filtered or unexported fields
}
Custom waits for a specific ".status.condition" matching a user-provided expression.
func NewCustom ¶
func NewCustom( ctx context.Context, source Source, logger logger, uns *unstructured.Unstructured, expr string, ) (*Custom, error)
NewCustom creates a new Custom condition.
The expression's syntax is identical to `kubectl wait --for=condition=`. A condition type is required, optionally followed by a value:
"condition=Foo" or "condition=Foo=Bar"
The "condition=" prefix is also optional.
func (*Custom) Object ¶
func (cc *Custom) Object() *unstructured.Unstructured
Object is a passthrough to the underlying Observer.
type Deleted ¶
type Deleted struct {
// contains filtered or unexported fields
}
Deleted condition succeeds when GET on a resource 404s or when a Deleted event is received for the resource.
func NewDeleted ¶
func NewDeleted( ctx context.Context, source Source, getter objectGetter, logger logger, obj *unstructured.Unstructured, ) (*Deleted, error)
NewDeleted constructs a new Deleted condition.
func (*Deleted) Object ¶
func (dc *Deleted) Object() *unstructured.Unstructured
Object returns the last-known state of the object we're deleting.
type DynamicSource ¶
type DynamicSource struct {
// contains filtered or unexported fields
}
DynamicSource establishes Informers against the cluster.
func NewDynamicSource ¶
func NewDynamicSource( ctx context.Context, clientset *clients.DynamicClientSet, namespace string, ) *DynamicSource
NewDynamicSource creates a new DynamicEventSource which will lazily establish a single dynamicinformer.DynamicSharedInformerFactory. Subsequent calls to Start will spawn informers.GenericInformer from that factory.
func (*DynamicSource) Start ¶
func (des *DynamicSource) Start(_ context.Context, gvk schema.GroupVersionKind) (<-chan watch.Event, error)
Start establishes an Informer against the cluster for the given GVK.
type Failure ¶
type Failure struct { Immediate // contains filtered or unexported fields }
Failure is a no-op condition which raises an error when it is checked. This is primarily useful for testing.
type Immediate ¶
type Immediate struct {
// contains filtered or unexported fields
}
Immediate is a no-op condition which is always satisfied. This is primarily used for skip-await behavior and testing.
func NewImmediate ¶
func NewImmediate(logger logger, obj *unstructured.Unstructured) Immediate
NewImmediate creates a new Immediate condition.
func (Immediate) Object ¶
func (i Immediate) Object() *unstructured.Unstructured
Object returns the observer's underlying object.
type JSONPath ¶
type JSONPath struct {
// contains filtered or unexported fields
}
JSONPath waits for the observed object to match a user-provided JSONPath expression.
func (*JSONPath) Object ¶
func (jp *JSONPath) Object() *unstructured.Unstructured
Object is a passthrough to the underlying Observer.
type Never ¶
type Never struct {
Immediate
}
Never is a no-op condition which is never satisfied. This is primarily useful for tests.
func NewNever ¶
func NewNever(obj *unstructured.Unstructured) *Never
NewNever creates a new Never condition.
type ObjectObserver ¶
type ObjectObserver struct {
// contains filtered or unexported fields
}
ObjectObserver observes the given resource and keeps track of its last-known state.
func NewObjectObserver ¶
func NewObjectObserver( ctx context.Context, source Source, obj *unstructured.Unstructured, ) *ObjectObserver
NewObjectObserver creates a new ObjectObserver that tracks changes to the provided object
func (*ObjectObserver) Object ¶
func (oo *ObjectObserver) Object() *unstructured.Unstructured
Object returns the last-known state of the observed object.
type Observer ¶
type Observer interface { // Range iterates over all events visible to the Observer. The caller is // responsible for invoking Observe as part of the provided callback. Range // can be used to customize setup and teardown behavior if the Observer // wraps another Observer. Range(func(watch.Event) bool) // Observe handles events and can optionally update the Observer's state. // This should be invoked by the caller and not during Range. Observe(watch.Event) error }
Observer acts on a watch.Event Source. Range is responsible for filtering events to only those relevant to the Observer, and Observe optionally updates the Observer's state.
func NewChildObserver ¶
func NewChildObserver( ctx context.Context, source Source, owner *unstructured.Unstructured, gvk schema.GroupVersionKind, ) Observer
NewChildObserver creates a new ChildObserver subscribed to children of the owner with the given GVK.
func NewObserver ¶
func NewObserver( ctx context.Context, source Source, gvk schema.GroupVersionKind, keep func(*unstructured.Unstructured) bool, ) Observer
NewObserver returns a new Observer with a watch.Event channel configured for the given GVK and filtered according to the given "keep" function.
type On ¶
type On struct {
// contains filtered or unexported fields
}
On is satisfied when it observes a specific event.
func NewOn ¶
func NewOn( ctx context.Context, source Source, obj *unstructured.Unstructured, want watch.Event, ) *On
NewOn creates a new On condition.
func (*On) Object ¶
func (o *On) Object() *unstructured.Unstructured
Object returns the observer's underlying object.
type Ready ¶
type Ready struct {
// contains filtered or unexported fields
}
func NewReady ¶
func NewReady( ctx context.Context, source Source, logger logger, obj *unstructured.Unstructured, ) *Ready
NewReady creates a new Ready condition.
func (*Ready) Object ¶
func (r *Ready) Object() *unstructured.Unstructured
Object returns the last-known state of the object we're watching.
type Satisfier ¶
type Satisfier interface { Observer // Satisfied returns true when the criteria is met. Satisfied() (bool, error) // Object returns the last-known state of the object being observed. Object() *unstructured.Unstructured }
Satisfier is an Observer which evaluates the observed object against some criteria.
func NewJSONPath ¶
func NewJSONPath( ctx context.Context, source Source, logger logger, obj *unstructured.Unstructured, jsp *jsonpath.Parsed, ) (Satisfier, error)
NewJSONPath creates a new JSONPath condition.
type Source ¶
type Source interface {
Start(context.Context, schema.GroupVersionKind) (<-chan watch.Event, error)
}
Source encapsulates logic responsible for establishing watch.Event channels.
type Static ¶
Static implements Source and allows a fixed event channel to be used as an Observer's Source. Static should not be shared across multiple Observers, instead give each Observer their own channel.
type Stopped ¶
type Stopped struct {
// contains filtered or unexported fields
}
Stopped is satisfied after its underlying Observer has been exhausted. This is primarily useful for testing behavior which occurs on shutdown.
func NewStopped ¶
func NewStopped(logger logger, obj *unstructured.Unstructured) *Stopped
NewStopped creates a new Stopped condition.
func (*Stopped) Object ¶
func (s *Stopped) Object() *unstructured.Unstructured
Object returns the observer's underlying object.