• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""Functions to generate proto payloads."""
2
3def _generate(config, output = "config.jsonproto"):
4    """Serializes a ConfigBundle to a file.
5
6    A json proto is written. Note that there is some post processing done
7    by the gen_config script to convert this json output into a json
8    output that uses ints for encoding enums.
9    """
10
11    def _generate_impl(ctx):
12        ctx.output[output] = proto.to_jsonpb(config)
13
14    lucicfg.generator(impl = _generate_impl)
15
16def _gen_file(content, output = "new_generated_file"):
17    """Create a new file with open file name and free content.
18
19    We can define the file name and file content freely.
20    The new file will be created in the same directory of jsonproto files
21    in each project repo. Example: project/fake/fake/generated/newfile
22    """
23
24    def _gen_file_impl(ctx):
25        ctx.output[output] = content
26
27    lucicfg.generator(impl = _gen_file_impl)
28
29generate = struct(
30    generate = _generate,
31    gen_file = _gen_file,
32)
33