def get_start_time( *, body: bodies.Body, patch: patches.Patch, handler: registries.ResourceHandler, ) -> Optional[datetime.datetime]: progress = patch.get('status', {}).get('kopf', {}).get('progress', {}) new_value = progress.get(handler.id, {}).get('started', None) progress = body.get('status', {}).get('kopf', {}).get('progress', {}) old_value = progress.get(handler.id, {}).get('started', None) value = new_value or old_value return None if value is None else datetime.datetime.fromisoformat(value)
def purge(self, patch: patches.Patch, body: bodies.Body) -> None: if 'progress' in body.get('status', {}).get('kopf', {}): patch_storage = patch.setdefault('status', {}).setdefault('kopf', {}) patch_storage['progress'] = None elif 'progress' in patch.get('status', {}).get('kopf', {}): del patch['status']['kopf']['progress'] # Avoid storing the empty status dicts (but do so if they have any content). if 'status' in patch and 'kopf' in patch['status'] and not patch['status']['kopf']: del patch['status']['kopf'] if 'status' in patch and not patch['status']: del patch['status']