Example #1
0
def init_governors():
    """Get initial list of anarchy governors"""
    for resource in runtime.custom_objects_api.list_namespaced_custom_object(
        runtime.operator_domain, 'v1', runtime.operator_namespace, 'anarchygovernors'
    ).get('items', []):
        AnarchyGovernor.register(resource)
Example #2
0
def handle_governor_event(event, **_):
    if event['type'] == 'DELETED':
        AnarchyGovernor.unregister(event['object']['metadata']['name'])
    elif event['type'] in ['ADDED', 'MODIFIED', None] \
    and 'spec' in event['object']:
        AnarchyGovernor.register(event['object'])