from typing import Dict


def parse_metadata(s: str) -> Dict[str, str]:
    """
    Parses a METADATA or alternate_METADATA file and returns fields as a dict.

    Example:

    Wi-Fi soma-image-1.0 (nbg6817) Rootfs Build Information

    build-user: alanw
    build-host: devvm886.prn3.facebook.com
    build-time: Thu May  3 14:38:49 PDT 2018
    build-time-epoch: 1525383529
    commit-hash: 8592d04fcbfd5a844d98f3c761aeb6cbb32a6ea5
    config-overlay: mpkdogfood
    fbpkg: soma.image-mpkdogfood:5ff4882155f54506a6066a293f2ef2c4

    Returned:
    {
        "commit-hash": "8592d04fcbfd5a844d98f3c761aeb6cbb32a6ea5",
        "config-overlay": "mpkdogfood",
        "fbpkg": "soma.image-mpkdogfood:5ff4882155f54506a6066a293f2ef2c4",
    }
    """
    parsed: Dict[str, str] = {}
    for line in s.split("\n"):
        key, found, value = line.partition(": ")
        if found and " " not in key:
            parsed[key] = value.strip()
    return parsed