def gen_mapping(args, service, weight=None, labels={}):
    """
    Generate a Mapping for a service/prefix and (optional) weight
    """
    prefix = args.prefix
    mapping = {
        "apiVersion": "getambassador.io/v1",
        "kind":  "Mapping",
        "metadata": {
            "name":  f"mapping-for-{service}"
        },
        "spec": {
            "prefix": prefix,
            "service": service
        }
    }

    if args.namespace:
        mapping["metadata"]["namespace"] = args.namespace

    if len(labels) > 0:
        mapping["metadata"]["labels"] = labels

    if weight:
        mapping["spec"]["weight"] = weight

    return mapping