Repository: googleapis/synthtool

Issue:
Support multiple `codeowner_team`s in `.repo-metadata.json`
Today you can add a `codeowner_team` to `.repo-metadata.json`, and it will add that team as a CODEOWNER along side the language specific team.  There are cases where we want multiple teams, often both a DPE team and a product engineering team that need CODEOWERS access.  Ideally, `codeowner_team` would support both a string, and an array.  

Today, we would need to:
- hand modify the `CODEOWNERS` file
- Add `CODEOWNERS` to the ignore list `synth.py` when copying templates

Discussion:

Patch:
diff --git a/synthtool/gcp/templates/python_library/.github/blunderbuss.yml b/synthtool/gcp/templates/python_library/.github/blunderbuss.yml
index 18a3ed8..22ab79e 100644
--- a/synthtool/gcp/templates/python_library/.github/blunderbuss.yml
+++ b/synthtool/gcp/templates/python_library/.github/blunderbuss.yml
@@ -5,17 +5,23 @@
 # team, please update `codeowner_team` in `.repo-metadata.json`.
 {% if metadata['repo']['codeowner_team']|length -%}
 assign_issues:
-  - {{ metadata['repo']['codeowner_team'].replace("@","") }}
+  {%- for codeowner in metadata['repo']['codeowner_team'].replace("@","").split(" ") %}
+  - {{ codeowner }}
+  {%- endfor %}
 
 assign_issues_by:
   - labels:
       - "samples"
     to:
       - googleapis/python-samples-reviewers
-      - {{ metadata['repo']['codeowner_team'].replace("@","") }}
+      {%- for codeowner in metadata['repo']['codeowner_team'].replace("@","").split(" ") %}
+      - {{ codeowner }}
+      {%- endfor %}
 
 assign_prs:
-  - {{ metadata['repo']['codeowner_team'].replace("@","") }}
+  {%- for codeowner in metadata['repo']['codeowner_team'].replace("@","").split(" ") %}
+  - {{ codeowner }}
+  {%- endfor %}
 {% else %}
 assign_issues:
   - googleapis/python-core-client-libraries


Test patch:
diff --git a/tests/test_python_library.py b/tests/test_python_library.py
index 0019ba7..b4d5019 100644
--- a/tests/test_python_library.py
+++ b/tests/test_python_library.py
@@ -178,7 +178,7 @@ def assert_valid_yaml(file):
             pytest.fail(f"unable to parse YAML: {file}")
 
 
-def test_library_blunderbuss():
+def test_library_blunderbuss_single_codeowner():
     t = templates.Templates(PYTHON_LIBRARY / ".github")
     result = t.render(
         "blunderbuss.yml",
@@ -188,6 +188,7 @@ def test_library_blunderbuss():
         config = yaml.safe_load(result)
         assert "googleapis/python-core-client-libraries" not in config["assign_issues"]
         assert "googleapis/foo" in config["assign_issues"]
+        assert "googleapis/foo" in config["assign_prs"]
         assert (
             "googleapis/python-samples-reviewers" in config["assign_issues_by"][0]["to"]
         )
@@ -196,6 +197,28 @@ def test_library_blunderbuss():
         pytest.fail(f"unable to parse YAML: {result}")
 
 
+def test_library_blunderbuss_multiple_codeowner():
+    t = templates.Templates(PYTHON_LIBRARY / ".github")
+    result = t.render(
+        "blunderbuss.yml",
+        metadata={"repo": {"codeowner_team": "googleapis/foo googleapis/bar"}},
+    ).read_text()
+    try:
+        config = yaml.safe_load(result)
+        assert "googleapis/python-core-client-libraries" not in config["assign_issues"]
+        assert "googleapis/foo" in config["assign_issues"]
+        assert "googleapis/bar" in config["assign_issues"]
+        assert "googleapis/foo" in config["assign_prs"]
+        assert "googleapis/bar" in config["assign_prs"]
+        assert (
+            "googleapis/python-samples-reviewers" in config["assign_issues_by"][0]["to"]
+        )
+        assert "googleapis/foo" in config["assign_issues_by"][0]["to"]
+        assert "googleapis/bar" in config["assign_issues_by"][0]["to"]
+    except yaml.YAMLError:
+        pytest.fail(f"unable to parse YAML: {result}")
+
+
 def test_library_blunderbuss_no_codeowner():
     t = templates.Templates(PYTHON_LIBRARY / ".github")
     result = t.render(