def deployment_events_enricher(event: DeploymentEvent, params: ExtendedEventEnricherParams):
    """
    Given a deployment, fetch related events in the near past.

    Can optionally fetch events for related pods instead.
    """
    dep = event.get_deployment()
    if not dep:
        logging.error(f"cannot run deployment_events_enricher on alert with no deployment object: {event}")
        return

    if params.dependent_pod_mode:
        pods = list_pods_using_selector(dep.metadata.namespace, dep.spec.selector, "status.phase!=Running")
        if pods:
            selected_pods = pods if len(pods) <= params.max_pods else pods[: params.max_pods]
            for pod in selected_pods:
                events_table_block = get_resource_events_table(
                    f"Pod events for {pod.metadata.name}",
                    "Pod",
                    pod.metadata.name,
                    pod.metadata.namespace,
                    included_types=params.included_types,
                    max_events=params.max_events,
                )
                if events_table_block:
                    event.add_enrichment(
                        [events_table_block],
                        {SlackAnnotations.ATTACHMENT: True},
                        enrichment_type=EnrichmentType.k8s_events,
                        title="Deployment Events",
                    )
    else:
        events_table_block = get_resource_events_table(
            "Deployment Events",
            dep.kind,
            dep.metadata.name,
            dep.metadata.namespace,
            included_types=params.included_types,
            max_events=params.max_events,
        )
        if events_table_block:
            event.add_enrichment(
                [events_table_block],
                {SlackAnnotations.ATTACHMENT: True},
                enrichment_type=EnrichmentType.k8s_events,
                title="Deployment Events",
            )

    Given a deployment, fetch related events in the near past.

    Can optionally fetch events for related pods instead.
    
playbooks/robusta_playbooks/event_enrichments.py