aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/codesearch/create_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap/codesearch/create_config.py')
-rwxr-xr-xbootstrap/codesearch/create_config.py39
1 files changed, 19 insertions, 20 deletions
diff --git a/bootstrap/codesearch/create_config.py b/bootstrap/codesearch/create_config.py
index aef99e778..115b4672b 100755
--- a/bootstrap/codesearch/create_config.py
+++ b/bootstrap/codesearch/create_config.py
@@ -8,8 +8,8 @@ import json
import urllib.request
import sys
-DEFAULT_GERRIT = "https://gerrit.onap.org/r"
-DEFAULT_GIT = "https://git.onap.org"
+DEFAULT_GERRIT = "gerrit.onap.org"
+API_PREFIX = "/r"
API_PROJECTS = "/projects/"
MAGIC_PREFIX = ")]}'"
@@ -20,7 +20,7 @@ GIT_ANCHOR = "#n{line}"
def get_projects_list(gerrit):
"""Request list of all available projects from ONAP Gerrit."""
- resp = urllib.request.urlopen(gerrit + API_PROJECTS)
+ resp = urllib.request.urlopen("https://{}{}{}".format(gerrit, API_PREFIX, API_PROJECTS))
resp_body = resp.read()
no_magic = resp_body[len(MAGIC_PREFIX):]
@@ -30,23 +30,23 @@ def get_projects_list(gerrit):
return projects.keys()
-def create_repos_list(projects, gitweb, git, gerrit):
+def create_repos_list(projects, gerrit, ssh, git):
"""Create a map of all projects to their repositories' URLs."""
- gerrit_project_url = "{}/{}.git"
- gitweb_code_url = "{}/gitweb?p={}.git;hb=HEAD;a=blob;f={{path}}{{anchor}}"
-
- git_project_url = "{}/{}"
- git_code_url = "{url}/tree/{path}{anchor}"
+ gerrit_url = "https://{}{}".format(gerrit, API_PREFIX)
+ gerrit_project_url = "{}/{{}}.git".format(gerrit_url)
+ gitweb_code_url = "{}/gitweb?p={{}}.git;hb=HEAD;a=blob;f={{path}}{{anchor}}".format(gerrit_url)
repos_list = {}
for project in projects:
- if gitweb:
- project_url = gerrit_project_url.format(gerrit, project)
- code_url = gitweb_code_url.format(gerrit, project)
- anchor = GITWEB_ANCHOR
- else:
- project_url = git_project_url.format(git, project)
- code_url = git_code_url
+ project_url = gerrit_project_url.format(project)
+ code_url = gitweb_code_url.format(project)
+ anchor = GITWEB_ANCHOR
+
+ if ssh and len(ssh) == 2:
+ user, port = ssh[0], ssh[1]
+ project_url = "ssh://{}@{}:{}/{}.git".format(user, gerrit, port, project)
+ if git:
+ code_url = "https://{}/{}/tree/{{path}}{{anchor}}".format(git, project)
anchor = GIT_ANCHOR
repos_list[project] = {
@@ -64,9 +64,8 @@ def parse_arguments():
"""Return parsed command-line arguments."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--gerrit', help='Gerrit address', default=DEFAULT_GERRIT)
- access = parser.add_mutually_exclusive_group()
- access.add_argument('--gitweb', help='use Gerrit\'s gitweb (bool)', action='store_true')
- access.add_argument('--git', help='use external git (address)', default=DEFAULT_GIT)
+ parser.add_argument('--ssh', help='SSH information: user, port', nargs=2)
+ parser.add_argument('--git', help='external git address')
return parser.parse_args()
@@ -76,7 +75,7 @@ def main():
arguments = parse_arguments()
projects = get_projects_list(arguments.gerrit)
- repos = create_repos_list(projects, arguments.gitweb, arguments.git, arguments.gerrit)
+ repos = create_repos_list(projects, arguments.gerrit, arguments.ssh, arguments.git)
config = {
"max-concurrent-indexers": 2,
"dbpath": "data",