import re


def parse_env(env_in):
    """
    Parses all environment variables into a map.
    """
    env_out = {}
    reg = re.compile(r'^(?P<var_name>[A-Z0-9_\-]+)=(?P<var_value>.+)$')
    env_all = env_in.split(" ")
    for e in env_all:
        if e == "":
            continue

        match = reg.match(e.lstrip())
        if not match:
            raise ValueError("Invalid Environment variable supplied.")

        var_name = match.group("var_name")
        var_value = match.group("var_value")
        env_out[var_name] = var_value

    return env_out