Skip to content

Commit a1ef2ff

Browse files
committed
add verification of repo names
1 parent 7670dfa commit a1ef2ff

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

ccos/data/get_community_team_data.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,23 @@ def prune_databag(databag):
175175
return pruned
176176

177177

178+
def verify_databag(databag, repo_names):
179+
"""
180+
Ensure all repository names are accurate.
181+
"""
182+
for project in databag["projects"]:
183+
databag_repos = project["repos"].split(",")
184+
for databag_repo in databag_repos:
185+
if databag_repo not in repo_names:
186+
logger.log(
187+
logging.ERROR,
188+
f'"{project["name"]}" contains invalid reposiotry:'
189+
f' "{databag_repo}"',
190+
)
191+
sys.exit(1)
192+
return databag
193+
194+
178195
def get_custom_field(task, field_name):
179196
"""
180197
Gets the value of a custom field
@@ -187,5 +204,9 @@ def get_custom_field(task, field_name):
187204
return field["text_value"]
188205

189206

190-
def get_community_team_data(asana_client):
191-
return prune_databag(sort_databag(generate_databag(asana_client)))
207+
def get_community_team_data(asana_client, repo_names):
208+
databag = generate_databag(asana_client)
209+
databag = prune_databag(databag)
210+
databag = verify_databag(databag, repo_names)
211+
databag = sort_databag(databag)
212+
return databag

push_data_to_ccos.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
get_community_team_data,
1515
setup_asana_client,
1616
)
17-
from ccos.data.get_repo_data import get_repo_data
17+
from ccos.data.get_repo_data import get_repo_data, get_repo_names
1818
from ccos.data.push_data_via_git import push_data
1919

2020
DAILY_DATABAGS = ["repos", "community_team_members"]
@@ -57,10 +57,9 @@ def main():
5757
push_data(get_repo_data(), "repos.json")
5858
if "community_team_members" in args.databags:
5959
logger.log(logging.INFO, "community_team_members.json")
60-
push_data(
61-
get_community_team_data(asana_client),
62-
"community_team_members.json",
63-
)
60+
repo_names = get_repo_names()
61+
community_data = get_community_team_data(asana_client, repo_names)
62+
push_data(community_data, "community_team_members.json")
6463

6564

6665
if __name__ == "__main__":

0 commit comments

Comments
 (0)