Пример #1
0
        type_desc.qualified_package
        for type_name, type_desc in type_map.items()
        if next_version_upgrade(type_name, type_map, next_version_upgrade_memo)
    ]).union(set(['envoy.config.retry.previous_priorities', 'envoy.config.cluster.redis']))

    # Generate type map entries for upgraded types. We run this twice to allow
    # things like a v2 deprecated map field's synthesized map entry to forward
    # propagate to v4alpha (for shadowing purposes).
    for _ in range(2):
        type_map.update([
            upgraded_type_with_description(type_name, type_desc)
            for type_name, type_desc in type_map.items()
            if type_desc.qualified_package in next_versions_pkgs and (
                type_desc.active or type_desc.deprecated_type or type_desc.map_entry)
        ])

    # Generate the type database proto. To provide some stability across runs, in
    # terms of the emitted proto binary blob that we track in git, we sort before
    # loading the map entries in the proto. This seems to work in practice, but
    # has no guarantees.
    type_db = TypeDb()
    next_proto_info = {}
    for t in sorted(type_map):
        type_desc = type_db.types[t]
        type_desc.qualified_package = type_map[t].qualified_package
        type_desc.proto_path = type_map[t].proto_path

    # Write out proto text.
    with open(out_path, 'w') as f:
        f.write(str(type_db))
Пример #2
0
    upgraded_types = []
    for type_name, type_desc in type_map.items():
        if type_desc.qualified_package in next_versions_pkgs:
            upgrade_type_desc = TypeDescription()
            upgrade_type_desc.qualified_package = UpgradedType(
                type_desc.qualified_package)
            upgrade_type_desc.proto_path = UpgradedPath(type_desc.proto_path)
            upgraded_types.append((UpgradedType(type_name), upgrade_type_desc))
    for n, t in upgraded_types:
        type_map[n] = t

    # Generate the type database proto. To provide some stability across runs, in
    # terms of the emitted proto binary blob that we track in git, we sort before
    # loading the map entries in the proto. This seems to work in practice, but
    # has no guarantees.
    type_db = TypeDb()
    next_proto_path = {}
    for t in sorted(type_map):
        type_desc = type_db.types[t]
        type_desc.qualified_package = type_map[t].qualified_package
        type_desc.proto_path = type_map[t].proto_path
        if type_desc.qualified_package in next_versions_pkgs:
            type_desc.next_version_type_name = UpgradedType(t)
            assert (type_desc.next_version_type_name != t)
            next_proto_path[type_map[t].proto_path] = type_map[
                type_desc.next_version_type_name].proto_path
    for pkg in sorted(all_pkgs):
        if pkg in next_versions_pkgs:
            type_db.next_version_packages[pkg] = UpgradedType(pkg)
    for proto_path in sorted(next_proto_path):
        type_db.next_version_proto_paths[proto_path] = UpgradedPath(proto_path)
Пример #3
0
def load_type_db(type_db_path):
    global _typedb
    _typedb = TypeDb()
    with open(type_db_path, 'r') as f:
        text_format.Merge(f.read(), _typedb)
Пример #4
0
def load_type_db(type_db_path):
    type_db = TypeDb()
    with open(type_db_path, 'r') as f:
        text_format.Merge(f.read(), type_db)
    return type_db
Пример #5
0
def LoadTypeDb():
  typedb = TypeDb()
  with open(os.getenv('TYPE_DB_PATH'), 'r') as f:
    text_format.Merge(f.read(), typedb)
  return typedb