summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-08-22 14:04:58 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-08-22 14:19:59 +0200
commitaa15c9feecf7e8f69d65371d784c00d6552eebb9 (patch)
treef8d9cc597d34fe1d3810d5da3fd7289b6bf3e45a
parentf3d9e19b02b57a15d9ba34b2bfd8756b3eb8b2bd (diff)
downloadgitlab-ce-aa15c9feecf7e8f69d65371d784c00d6552eebb9.tar.gz
Add cluster project id to jupyter config
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/models/clusters/applications/jupyter.rb9
-rw-r--r--spec/models/clusters/applications/jupyter_spec.rb13
2 files changed, 22 insertions, 0 deletions
diff --git a/app/models/clusters/applications/jupyter.rb b/app/models/clusters/applications/jupyter.rb
index ef1c76c03bd..a51687ca954 100644
--- a/app/models/clusters/applications/jupyter.rb
+++ b/app/models/clusters/applications/jupyter.rb
@@ -72,10 +72,19 @@ module Clusters
"clientSecret" => oauth_application.secret,
"callbackUrl" => callback_url
}
+ },
+ "singleuser" => {
+ "extraEnv" => {
+ "GITLAB_PROJECT_ID" => project_id
+ }
}
}
end
+ def project_id
+ cluster&.project&.id
+ end
+
def gitlab_url
Gitlab.config.gitlab.url
end
diff --git a/spec/models/clusters/applications/jupyter_spec.rb b/spec/models/clusters/applications/jupyter_spec.rb
index 027b732681b..89eb7b45f8c 100644
--- a/spec/models/clusters/applications/jupyter_spec.rb
+++ b/spec/models/clusters/applications/jupyter_spec.rb
@@ -99,8 +99,21 @@ describe Clusters::Applications::Jupyter do
expect(values).to include('rbac')
expect(values).to include('proxy')
expect(values).to include('auth')
+ expect(values).to include('singleuser')
expect(values).to match(/clientId: '?#{application.oauth_application.uid}/)
expect(values).to match(/callbackUrl: '?#{application.callback_url}/)
end
+
+ context 'when cluster belongs to a project' do
+ let(:project) { create(:project) }
+
+ before do
+ application.cluster.projects << project
+ end
+
+ it 'sets GitLab project id' do
+ expect(values).to match(/GITLAB_PROJECT_ID: '?#{project.id}/)
+ end
+ end
end
end