Filter

Filters are expressed in a single Python expression. Python expressions are extended in that regard, that you can navigate structured data (dict/map) like a native Python object. Using globals like len(), list() etc. is not allowed. You can access methods provided by native data types like str, int, float etc.

Accessible by the filter are 2 objects:

  • Event
  • Emitter

Event

The event is produced by Watchers is a simple Python object looking like this:

class watchm8.event.Event(_type, data)

Object emitted by watchers reflecting the event produced by observed resource.

Parameters:
  • _type (str) – The type of event, eg. created, modified, deleted, … This differs from resource to resource
  • data (dict) – The raw event data passed to watchers by the observed resource
data

The raw event data passed to watchers by the observed resource

Returns:event data
Return type:dict
type

The type of event, eg. created, modified, deleted, …

Returns:The event type
Return type:str

Emitter

The emitter is in almost all cases the Watcher, which produced the event. If an action was used to emit a new event the action would be the emitter.

Examples

event.type == "created" and event.data.metadata.labels.environment == "dev"
event.type.startswith("created") and event.data.metadata.labels.has_key("environment")