def format_event_templated_string(subject: Union[FindingSubject, ObjectReference], string_to_substitute) -> str:
    """
        For templating strings based on event subjects
    """
    variables: Dict[str, str] = defaultdict(lambda: "<missing>")
    kind = subject.kind if isinstance(subject, ObjectReference) else subject.subject_type.value
    variables.update(
        {
            "name": subject.name,
            "kind": kind,
            "namespace": subject.namespace if subject.namespace else "<missing>",
            "node": subject.node if isinstance(subject, FindingSubject) and subject.node else "<missing>",
        }
    )
    if isinstance(subject, FindingSubject):
        variables.update({f"labels.{key}": value for key, value in subject.labels.items()})
        variables.update({f"annotations.{key}": value for key, value in subject.annotations.items()})
    return ExtendedTemplate(string_to_substitute).safe_substitute(variables)

        For templating strings based on event subjects
    
src/robusta/utils/parsing.py