2 # -*- coding: utf-8 -*-
4 """Create configuration for code search."""
10 ONAP_GERRIT = "https://gerrit.onap.org/r"
11 API_PROJECTS = "/projects/"
16 def get_projects_list():
17 """Request list of all available projects from ONAP Gerrit."""
18 resp = urllib.request.urlopen(ONAP_GERRIT + API_PROJECTS)
19 resp_body = resp.read()
21 no_magic = resp_body[len(MAGIC_PREFIX):]
22 decoded = no_magic.decode("utf-8")
23 projects = json.loads(decoded)
25 return projects.keys()
28 def create_repos_list(projects):
29 """Create a map of all projects to their repositories' URLs."""
30 return {p: {"url": "{}/{}.git".format(ONAP_GERRIT, p)} for p in projects}
34 """Main entry point for the script."""
35 repos = create_repos_list(get_projects_list())
37 "max-concurrent-indexers": 2,
39 "health-check-uri": "/healthz",
42 print(json.dumps(config, sort_keys=True, indent=4, separators=(',', ': ')))
45 if __name__ == '__main__':