[Autotest] Metadata - move all logic into metadata/ directory

BUG=chromium:1072721
TEST=ran it

Change-Id: I15dfa0cdbb7464f262a8983795bf43d04129dd71
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2159601
Tested-by: Katherine Threlkeld <[email protected]>
Reviewed-by: Prathmesh Prabhu <[email protected]>
diff --git a/main.star b/main.star
index fc10a99..20276ec 100755
--- a/main.star
+++ b/main.star
@@ -1,39 +1,13 @@
 #!/usr/bin/env lucicfg generate
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
 
 # This is the main entry point for the generation of configuration.
 # Invoking (lucicfg is included with depot_tools):
 # lucicfg generate ./main.star
-# will update the configuration in the generated/ directory.
+# will update the configuration.
 
 
-# Load and register protos.
-load("@stdlib//internal/descpb.star", "wellknown_descpb")
-protos = proto.new_descriptor_set(
-    name = "chromiumos",
-    blob = io.read_file("metadata/proto/descpb.bin"),
-    deps = [wellknown_descpb],
-)
-protos.register()
-
-
-# Load test metadata.
-load("//metadata/metadata.star", "METADATA")
-
-
-# Generate metadata output.
-def _generate(config):
-    """
-    Serializes a proto message to files.
-
-    A text proto and binary proto are written.
-    """
-    def _generate_impl(ctx):
-        ctx.output["config.cfg"] = proto.to_textpb(config)
-        ctx.output["config.binaryproto"] = proto.to_wirepb(config)
-
-    lucicfg.generator(impl = _generate_impl)
-
-_generate(METADATA)
-
-
-
+load("//metadata/generate.star", "generate")
+generate()