blob: 88717ef346265b9ce84519468d89933849b5a590 [file] [log] [blame]
Andrew Lambc89a70d2020-08-14 11:47:44 -06001#!/usr/bin/env python3
2# Copyright 2020 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Filters a ConfigBundle based on PublicReplication messages."""
6
7import argparse
8
9from checker import io_utils
10from chromiumos.config.payload import config_bundle_pb2
11from common import proto_utils
12
13
14def argument_parser():
15 """Returns an ArgumentParser for the script."""
16 parser = argparse.ArgumentParser(description=__doc__)
17 parser.add_argument(
18 '--input',
19 required=True,
20 help=('Path to the private config json proto e.g. '
21 '.../chromiumos/src/project/project1/generated/config.jsonproto.'),
22 metavar='PATH')
23 parser.add_argument(
24 '--output',
25 required=True,
26 help=('Path to the output the filtered public json proto.'),
27 metavar='PATH')
28 return parser
29
30
31def main():
32 """Runs the script."""
33 parser = argument_parser()
34 args = parser.parse_args()
35
36 private_config = io_utils.read_config(args.input)
37 public_config = config_bundle_pb2.ConfigBundle()
38
39 proto_utils.apply_public_replication(private_config, public_config)
40
41 io_utils.write_message_json(public_config, args.output)
42
43
44if __name__ == '__main__':
45 main()