diff --git a/configs/config.json b/configs/config.json index b39e9279..fb01d5fd 100644 --- a/configs/config.json +++ b/configs/config.json @@ -4,6 +4,10 @@ { "Type": "github", "GitHubUser": "TaqlaAI" + }, + { + "Type": "gitlab", + "GitLabURL": "https://gitlab.com/api/v4/" } ] } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 3cba1b96..58a179a9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,7 @@ services: dockerfile: Dockerfile.zoekt-indexserver environment: - GITHUB_TOKEN=${GITHUB_TOKEN} + - GITLAB_TOKEN=${GITLAB_TOKEN} - CONFIG_PATH=/app/configs/config.json - ZOEKT_DATA_CACHE_DIR=/zoekt-data/ volumes: diff --git a/entrypoint.zoekt-indexserver.sh b/entrypoint.zoekt-indexserver.sh index 8c7c5d85..3796ce94 100644 --- a/entrypoint.zoekt-indexserver.sh +++ b/entrypoint.zoekt-indexserver.sh @@ -13,4 +13,12 @@ else echo -e "\e[33mWarning: Private GitHub repositories will not be indexed since GITHUB_TOKEN was not set. If you are not using GitHub, disregard.\e[0m" fi +# Check if GITLAB_TOKEN is set +if [ -n "$GITLAB_TOKEN" ]; then + echo "$GITLAB_TOKEN" > "$HOME/.gitlab-token" + chmod 600 "$HOME/.gitlab-token" +else + echo -e "\e[33mWarning: GitLab repositories will not be indexed since GITLAB_TOKEN was not set. If you are not using GitLab, disregard.\e[0m" +fi + exec "zoekt-indexserver" "-data_dir" "${ZOEKT_DATA_CACHE_DIR}" "-mirror_config" "${CONFIG_PATH}" diff --git a/schemas/zoekt-mirror.json b/schemas/zoekt-mirror.json index d85efb5a..9fc6d54f 100644 --- a/schemas/zoekt-mirror.json +++ b/schemas/zoekt-mirror.json @@ -2,10 +2,23 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "definitions": { + "RepoNameRegexIncludeFilter": { + "type": "string", + "description": "Only clone repos whose name matches the given regexp.", + "format": "regexp" + }, + "RepoNameRegexExcludeFilter": { + "type": "string", + "description": "Don't mirror repos whose names match this regexp.", + "format": "regexp" + }, "ZoektConfig": { "anyOf": [ { "$ref": "#/definitions/GitHubConfig" + }, + { + "$ref": "#/definitions/GitLabConfig" } ] }, @@ -28,18 +41,15 @@ "description": "The GitHub organization to mirror" }, "Name": { - "type": "string", - "description": "Only clone repos whose name matches the given regexp.", - "format": "regexp" + "$ref": "#/definitions/RepoNameRegexIncludeFilter" }, "Exclude": { - "type": "string", - "description": "Don't mirror repos whose names match this regexp.", - "format": "regexp" + "$ref": "#/definitions/RepoNameRegexExcludeFilter" }, "CredentialPath": { "type": "string", - "description": "Path to a file containing a GitHub access token." + "description": "Path to a file containing a GitHub access token.", + "default": "~/.github-token" }, "Topics": { "type": "array", @@ -70,6 +80,40 @@ "Type" ], "additionalProperties": false + }, + "GitLabConfig": { + "type": "object", + "properties": { + "Type": { + "const": "gitlab" + }, + "GitLabURL": { + "type": "string", + "description": "The GitLab API url.", + "default": "https://gitlab.com/api/v4/" + }, + "Name": { + "$ref": "#/definitions/RepoNameRegexIncludeFilter" + }, + "Exclude": { + "$ref": "#/definitions/RepoNameRegexExcludeFilter" + }, + "OnlyPublic": { + "type": "boolean", + "description": "Only mirror public repos", + "default": false + }, + "CredentialPath": { + "type": "string", + "description": "Path to a file containing a GitLab access token.", + "default": "~/.gitlab-token" + } + }, + "required": [ + "Type", + "GitLabURL" + ], + "additionalProperties": false } }, "properties": { diff --git a/vendor/zoekt b/vendor/zoekt index cab02224..3780e68c 160000 --- a/vendor/zoekt +++ b/vendor/zoekt @@ -1 +1 @@ -Subproject commit cab022245653c711f31d1fb0993a7741b11c648a +Subproject commit 3780e68cdb537d5a7ed2c84d9b3784f80c7c5d04