Write merge_flat_configs utility to simplify merging FlatConfigLists
BUG=chromium:1073073
TEST=manual
Change-Id: I7ebb5d9b7303688cd6098f6202aa991f14658e46
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/config/+/2465573
Commit-Queue: Sean McAllister <smcallis@google.com>
Auto-Submit: Sean McAllister <smcallis@google.com>
Reviewed-by: Andrew Lamb <andrewlamb@chromium.org>
diff --git a/payload_utils/checker/io_utils.py b/payload_utils/checker/io_utils.py
index ee43989..e8b6585 100644
--- a/payload_utils/checker/io_utils.py
+++ b/payload_utils/checker/io_utils.py
@@ -12,7 +12,7 @@
from google.protobuf.message import Message
from chromiumos.config.payload import config_bundle_pb2
-
+from chromiumos.config.payload import flat_config_pb2
def write_message_json(message: Message, path: pathlib.Path, \
@@ -32,11 +32,10 @@
def read_config(path: str) -> config_bundle_pb2.ConfigBundle:
- """Reads a ConfigBundle mesage from a jsonpb file.
+ """Reads a ConfigBundle message from a jsonpb file.
Args:
- path: Path to the json proto. See note above about deprecated repo
- root behavior.
+ path: Path to the json proto.
Returns:
ConfigBundle parsed from file.
@@ -47,6 +46,21 @@
return project_config
+def read_flat_config(path: str) -> flat_config_pb2.FlatConfigList:
+ """Reads a FlatConfigList message from a jsonpb file.
+
+ Args:
+ path: Path to the json proto.
+
+ Returns:
+ FlatConfigList parsed from file.
+ """
+ flat_config = flat_config_pb2.FlatConfigList()
+ with open(path, 'r') as f:
+ json_format.Parse(f.read(), flat_config)
+ return flat_config
+
+
def read_model_sku_json(factory_dir: pathlib.Path) -> Dict[str, Any]:
"""Reads and parses the model_sku.json file.