Get a Resource from environment variables.

    :rtype: :class:`Resource`
    :return: A resource with type and labels from the environment.

def get_from_env():
    """Get a Resource from environment variables.

    :rtype: :class:`Resource`
    :return: A resource with type and labels from the environment.
    """
    type_env = os.getenv(OC_RESOURCE_TYPE)
    if type_env is None:
        return None
    type_env = type_env.strip()

    labels_env = os.getenv(OC_RESOURCE_LABELS)
    if labels_env is None:
        return Resource(type_env)

    labels = parse_labels(labels_env)

    return Resource(type_env, labels)