diff options
author | Stan Hu <stanhu@gmail.com> | 2019-02-16 06:54:32 -0800 |
---|---|---|
committer | mfluharty <mfluharty@gitlab.com> | 2019-02-20 11:20:33 -0700 |
commit | 16e492f429759d507ad8b4f7619e567d937f84d2 (patch) | |
tree | cf9d8aa65784b12252fbbe5217918e43a534c13d | |
parent | cd32a95e14ebadbfb590c05bdd21b5b724a2ddb2 (diff) | |
download | gitlab-ce-16e492f429759d507ad8b4f7619e567d937f84d2.tar.gz |
Include gl_project_path in API /internal/allowed response
This will enable us to track the human-readable project path with SSH
access in gitlab-shell. Currently the Gitaly logs will only show the
hashed storage and gl_repository path (e.g. project-1234).
-rw-r--r-- | changelogs/unreleased/sh-include-project-path-for-internal-api.yml | 5 | ||||
-rw-r--r-- | lib/api/helpers/internal_helpers.rb | 8 | ||||
-rw-r--r-- | lib/api/internal.rb | 1 | ||||
-rw-r--r-- | spec/requests/api/internal_spec.rb | 4 |
4 files changed, 18 insertions, 0 deletions
diff --git a/changelogs/unreleased/sh-include-project-path-for-internal-api.yml b/changelogs/unreleased/sh-include-project-path-for-internal-api.yml new file mode 100644 index 00000000000..1973049e9e3 --- /dev/null +++ b/changelogs/unreleased/sh-include-project-path-for-internal-api.yml @@ -0,0 +1,5 @@ +--- +title: Include gl_project_path in API /internal/allowed response +merge_request: 25314 +author: +type: other diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb index 4eaaca96b49..fe78049af87 100644 --- a/lib/api/helpers/internal_helpers.rb +++ b/lib/api/helpers/internal_helpers.rb @@ -81,6 +81,14 @@ module API Gitlab::GlRepository.gl_repository(project, wiki?) end + def gl_project_path + if wiki? + project.wiki.full_path + else + project.full_path + end + end + # Return the repository depending on whether we want the wiki or the # regular repository def repository diff --git a/lib/api/internal.rb b/lib/api/internal.rb index b44ef2a6ea4..70b32f7d758 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -77,6 +77,7 @@ module API when ::Gitlab::GitAccessResult::Success payload = { gl_repository: gl_repository, + gl_project_path: gl_project_path, gl_id: Gitlab::GlId.gl_id(user), gl_username: user&.username, git_config_options: [], diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index 11d9ce354f1..cd85151ec1b 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -325,6 +325,7 @@ describe API::Internal do expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq('/') + expect(json_response["gl_project_path"]).to eq(project.wiki.full_path) expect(json_response["gl_repository"]).to eq("wiki-#{project.id}") expect(user.reload.last_activity_on).to be_nil end @@ -337,6 +338,7 @@ describe API::Internal do expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq('/') + expect(json_response["gl_project_path"]).to eq(project.wiki.full_path) expect(json_response["gl_repository"]).to eq("wiki-#{project.id}") expect(user.reload.last_activity_on).to eql(Date.today) end @@ -350,6 +352,7 @@ describe API::Internal do expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq('/') expect(json_response["gl_repository"]).to eq("project-#{project.id}") + expect(json_response["gl_project_path"]).to eq(project.full_path) expect(json_response["gitaly"]).not_to be_nil expect(json_response["gitaly"]["repository"]).not_to be_nil expect(json_response["gitaly"]["repository"]["storage_name"]).to eq(project.repository.gitaly_repository.storage_name) @@ -369,6 +372,7 @@ describe API::Internal do expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq('/') expect(json_response["gl_repository"]).to eq("project-#{project.id}") + expect(json_response["gl_project_path"]).to eq(project.full_path) expect(json_response["gitaly"]).not_to be_nil expect(json_response["gitaly"]["repository"]).not_to be_nil expect(json_response["gitaly"]["repository"]["storage_name"]).to eq(project.repository.gitaly_repository.storage_name) |